Deployment Strategies

Deployment strategy controls how old and new application versions overlap while traffic changes.

Why This Matters

The choice affects capacity, rollback, database compatibility, session behavior, worker versions, and observability.

Working Model

Recreate stops old before new. Rolling replaces instances gradually. Blue-green prepares a parallel environment and switches traffic. Canary exposes a small traffic segment before wider rollout.

Practical Rules

  • Package one immutable release.
  • Keep schema changes compatible across overlapping versions.
  • Separate deploy from release with flags when needed.
  • Define health and rollback signals.
  • Include workers and scheduled jobs.

Failure Modes

  • Calling blue-green instant rollback when migrations are destructive.
  • Running two worker versions against incompatible messages.
  • Using random canaries that miss tenant-specific risks.
  • Switching traffic before warmup and readiness.

Verification

  • Exercise rollback in staging.
  • Observe errors and latency by version.
  • Test mixed-version database access.
  • Confirm old assets remain available.

What You Should Be Able To Do

After this lesson, you should be able to explain recreate, rolling, blue-green, and canary deployment tradeoffs, choose a suitable approach for a real PHP project, and verify the result instead of relying on assumptions.

Practice

Practice: Choose A Deployment Strategy

Choose a strategy for a small VPS and a multi-instance checkout service.

Your answer must:

  • state the intended outcome;
  • show the commands, data flow, or implementation shape;
  • identify at least one unsafe alternative;
  • explain how the result will be verified.
Show solution

A small VPS may use atomic release directories plus graceful reload. A checkout service can use rolling or canary delivery with version metrics and compatible schema changes.

The important part is not memorising one command or vendor screen. The solution makes the invariant, failure behavior, and verification evidence explicit.

Practice: Plan Blue-Green Delivery

Plan a blue-green release with database changes.

Your answer must:

  • state the intended outcome;
  • show the commands, data flow, or implementation shape;
  • identify at least one unsafe alternative;
  • explain how the result will be verified.
Show solution

Deploy the compatible schema first, build and smoke-test green, mirror or test dependencies safely, switch traffic, monitor, retain blue for bounded rollback, then remove compatibility later.

The important part is not memorising one command or vendor screen. The solution makes the invariant, failure behavior, and verification evidence explicit.

Practice: Design Canary Signals

Choose promotion and rollback evidence.

Your answer must:

  • state the intended outcome;
  • show the commands, data flow, or implementation shape;
  • identify at least one unsafe alternative;
  • explain how the result will be verified.
Show solution

Compare error rate, p95/p99 latency, saturation, business conversion, queue failures, and version-specific logs against a baseline with explicit thresholds and duration.

The important part is not memorising one command or vendor screen. The solution makes the invariant, failure behavior, and verification evidence explicit.