Use timestamped release directories, a stable current symlink, Puma supervised by systemd, and Puma’s phased restart. Prepare and test the new release before switching traffic, run only backward-compatible database migrations, then replace workers one at a time. This keeps the Puma master and listening socket available while old and new application code briefly overlap.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
The deployment design that avoids a request gap
A reliable VPS deployment separates immutable application releases from runtime data. Each build is unpacked into its own directory, while a stable path points to the release currently serving traffic:
As an Amazon Associate I earn from qualifying purchases.
/var/www/myapp/releases/20261015040100
/var/www/myapp/current -> /var/www/myapp/releases/20261015040100
Logs, process IDs, Unix sockets, cache data, uploads, and secrets live under a shared directory rather than inside a release that will later be deleted. Puma runs from /var/www/myapp/current as a foreground process under systemd. NGINX can terminate TLS, serve static files, and proxy dynamic requests to Puma’s Unix socket:
client → NGINX → Puma Unix socket → Rails
NGINX is a practical implementation, not a requirement imposed by Puma. Any front end that can proxy to the socket can fill that 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.
Why the stable symlink matters
Building in a new directory prevents half-installed code from receiving requests. The running service continues to use the previous target until the new release has passed dependency installation, asset compilation, migration checks, and boot checks. Changing the symlink is then a short filesystem operation instead of a long in-place update.
What must be shared
config/database.ymland production credentials or other secret files.logand runtime directories undertmp, including Puma’s PID and state files.- The socket directory used by NGINX and Puma.
- Application cache where losing the cache on every deploy is unacceptable.
- User uploads and any other files created at runtime.
Capistrano Rails supports this release layout, linked files and directories, asset tasks, and deployment migrations. You can implement the same pattern with a shell script or another release tool as long as the ordering remains the same.
Free tools Windows power users keep installed
One-click scans. No signup required.
Prerequisites and host preparation
Before the first production deployment, confirm that the VPS has a supported Ruby and Bundler installation, the production database is reachable, the web server can read the Puma socket, and the deploy user owns the application tree. The service account should not need root access to read releases or write shared runtime directories.
Create the directory layout
sudo mkdir -p /var/www/myapp/releases
sudo mkdir -p /var/www/myapp/shared/{log,tmp/pids,tmp/sockets,cache,uploads,config}
sudo chown -R deploy:deploy /var/www/myapp
Place the shared database configuration and credentials in their final locations, then link them into every release. Keep permissions restrictive for secrets. Ensure the socket directory is writable by Puma and readable by the NGINX worker account; group ownership or an appropriate systemd umask is usually safer than making the socket world-readable.
Define a health endpoint
Use an endpoint that can prove the Rails process booted and can answer a request without performing an expensive business operation. It should return a success status only when the application is ready for traffic. The deployment checks below assume an endpoint such as /health; use the path implemented by your application.
Configure Puma for the VPS
Puma’s deployment guidance generally favors cluster mode when the machine has more than one CPU core, because multiple workers can use available CPU resources. Single mode is generally appropriate for a fully multithreaded Ruby implementation or a machine with only one CPU core. Worker and thread counts must be chosen from measured CPU and memory capacity, then validated with a load test; the values in this example are illustrative, not sizing recommendations.
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/tmp/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")
Choose workers and threads deliberately
Every worker is a separate Ruby process and therefore consumes its own memory. Threads share a worker’s memory but require thread-safe application code and enough database connections for the concurrency you configure. Increasing both values without measurement can exhaust RAM or the database before it improves throughput. Start conservatively, observe memory and response errors, and load-test before raising concurrency.
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.
Understand preload_app!
Preloading can reduce duplicated memory through copy-on-write, but it changes boot behavior. Validate initialization hooks, reconnect database clients after forking, and verify that libraries are safe in this arrangement before enabling it. It is an optional tuning choice, not a prerequisite for phased restarts.
Use a shared socket and state path
The socket and state files must not disappear when the symlink changes. Keeping them under shared lets NGINX retain a stable destination and lets the control command find the Puma master across releases.
Run Puma as a supervised systemd service
Puma should remain in the foreground. Its deployment documentation recommends an operating-system process monitor such as systemd and notes that daemonization is not required for zero-downtime restarts.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →[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 Ruby, Puma, or systemd environment cannot provide notifications, use a service type appropriate to that installation rather than claiming readiness that cannot be reported. Adapt the executable path if Ruby is installed through a version manager, and load environment variables through a controlled systemd environment file or wrapper.
Enable, start, and inspect the service
sudo systemctl daemon-reload
sudo systemctl enable myapp-puma
sudo systemctl start myapp-puma
sudo systemctl status myapp-puma
sudo journalctl -u myapp-puma -n 100 --no-pager
Before deploying application code, confirm that Puma creates the shared socket, the health endpoint answers locally, and NGINX can connect to that socket. Puma also documents socket activation as an option: systemd owns the listening socket and keeps it open while the service is restarted. That is a separate design from a normal service restart and can provide a hot-restart behavior when configured correctly.
Proxy Puma through NGINX
A typical NGINX configuration defines the Puma Unix socket as an upstream and forwards the original host, client address, and protocol. The exact server block depends on your TLS and domain configuration, but the dynamic location needs to target the same shared socket configured in Puma.
upstream myapp_puma {
server unix:/var/www/myapp/shared/tmp/sockets/puma.sock;
}
server {
listen 443 ssl;
server_name app.example;
location / {
proxy_pass http://myapp_puma;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Test the configuration before reloading NGINX, and verify socket permissions if NGINX reports a permission-denied or upstream-unavailable error. NGINX can also serve fingerprinted assets directly, reducing work for Rails.
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 #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.
Cache fingerprinted assets safely
Production asset precompilation creates digest-named files under public/assets. Rails documentation shows an NGINX rule that gives these immutable-looking files a one-year expiry and Cache-Control: public. Retain old compiled files for as long as cached HTML from the previous release may reference them. If shared asset cleanup removes a digest too early, clients can receive missing CSS or JavaScript even though the new release is healthy.
The release sequence
Do all expensive and failure-prone work before changing current. A safe sequence is:
- Fetch the exact commit. Create a new timestamped directory under
/var/www/myapp/releasesand check out the intended revision there. Never build directly incurrent. - Install locked dependencies. Run Bundler in deployment mode and install any locked JavaScript dependencies required by the asset build. Fail the deployment if the lockfiles cannot be honored.
- Link shared files and directories. Link database configuration, credentials, logs, runtime directories, cache, sockets, and uploads into the new release. Check that every link resolves before continuing.
- Compile production assets. Run
RAILS_ENV=production bin/rails assets:precompile. Rails normally performs this during deployment and writes compiled files topublic/assets. If the build does not require production secrets,SECRET_KEY_BASE_DUMMYcan provide a build-only key. - Apply only compatible migrations. Run the production migration task before cutover, but restrict it to changes that both the old and new code can tolerate. Capistrano Rails exposes
deploy:migrateand supports conditional migration configuration. - Boot-check the new release. Load the application with the new environment, verify the configured health endpoint locally, and inspect logs for missing secrets, failed initializers, or database connection errors.
- Atomically move the pointer. Create a temporary symlink and replace
currentin one rename operation:
ln -s /var/www/myapp/releases/20261015040100 /var/www/myapp/current.new
mv -Tf /var/www/myapp/current.new /var/www/myapp/current
- Request a phased restart. Tell the existing Puma master to replace workers one at a time. You can use Puma’s control mechanism or send
SIGUSR1to the master process:
kill -USR1 "$(cat /var/www/myapp/shared/tmp/pids/puma.pid)"
- Verify after replacement. Check the public health endpoint, response errors, Puma and Rails logs, asset URLs, and a representative authenticated request. Keep the previous release until these checks pass and the rollback window closes.
What a phased restart actually does
Puma’s phased restart kills an old worker, starts a new worker, waits for the new worker to start successfully, and then proceeds to the next worker. The master process remains running, so the listener does not need to be closed for the replacement.
During the operation, old and new workers can exist simultaneously. That overlap is the central database requirement: both versions must be able to use the schema and data at the same time. A phased restart is therefore not a way to make an incompatible schema change harmless.
Phased restart versus other restart strategies
| Strategy | Request continuity | Old/new code overlap | Migration constraint | Memory and operations |
|---|---|---|---|---|
| Phased restart | Workers are replaced individually while the Puma master remains active. | Yes, briefly. | Schema must support both versions. | Requires spare capacity for replacement workers and careful readiness checks. |
| Normal systemd restart | Not guaranteed; the service can close listener sockets while the new process initializes. | Usually no worker overlap. | Still requires a deployable schema, but it does not solve request interruption. | Simpler, but unsuitable when a serving gap is unacceptable. |
| Socket-activated restart | systemd can keep the listening socket open while Puma restarts. | Depends on how the replacement is configured. | Does not remove schema compatibility work. | More systemd configuration and another failure mode to monitor. |
| Blue-green deployment | Traffic switches between separately running environments. | Yes, for the duration of the cutover. | Shared database still requires compatible versions. | Needs substantially more memory and duplicate infrastructure, but can make rollback fast. |
Use phased restart when one VPS has enough headroom for worker overlap and you want a compact deployment. Consider socket activation or a second environment when your startup behavior, memory profile, or rollback requirements make worker replacement insufficient.
Design migrations for overlapping workers
Use an expand-and-contract sequence rather than changing a live schema in one destructive step.
Expand
Add nullable columns, new tables, indexes, or other additive structures first. The old release must continue to work when these objects exist but are unused. Avoid a migration that immediately renames or drops something the old workers still query.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #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
Deploy dual-compatible code
Release code that can read the old and new shapes. When changing a column or serialized representation, temporarily support both formats. Deploy writers that populate the new structure while preserving the old one if rollback remains possible.
Backfill separately
Large data updates should be a controlled operation separate from the request-serving migration. Batch and monitor the work so it does not hold locks for an unacceptable duration. Puma replacing workers does not reduce database lock time.
Switch and contract
After all workers use the new path and the rollback window has passed, switch reads and writes fully, then remove obsolete columns or compatibility code in a later deployment. Destructive changes need their own recovery plan because a code rollback cannot restore data that a migration permanently removed.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Assets, uploads, and release cleanup
Digest-based assets make it possible for old and new HTML to reference different filenames. Do not delete the previous release’s compiled assets immediately after cutover. Keep enough history for browser and intermediary caches, or store assets in a shared location with a cleanup policy that understands active references.
Recommended Free Tools
Uploads are not build artifacts. Keep them in the shared uploads directory and mount or link that directory into each release. The same principle applies to logs and any generated files that must survive a deployment.
Rollback without making the incident worse
Failure before cutover
If dependency installation, asset compilation, migration checks, boot checks, or the local health request fails, leave current pointing at the previous release. Inspect the failed release and run:
sudo journalctl -u myapp-puma -n 200 --no-pager
Fix the cause, or remove the failed release after preserving logs needed for diagnosis. Because traffic never moved, no Puma restart is required for this case.
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.
Failure after cutover
If the pointer changed but the public health check fails, point current back to the previous release using the same atomic symlink replacement, then request another phased restart. Watch the logs while old workers return and confirm that NGINX sees the expected socket.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsCheck database compatibility first
A rollback is safe only while the database remains usable by both releases. If the new version ran a destructive migration, reverting application code may produce errors or silent data loss. Treat destructive migrations as a separate recovery project rather than assuming that changing the symlink restores the old system.
Troubleshooting the common failure modes
NGINX returns 502 or cannot connect
- Check that Puma is active with
systemctl status myapp-puma. - Confirm the socket exists at the shared path and that its owner, group, and mode allow NGINX access.
- Verify that systemd’s working directory and Puma’s
bindpath both resolve through the intended shared tree. - Read the Puma journal for boot failures before changing NGINX.
Phased restart leaves mixed behavior
Mixed responses usually indicate that old and new workers are serving different code paths, which is expected during replacement. If requests fail, inspect migration compatibility, feature flags, cache formats, and initializers that assume a single version. Do not “fix” the symptom by forcing a normal restart if that would create a serving gap.
Workers repeatedly restart
Check memory pressure, database connection limits, missing environment variables, and exceptions during boot. A watchdog or Restart=always can keep trying indefinitely, but supervision does not make a broken release healthy. Stop the deployment, preserve the previous pointer, and use the journal to identify the first failure.
New pages have missing styles or scripts
Confirm that assets:precompile ran in production, that NGINX serves the new digest files, and that cleanup did not remove files referenced by cached HTML from the previous release. Check the generated asset URL rather than only the Rails response status.
A repeatable operational checklist
- Release directory is new and timestamped;
currentstill points to the known-good version. - Locked Ruby and JavaScript dependencies installed successfully.
- Shared secrets, database configuration, logs, sockets, cache, and uploads are linked.
- Production assets compiled successfully.
- Migrations are additive or otherwise compatible with old workers.
- New release boots and passes a local health request.
- Symlink replacement completed atomically.
- Puma phased restart completed without worker boot errors.
- Public health endpoint, logs, error rate, and asset URLs are normal.
- Previous release remains available until rollback is no longer needed.
Final deployment rule
Zero downtime is a sequence property, not a single Puma flag. Build everything away from the live path, supervise Puma with systemd, switch the release pointer only after checks pass, and use phased restart so workers are replaced one at a time. The database, assets, uploads, secrets, and rollback plan must all tolerate the brief period when two application versions coexist. A normal systemctl restart is not the default code-deploy operation when a request-serving gap is unacceptable; use phased restart or a deliberately configured socket-activation design instead.
Quick Recap
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.




