← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Zero Downtime Deployment

devops PHP 5.0+ Intermediate

Also Known As

zero-downtime deployment no-downtime deploy hot deploy

TL;DR

Deploying new application code without dropping a single request — using rolling updates, blue/green swaps, or atomic symlink switches.

Explanation

Zero downtime deployment for PHP applications uses several techniques. Atomic symlink swap (Deployer, Envoyer, Capistrano): deploy to a new release/ directory, run migrations and composer install, then atomically switch a current/ symlink — PHP-FPM continues serving the old release until the symlink swaps. Blue/green: two identical environments; the load balancer is flipped between them after the new version passes health checks. Rolling: gradually replace old instances. Critical requirements: database migrations must be backward compatible with the old code (never rename or drop a column in the same deploy as the code that uses it — separate into two deploys); session storage must be external (Redis); file uploads must use shared storage (S3). Use a deployment tool like Deployer to orchestrate the release sequence.

Common Misconception

Zero downtime deployment only requires a load balancer in front of multiple servers. Database migrations that lock tables, incompatible API changes between old and new code, and session state tied to specific servers can all cause downtime even with a load balancer — zero downtime requires careful schema migration strategy too.

Why It Matters

Zero-downtime deployments keep the service fully available during updates — eliminating the deploy windows and maintenance pages that erode user trust and are unnecessary with modern techniques.

Common Mistakes

  • Restarting PHP-FPM abruptly — use reload (graceful) not restart to finish in-flight requests.
  • Running destructive database migrations before deploying backward-compatible code.
  • Not using atomic symlink swaps — file-by-file rsync creates a window where old and new files mix.
  • Health check that passes immediately after deploy before the app has fully initialised.

Code Examples

✗ Vulnerable
# Non-zero-downtime deploy:
systemctl stop php-fpm        # Drops all in-flight requests
rsync -avz ./app/ /var/www/   # Files updated one by one — mixed state
systemctl start php-fpm       # Cold start — first requests slow

# Zero-downtime with symlinks:
rsync -avz ./app/ /var/www/releases/v2/  # Prep in background
ln -sfn /var/www/releases/v2 /var/www/current  # Atomic swap
systemctl reload php-fpm      # Graceful — finishes in-flight
✓ Fixed
# Zero-downtime deploy sequence for PHP apps

# 1. Run DB migrations that are backwards-compatible
#    (add columns/tables — don't remove until next deploy)
$ php artisan migrate --force

# 2. Warm OPcache on new code
$ php artisan optimize

# 3. Rolling restart PHP-FPM workers (graceful — finishes current requests)
$ sudo kill -USR2 $(cat /var/run/php-fpm.pid)
# USR2 = graceful reload — new workers start, old ones finish then exit

# 4. Verify health endpoint returns 200
$ curl --fail https://yourapp.com/health

# Kubernetes approach:
# Set rollingUpdate: maxUnavailable=0, maxSurge=1
# New pods start, health check passes, old pods terminate

# Blue-green: both versions running — switch load balancer
# Canary: route 5% traffic to new version first

Added 15 Mar 2026
Edited 22 Mar 2026
Views 35
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 0 pings S 0 pings S 0 pings M 1 ping T 0 pings W 0 pings T 1 ping F 1 ping S
Perplexity 10 Amazonbot 10 Unknown AI 3 Google 2 Ahrefs 2 ChatGPT 1
crawler 26 crawler_json 1 pre-tracking 1
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: High
⚡ Quick Fix
The four requirements for zero-downtime PHP deploys: backwards-compatible DB migrations, graceful process shutdown (drain active requests), atomic symlink switch, and health checks before traffic routing
📦 Applies To
PHP 5.0+ web cli laravel symfony
🔗 Prerequisites
🔍 Detection Hints
Deployment dropping active connections; DB migration that requires app downtime; no health check before switching traffic; php-fpm restart killing active requests
Auto-detectable: ✗ No deployer envoyer kubernetes
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Medium ✗ Manual fix Fix: High Context: File Tests: Update

✓ schema.org compliant