What zero downtime requires
A deployment is not zero-downtime merely because files are copied quickly. Requests may be in progress, sessions may be active and old and new application versions may run simultaneously. The release process must account for all of them.
Use release directories
Build each release in a new directory, install dependencies and run checks before switching traffic. Keep a stable shared location for carefully selected writable data such as uploads and logs. Switch the active release using an atomic symlink operation where the hosting platform supports it.
Keep schema changes compatible
Use expand-and-contract migrations. Deploy schema additions before code that requires them, and postpone destructive changes until all old application instances are gone. Remember that database DDL behavior differs by server version and operation.
Handle sessions and uploads
Store sessions and user uploads outside the versioned release directory so switching releases does not make them disappear. Ensure all application instances use compatible session storage and serialization formats during the transition.
Verify and roll back
Run health checks after switching traffic. Monitor error rates, latency and critical workflows. Keep the previous release available for a quick code rollback, but remember that a code rollback cannot automatically reverse an incompatible database migration.
Checklist
- Build releases in separate directories.
- Run Composer install and tests before activation.
- Keep uploads and sessions in shared persistent storage.
- Use backward-compatible database migrations.
- Switch releases atomically where supported.
- Verify health and key user journeys.
- Keep a rollback plan that accounts for database state.