October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk11 min

How to Set Up Zero-Downtime Rails Deploys With Puma on a VPS

A practical VPS architecture for zero-downtime Rails releases: prepare immutable directories, switch a stable symlink, restart Puma workers in phases, and keep database changes compatible during overlap.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep runtime data in shared paths

Code is release-specific. Runtime data is not. Create shared locations for:

  • log for Rails and Puma logs
  • tmp/pids for the PID and state files
  • tmp/sockets for 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 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:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[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
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • 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

  1. Reload unit files: sudo systemctl daemon-reload.
  2. Enable startup at boot: sudo systemctl enable myapp-puma.
  3. Start Puma: sudo systemctl start myapp-puma.
  4. Inspect state and recent errors: sudo systemctl status myapp-puma and sudo journalctl -u myapp-puma.
  5. Confirm that /var/www/myapp/shared/sockets/puma.sock exists and is accessible to the NGINX user.
  6. 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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:

  1. Fetch the exact commit. Create a new directory under /var/www/myapp/releases/ and check out the intended revision there. Never build directly in current.
  2. 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.
  3. Link shared files and directories. Link credentials, config/database.yml, logs, temporary directories, sockets, cache, and uploads from /var/www/myapp/shared.
  4. Precompile production assets. Run RAILS_ENV=production bin/rails assets:precompile. Rails writes the compiled output to public/assets. If the build does not need production secrets, SECRET_KEY_BASE_DUMMY can provide the required placeholder during precompilation; do not use it as the application’s runtime secret.
  5. 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:migrate and supports conditional migration configuration.
  6. 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.
  7. Switch the symlink atomically. Point current at the prepared directory in one filesystem rename operation. Do not copy files into the existing active directory.
  8. 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.
  9. 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.