Deploying PHP applications
with zero downtime
ConFoo, Montreal - February 23rd, 2023
© David Buchmann
David Buchmann - david@liip.ch
PHP Engineer, Liip AG, Switzerland
If you really have to, use FTP with TLS: SFTP
Upload your application
git pull / scp / rsync
Replacing files in place on the running system
Replace files in place
- OK to deploy to shared hosting or for small generated pages of static files
- Wordpress or Drupal applications are capable of operating without shell access
- Inconsistent while files are being uploaded
- Not really interruption free, certainly not robust
- Lets look at more powerful options
Goals for a deployment
- Minimize downtime
- Rollback on failure
- Repeatable deployments across environments
- Deploy early, deploy often
Automate everything!
- No manual mistakes
- Nothing gets forgotten
- Each step runs as soon as the previous is finished
- Running code is accurate documentation
- Version control everything, including deployment scripts
- Low effort to do a deployment
Deploy from CI
Have your CI run the deployments
- Guaranteed that no manual steps creep in
- Every team member can trigger a deployment
- Avoids differences between personal setup
- Clean state, no accidental changes deployed.
Discourages manual hacks.
- Continous deployment
Feature flags where necessary
Atomic deployment
- Uploading the files takes a time > 0
- Uploading can be interrupted in the middle
- You need your application's code to be consistent