DevOps13 min read•Updated November 2026

How to Achieve Zero-Downtime Deployments on a Single VPS

Quick answer

On a single VPS, zero-downtime deploys come from three techniques combined: (1) build each release into its own directory and switch a current symlink atomically; (2) reload rather than restart, using graceful reloads (PHP-FPM reload, Gunicorn HUP, PM2 reload) or two app instances behind an Nginx upstream that you swap after a health check; (3) make database migrations backward compatible so old and new code can run at the same time. Keep the previous release so rollback is one symlink change.

Restarting an application usually means a few seconds where requests fail with 502 errors: the old process has stopped and the new one is not yet accepting connections. For many sites that is acceptable. For stores, APIs and anything with paying users, those seconds add up to failed checkouts and broken integrations. You do not need Kubernetes or several servers to avoid them. One VPS, Nginx and a disciplined release process are enough.

Where Deploy Downtime Comes From

  • Files changing under a running app: half-updated code from a git pull in place can serve errors for a moment.
  • Process restarts: the gap between the old process exiting and the new one listening.
  • Slow startup: JVM and large Node.js apps can take many seconds to become ready.
  • Schema changes: new code expects a column the database does not have yet, or old code breaks when a column disappears.

Each technique below removes one of these causes.

Technique 1: Atomic Release Directories

Never update the live directory in place. Prepare each release separately, then switch with one atomic operation:

/srv/app/
├── releases/
│   ├── 20261114-1010/
│   └── 20261114-1530/
├── shared/            # uploads, .env, logs - kept between releases
└── current -> releases/20261114-1530
REL=/srv/app/releases/$(date +%Y%m%d-%H%M)
git clone --depth 1 --branch v1.8.0 git@github.com:org/app.git "$REL"
ln -s /srv/app/shared/.env "$REL/.env"
ln -s /srv/app/shared/uploads "$REL/uploads"
# install dependencies and build inside $REL (composer install, npm ci && npm run build, pip install ...)

ln -sfn "$REL" /srv/app/current.tmp && mv -T /srv/app/current.tmp /srv/app/current

Creating the new link under a temporary name and renaming it over the old one with mv -T is atomic: every request sees either the old release or the new one, never a mix. Point your web server and process manager at /srv/app/current. Keep the last three to five releases and delete older ones.

Technique 2: Graceful Reloads

Many servers can swap their worker processes without closing the listening socket:

StackGraceful reloadNotes
PHP-FPMsystemctl reload php8.3-fpmWorkers finish current requests; reload also clears OPcache when timestamps are not validated
Gunicornkill -HUP <master pid> (or ExecReload in systemd)Starts new workers with new code, then stops old ones
Node.js with PM2pm2 reload appZero-downtime in cluster mode: restarts instances one at a time
Nginxnginx -t && systemctl reload nginxOld workers finish their connections before exiting

One caveat: if the process resolved /srv/app/current at start-up, it may keep running the old release after the symlink changes. Gunicorn and PHP-FPM handle this when configured with the symlink path (PHP needs $realpath_root in Nginx's SCRIPT_FILENAME, as in Laravel's recommended config); for others, use Technique 3.

Technique 3: Blue-Green Instances Behind Nginx

When an app cannot reload gracefully (for example a Spring Boot JAR or a standalone Next.js server), run two instances on different ports and switch traffic between them:

# /etc/nginx/conf.d/app-upstream.conf  (rewritten by the deploy script)
upstream app {
    server 127.0.0.1:8001;   # blue (live)
}

Deploy flow:

  1. Start the new release as the idle colour on port 8002 (a systemd template such as app@8002.service makes this easy).
  2. Wait until it is ready: poll a health endpoint until it returns 200.
  3. Point the upstream at 8002 and reload Nginx. New requests go to the new instance; requests in progress on the old one finish normally.
  4. After a grace period, stop the old instance.
#!/usr/bin/env bash
set -euo pipefail
LIVE=$(grep -oE '127\.0\.0\.1:80(01|02)' /etc/nginx/conf.d/app-upstream.conf | cut -d: -f2)
NEXT=$([ "$LIVE" = 8001 ] && echo 8002 || echo 8001)

systemctl restart "app@$NEXT"
for i in $(seq 1 60); do
  curl -fsS "http://127.0.0.1:$NEXT/health" >/dev/null && break
  sleep 1
  [ "$i" = 60 ] && { echo "new release unhealthy, aborting"; systemctl stop "app@$NEXT"; exit 1; }
done

printf 'upstream app {\n    server 127.0.0.1:%s;\n}\n' "$NEXT" > /etc/nginx/conf.d/app-upstream.conf
nginx -t && systemctl reload nginx
sleep 15
systemctl stop "app@$LIVE"

The health check is the important part: a broken release never receives traffic, and the deploy aborts with the old version still live. The trade-off is memory, because both instances run at once during the switch.

For Docker deployments, the same pattern works with two containers publishing 127.0.0.1:8001 and 127.0.0.1:8002; see our Docker guide.

Technique 4: Backward-Compatible Database Migrations

During a zero-downtime deploy, old and new code briefly run against the same database. Every migration must therefore work with both versions. Use the expand and contract pattern:

  1. Expand: add new columns or tables (nullable or with defaults). Old code ignores them.
  2. Deploy code that writes to both old and new structures and reads from the new one.
  3. Backfill existing rows in small batches.
  4. Contract: in a later release, once no running code uses the old column, drop it.

Avoid renaming or dropping columns in the same release that stops using them. On large tables, check whether an operation locks the table: adding an index in PostgreSQL should use CREATE INDEX CONCURRENTLY, and many MySQL schema changes can run with ALGORITHM=INPLACE or an online schema-change tool.

Rollback

With release directories, rollback is the same atomic switch pointed at the previous release, followed by a graceful reload or a blue-green swap back. Because migrations are backward compatible, the previous code still works with the current schema. Keep at least one previous release on disk at all times.

Queues, Cron and WebSockets

  • Queue workers keep old code in memory: signal them to finish their current job and restart after the switch (for example php artisan queue:restart, or restarting Celery workers with a warm shutdown).
  • Cron jobs should call scripts through /srv/app/current so they pick up the new release automatically.
  • WebSockets and long requests stay connected to the old instance until they close. Give the old instance a long enough grace period, and make clients reconnect gracefully.

SkyRainCloud Plans for This Workload

Blue-green on one server briefly runs two copies of your app, so leave memory headroom for both. If one instance needs 2 GB, plan for at least double during a deploy; the 16 GB tiers give comfortable room for an app, its database and a second instance.

AMD EPYC 7C13 VPS

Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
VPS 1 — AMD28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹649/monthWebsites, small APIs, bots, staging and VPN serversOrder
VPS 2 — AMD416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹1,299/monthWooCommerce, Node.js/Python backends, Docker Compose stacks, CI runnersOrder
VPS 3 — AMD832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹2,499/monthProduction databases, high-traffic sites, multi-container appsOrder
VPS 4 — AMD1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹4,899/monthLarge production workloads, SaaS platforms, analytics, in-memory cachesOrder

Intel Xeon Platinum 8269CY VPS

KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
VPS 1 — Intel28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹649/monthBusiness websites, small apps, scheduled jobs and botsOrder
VPS 2 — Intel416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹1,169/monthBusiness software, mid-size databases, several sites on one serverCheck stock
VPS 3 — Intel832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹2,249/monthERP/CRM stacks, heavier databases, multiple production appsCheck stock
VPS 4 — Intel1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹4,299/monthHigh-memory workloads and consolidated production serversCheck stock

Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.

Zero-Downtime Checklist

  1. Releases built in separate directories; shared state (uploads, .env) linked from shared/.
  2. Dependencies installed and assets built before the switch.
  3. Atomic symlink switch (ln -sfn to a temporary name, then mv -T).
  4. Graceful reload, or blue-green with a health check gate.
  5. Migrations follow expand/contract and never break the previous release.
  6. Workers restarted after the switch; cron uses the current path.
  7. Previous release kept for instant rollback.

Frequently Asked Questions

Can I really get zero-downtime deploys on one server?
Yes, for most web applications. Atomic release switching plus graceful reloads, or two instances behind an Nginx upstream, avoid dropped requests without needing extra servers.
What is blue-green deployment?
Running two copies of your application (blue and green), deploying the new version to the idle one, checking its health, then switching traffic to it. The old copy remains available for instant rollback.
Why use a symlink for the current release?
Switching a symlink with mv -T is atomic, so the server never serves a mix of old and new files, and rollback is just pointing the link back.
Does systemctl reload nginx drop connections?
No. Nginx starts new worker processes with the new configuration and lets the old workers finish their open connections before they exit.
How do I handle database migrations without downtime?
Use expand and contract: add new columns first, deploy code that works with both shapes, backfill, and drop old columns only in a later release.
How much extra memory does blue-green need?
Enough for a second instance of your app during the switch, typically double the app's memory for a short time. The database and other services are not duplicated.
What about PM2 reload?
pm2 reload restarts cluster-mode instances one at a time so at least one keeps serving. In fork mode, it behaves like a restart.
How do I roll back a failed deploy?
Point the current symlink at the previous release and reload, or switch the Nginx upstream back to the previous instance. Keep at least one previous release on disk.
Do I need Kubernetes for zero-downtime deployments?
No. Kubernetes automates rolling updates across many machines, but on a single VPS the techniques in this guide achieve the same result with far less complexity.
Which SkyRainCloud plan suits blue-green deployments?
Choose a plan with room for two app instances plus your database. Many teams use the 4 vCore / 16 GB AMD EPYC or Intel plan for this; small apps can fit 8 GB.
Instant UPI • ₹649/mo
Fast KVM Cloud Provisioning