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 pullin 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:
| Stack | Graceful reload | Notes |
|---|---|---|
| PHP-FPM | systemctl reload php8.3-fpm | Workers finish current requests; reload also clears OPcache when timestamps are not validated |
| Gunicorn | kill -HUP <master pid> (or ExecReload in systemd) | Starts new workers with new code, then stops old ones |
| Node.js with PM2 | pm2 reload app | Zero-downtime in cluster mode: restarts instances one at a time |
| Nginx | nginx -t && systemctl reload nginx | Old 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:
- Start the new release as the idle colour on port 8002 (a systemd template such as
app@8002.servicemakes this easy). - Wait until it is ready: poll a health endpoint until it returns 200.
- Point the upstream at 8002 and reload Nginx. New requests go to the new instance; requests in progress on the old one finish normally.
- 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:
- Expand: add new columns or tables (nullable or with defaults). Old code ignores them.
- Deploy code that writes to both old and new structures and reads from the new one.
- Backfill existing rows in small batches.
- 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/currentso 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.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — AMD | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Websites, small APIs, bots, staging and VPN servers | Order |
| VPS 2 — AMD | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,299/month | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| VPS 3 — AMD | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,499/month | Production databases, high-traffic sites, multi-container apps | Order |
| VPS 4 — AMD | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,899/month | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
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.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — Intel | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Business websites, small apps, scheduled jobs and bots | Order |
| VPS 2 — Intel | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,169/month | Business software, mid-size databases, several sites on one server | Check stock |
| VPS 3 — Intel | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,249/month | ERP/CRM stacks, heavier databases, multiple production apps | Check stock |
| VPS 4 — Intel | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,299/month | High-memory workloads and consolidated production servers | Check 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
- Releases built in separate directories; shared state (uploads,
.env) linked fromshared/. - Dependencies installed and assets built before the switch.
- Atomic symlink switch (
ln -sfnto a temporary name, thenmv -T). - Graceful reload, or blue-green with a health check gate.
- Migrations follow expand/contract and never break the previous release.
- Workers restarted after the switch; cron uses the
currentpath. - Previous release kept for instant rollback.
Frequently Asked Questions
Can I really get zero-downtime deploys on one server?
What is blue-green deployment?
Why use a symlink for the current release?
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?
How do I handle database migrations without downtime?
How much extra memory does blue-green need?
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?
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?
Which SkyRainCloud plan suits blue-green deployments?
Related Guides
- How to Configure Nginx as a Reverse Proxy for Multiple Applications
- How to Deploy Docker Containers on a VPS Server
- How to Deploy a FastAPI Application on a VPS with Uvicorn and Nginx
- How to Deploy a Laravel Application on a VPS with Nginx and PHP-FPM
- How to Migrate an Application to a New VPS with Minimal Downtime