deployment and operations

Zero-Downtime Reloads And Graceful Restarts

Deployments often need runtime reloads. A graceful restart lets existing work finish while new workers use updated configuration or code. The exact command depends on the platform and process manager, but the behaviour should be understood before a production release.

Distinguish Reload From Restart

  • Distinguish reload from abrupt restart.
  • Drain or complete active work where supported.
  • Coordinate web workers and queue workers during deploy.

Exercise The Deploy Path

  • Deploy to staging.
  • Trigger graceful lifecycle action.
  • Send traffic during reload and inspect errors.

Include Workers And Rollback

  • Abrupt restarts interrupt requests and jobs.
  • Old workers may keep old code longer than expected.
  • Rollback needs the same lifecycle plan.

Deploy Sequence

1. Publish new release directory.
2. Switch current symlink or release target.
3. Reload web workers gracefully.
4. Restart queue workers gracefully.
5. Run health and smoke checks.
6. Roll back target if verification fails.

A web reload is only part of the release. Long-running workers may keep old application code until they restart, and rollback needs the same lifecycle steps as deployment. Exercise both directions while sending representative traffic and processing a queued job.

Practice

Practice: Plan A Graceful Deploy

Write the deploy sequence for an application with PHP-FPM web traffic and long-running queue workers. Include the rollback sequence.

Requirements

  • Distinguish reload from abrupt restart.
  • Drain or complete active work where supported.
  • Coordinate web workers and queue workers during deploy.
  • Deploy to staging.
  • Trigger graceful lifecycle action.
  • Send traffic during reload and inspect errors.
Show solution

Publish the new release, switch the active release target, reload FPM gracefully, and restart queue workers through their supervisor so new jobs use the new code. Send staging traffic and process a queued job during the change, then inspect errors and health checks.

Keep the prior release available. Rollback should switch the target back and repeat the same controlled lifecycle steps. A web-only check is incomplete when workers remain on old code.