PHP › Deployment & Hosting for PHP Applications

How does zero downtime deployment work for a PHP application, and what techniques help avoid any interruption in service during a deployment?

Advanced

Answer

Zero downtime deployment typically involves deploying a new version of the application to a completely separate directory or set of servers while the current version continues serving live traffic, running any necessary preparation steps like cache warming against the new version, and then atomically switching traffic over, either through a symlink swap on a single server or through load balancer configuration across multiple servers, ensuring that at no point during the deployment does an actual user request fail or experience a noticeable interruption.
# Atomic symlink swap technique
ln -sfn /var/www/releases/20260907120000 /var/www/current
sudo systemctl reload php8.2-fpm
Real-world example An e commerce platform performs deployments during peak shopping hours without any customer noticing, since their deployment pipeline builds and prepares the new release in a completely separate directory before instantly switching the live symlink over once everything is confirmed ready.

Common follow-ups: What happens to in flight requests during the exact moment a symlink swap occurs?;How do you handle a database migration that is incompatible with the previous version of the application during a zero downtime deployment?