The reliable pattern is to prepare each Rails release completely, switch a stable current symlink atomically, and use Puma’s phased restart under systemd. NGINX can terminate TLS and serve static files, while Puma continues accepting requests through a Unix socket. The design keeps the previous release available, makes database changes compatible with both worker versions, and gives you a controlled rollback path.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
This guide builds that setup on a single VPS. It covers directory layout, Puma cluster configuration, systemd supervision, NGINX integration, deployment ordering, migrations, assets, verification, rollback, and the trade-offs between restart strategies.
As an Amazon Associate I earn from qualifying purchases.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →What zero-downtime means in this setup
A deploy is not zero-downtime merely because a command finishes quickly. Requests must continue to receive a valid response while new application code becomes active. During a Puma phased restart, old and new workers can briefly coexist. That overlap is why application code and database schema must remain mutually compatible during the transition.
The request path used here is:
client → NGINX → Puma Unix socket → Rails
NGINX is an implementation choice, not a requirement of Puma. It is useful when the VPS needs TLS termination, static-file delivery, or a public-facing reverse proxy. Puma itself should run as a foreground process under an operating-system supervisor rather than daemonizing itself. Puma’s deployment guidance specifically recommends a process monitor such as systemd for this role.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Plan the VPS before installing anything
Use immutable release directories
Store every deploy in its own timestamped directory and expose only a stable symlink to the active version:
/var/www/myapp/ ├── current -> releases/20261015040100
├── releases/
│ ├── 20261015035912/
│ └── 20261015040100/
└── shared/
The timestamp in this example is illustrative. Your deploy process should generate a unique value for every release. The current link is the only path systemd and NGINX need to know; changing it atomically avoids exposing a half-copied directory.
Keep runtime data in shared paths
Code is release-specific. Runtime data is not. Create shared locations for:
logfor Rails and Puma logstmp/pidsfor the PID and state filestmp/socketsfor the Unix socket- cache data that must survive a release switch
- user uploads and other persistent files
- secrets and linked configuration such as
config/database.yml
Capistrano Rails supports this model through linked files and directories, and also provides deployment tasks for migrations and assets. Ensure the deploy user owns the release and shared trees while the web-facing process has only the access it needs.
Choose Puma mode and capacity deliberately
Use Puma cluster mode when the VPS has more than one CPU core so multiple worker processes can use the available CPU resources. Single mode is generally intended for a fully multithreaded Ruby implementation or an MRI host with only one CPU core. Workers and threads are capacity settings, not universal performance recommendations: measure memory use and CPU saturation, then load-test before increasing concurrency.
Every Puma worker can hold a database connection for each active thread. Set the Rails connection pool high enough for the configured concurrency, but do not use a large pool to compensate for an undersized database. The illustrative configuration below uses two workers and five threads per worker; replace those values after measuring your VPS.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Configure Puma for a graceful deployment
Example config/puma.rb
workers Integer(ENV.fetch("WEB_CONCURRENCY", 2))
threads_count = Integer(ENV.fetch("RAILS_MAX_THREADS", 5))
threads threads_count, threads_count
preload_app!
plugin :tmp_restart
bind "unix:///var/www/myapp/shared/sockets/puma.sock"
pidfile "/var/www/myapp/shared/tmp/pids/puma.pid"
state_path "/var/www/myapp/shared/tmp/pids/puma.state"
environment ENV.fetch("RAILS_ENV", "production")
The worker and thread numbers are deliberately illustrative. Keep the socket, PID file, and state file under shared so they survive a release change. The service will start Puma from /var/www/myapp/current, so the same configuration follows the active release.
Decide whether to preload
preload_app! loads the application before workers are forked and can reduce duplicated memory in suitable applications. It is optional. Before enabling it, verify that boot hooks, background clients, and database connections are correctly re-established in each worker. An application that opens connections or starts threads during preload may need explicit worker boot and shutdown hooks.
Use the restart controls Puma expects
The plugin :tmp_restart line enables Puma’s temporary-file restart mechanism, but a production deploy can also use Puma’s control interface or send SIGUSR1 to request a phased restart. Do not confuse that signal with a normal process restart: phased restart replaces workers one at a time while leaving the master process in place.
Run Puma as a systemd service
Service unit
Create a unit such as /etc/systemd/system/myapp-puma.service and adapt the user, Ruby executable path, and environment-loading method to the VPS:
[Unit]
Description=MyApp Puma
After=network.target
[Service]
Type=notify
User=deploy
WorkingDirectory=/var/www/myapp/current
ExecStart=/var/www/myapp/current/bin/puma -C /var/www/myapp/current/config/puma.rb
Restart=always
RestartSec=5
WatchdogSec=10
[Install]
WantedBy=multi-user.target
Puma 5.1 and later support Type=notify and watchdog integration when the required notification support is available. If your installed Puma or service environment cannot provide systemd notifications, use a service type appropriate to that installation instead of claiming readiness that the process cannot report.
When Ruby is managed by a version manager, an interactive shell’s PATH is not automatically available to systemd. Use an absolute Puma executable path or explicitly load the manager’s environment in a wrapper. The unit’s working directory must be the current symlink, not an old timestamped release.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Enable and verify the unit
- Reload unit files:
sudo systemctl daemon-reload. - Enable startup at boot:
sudo systemctl enable myapp-puma. - Start Puma:
sudo systemctl start myapp-puma. - Inspect state and recent errors:
sudo systemctl status myapp-pumaandsudo journalctl -u myapp-puma. - Confirm that
/var/www/myapp/shared/sockets/puma.sockexists and is accessible to the NGINX user. - Request a health endpoint locally before sending public traffic.
Puma documents socket activation as another systemd option. With socket activation, systemd owns the listening socket and can keep it open while the service process is restarted. That is different from the phased-restart flow below and requires a separate .socket unit and matching Puma setup.
Put NGINX in front of the Unix socket
Configure NGINX to terminate TLS and proxy dynamic requests to the shared Puma socket. Serve fingerprinted files directly from the active release or from a shared asset location. The important operational requirements are stable socket permissions, a health endpoint that does not require a user session, and a proxy timeout long enough for legitimate application requests.
Rails production asset precompilation creates digest-named files in public/assets. NGINX can assign a long cache lifetime to that directory, commonly using a one-year expiry with Cache-Control: public. Because filenames are fingerprinted, clients can safely cache them while a new release introduces different names.
Do not delete old digested files immediately if browsers or intermediary caches may still request pages from the previous release. If assets are shared between releases, make cleanup retention-aware so it cannot remove files referenced by cached HTML.
Build a release without interrupting requests
Prepare everything before changing current. A practical sequence is:
- Fetch the exact commit. Create a new directory under
/var/www/myapp/releases/and check out the intended revision there. Never build directly incurrent. - Install locked dependencies. Run the Bundler command required by the project’s lockfile, plus any locked JavaScript package installation. Fail the release if dependency resolution changes unexpectedly.
- Link shared files and directories. Link credentials,
config/database.yml, logs, temporary directories, sockets, cache, and uploads from/var/www/myapp/shared. - Precompile production assets. Run
RAILS_ENV=production bin/rails assets:precompile. Rails writes the compiled output topublic/assets. If the build does not need production secrets,SECRET_KEY_BASE_DUMMYcan provide the required placeholder during precompilation; do not use it as the application’s runtime secret. - Apply only compatible migrations. Run the migration task before cutover when the migration is safe for both the old and new code. Capistrano Rails exposes
deploy:migrateand supports conditional migration configuration. - Boot-check the new release. Load the application, verify configuration, and make a local request against the new code. Check that the health endpoint, database connection, asset URLs, and critical dependencies work before traffic can reach this release.
- Switch the symlink atomically. Point
currentat the prepared directory in one filesystem rename operation. Do not copy files into the existing active directory. - Request a phased restart. Use Puma’s control mechanism or
SIGUSR1. Puma stops an old worker, starts its replacement, waits for the replacement to start successfully, and then continues to the next worker while the master remains running. - Verify externally. Check the public health endpoint, HTTP status and latency, error rates, Puma and Rails logs, and the asset URLs. Keep the previous release available until these checks pass.
A phased restart can briefly leave processes from both releases alive. Budget memory for that overlap, especially when workers are large or the VPS is close to its RAM limit.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallRank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Make database migrations safe for overlapping workers
The database is shared by old and new workers, so a schema change must not require every process to upgrade at the same instant. Use an expand-and-contract sequence:
1. Expand the schema
Add nullable columns, new tables, or additive indexes without removing or renaming structures that the old release still uses. Avoid a migration that requires old workers to write a column they do not know about.
2. Deploy dual-compatible code
Release code that can read the old and new shapes, and write in a way both versions tolerate. Feature flags can keep new behavior disabled while the schema change propagates.
3. Backfill separately
Run a controlled backfill outside the request path when possible. Monitor lock duration, transaction size, replication or database health, and application latency. A phased Puma restart does not eliminate database-lock time.
4. Switch reads and writes
After the backfill and compatibility checks, enable the new column or table for normal traffic. Keep the old representation available through the rollback window.
5. Contract later
Only after old workers are gone and rollback is no longer expected should you remove obsolete columns, constraints, or code paths. Destructive migrations require a separately planned recovery procedure; they are not automatically reversible because the application restarted cleanly.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Choose the restart strategy that matches your risk
| Strategy | Request continuity | Old/new code overlap | Database requirement | Memory and complexity | Rollback speed |
|---|---|---|---|---|---|
| Phased restart | Worker-by-worker replacement; designed for continuous service | Yes, briefly | Must support both versions during the overlap | Temporary extra worker memory; moderate operational complexity | Fast if the previous release and compatible schema remain available |
| Normal or hot process restart | Can leave a gap while the listener closes and the new process initializes | Not necessarily | Still requires schema planning if traffic resumes during a transition | Simpler, but interruption risk is higher | Depends on process startup and listener recovery |
| Socket-activated restart | systemd can hold the listening socket while Puma restarts | Usually process replacement rather than worker overlap | Plan for any code transition separately | More unit configuration; socket ownership stays with systemd | Good when the socket unit is correctly configured |
| Blue-green deployment | Traffic moves between two complete environments | Yes, at environment level | Shared database still needs backward-compatible changes | Requires capacity for two stacks and greater operational complexity | Very fast traffic reversal if both environments remain healthy |
Do not use systemctl restart myapp-puma as the normal code-deploy operation when a request-serving gap is unacceptable. A normal service restart closes listener sockets while the new process initializes. Use phased restart for the worker-replacement path, or deliberately configure socket activation when its operational model fits the VPS.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Verify, monitor, and retain a rollback point
Checks immediately after cutover
- Request the public health endpoint through NGINX, not only localhost.
- Confirm the response status, database access, and a representative authenticated or write path where safe.
- Inspect
journalctl -u myapp-puma, Rails logs, and NGINX error logs for boot failures, permission errors, and upstream disconnects. - Check that the socket is owned and permissioned so NGINX can connect while unrelated users cannot write to it.
- Load a page that references fingerprinted assets and confirm that every asset URL returns successfully.
- Watch error rate, response latency, memory pressure, and worker restarts for several minutes.
Rollback when the new release fails before cutover
If boot checks fail, do not move current. Fix the release or remove it while the previous version continues serving traffic. The failed release’s systemd and Rails logs usually reveal missing environment variables, dependency errors, failed initializers, or incorrect permissions.
Rollback after cutover
If the symlink has switched but health checks fail, point current back to the previous release and request another phased restart. This is safe only when the database schema remains readable and writable by both versions. If a migration removed or irreversibly transformed data, a code rollback alone cannot restore compatibility; use the separately prepared database recovery plan.
Retain at least the previous known-good release, its compiled assets, and the deployment metadata until the observation window closes. Clean older releases only after confirming that no rollback or cached asset request depends on them.
Common failure modes and fixes
Systemd starts the wrong Ruby or Puma
Interactive shell configuration does not automatically reach systemd. Replace a bare puma command with an absolute executable path or a wrapper that loads the intended Ruby environment, then run systemctl daemon-reload and restart the unit.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →NGINX reports a bad gateway
Check that Puma is active, the socket exists at the path in puma.rb, and the NGINX user can traverse every parent directory and connect to the socket. A stale socket can remain after an unclean shutdown; stop the service, remove only the stale runtime socket, and start Puma again.
Workers crash during phased restart
Read the Puma journal for boot exceptions, missing secrets, and database connection failures. Confirm that worker boot hooks recreate connections and that the new release can load from the current path. Do not repeatedly signal Puma while workers are failing; restore the previous release if the health check cannot pass.
Old pages cannot load new assets
Keep digest-named assets from the prior release available for the cache lifetime of old HTML. Review cleanup jobs and shared-directory links before deleting anything under public/assets.
A migration blocks requests
Stop treating worker replacement as a database migration strategy. Break the change into expand, compatibility, backfill, switch, and contract phases; schedule locking work separately and measure its impact before running it on production traffic.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteQuick Recap
A repeatable deployment checklist
- Confirm the commit, release timestamp, and rollback target.
- Build and test in a new release directory.
- Install locked Ruby and JavaScript dependencies.
- Link secrets, persistent files, logs, caches, PID paths, and sockets.
- Precompile production assets before changing
current. - Run only migrations that old and new workers both tolerate.
- Boot-check the release locally.
- Atomically update
current. - Trigger Puma’s phased restart, not a routine systemd stop/start.
- Check the public endpoint, logs, assets, errors, latency, and memory.
- Keep the previous release until the observation and rollback window ends.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




