Skip to content

Lesson 8 of 9 · 24m

Production Deployment Patterns

Build immutable artifacts, separate deploy from release, and use rolling, blue-green, or canary strategies according to actual risk.

Deployment is where architecture meets physics. A rolling update changes schema compatibility requirements. A canary changes traffic shaping requirements. A blue-green deployment changes cost and data synchronization requirements. There is no universally correct pattern; there are trade-offs you must choose before the incident, not during it.

Build once, deploy the same artifact everywhere

The artifact that passes tests should be the artifact that runs in production. Rebuilding per environment recreates risk and makes provenance muddy:

./mvnw -ntp -DskipTests package
docker build -t registry.internal/billing:2026.03.01-4f3a91c .
docker push registry.internal/billing:2026.03.01-4f3a91c

The image tag should be traceable to source. Mutable tags like latest are fine as convenience aliases, but deployment records need immutable digests or versioned tags.

Rolling deployment is simple but constrains change shape

Kubernetes rolling updates gradually replace old pods with new ones:

strategy:
  type: RollingUpdate
  rollingUpdate:
    maxSurge: 1
    maxUnavailable: 0

That means old and new versions run together. Database changes must be expand-then-contract: add nullable columns first, deploy writers that tolerate both shapes, backfill, then enforce or drop old structures in a later release. A destructive migration cannot roll safely in one step.

Blue-green reduces exposure but doubles hard parts

Blue-green keeps two environments and switches traffic at once. It is attractive when startup is slow or cutover must be fast, but data does not fork neatly. If both environments share a database, schema compatibility still matters. If they do not share state, synchronization and cutover loss become your problem.

Use blue-green when the infrastructure cost and operational maturity justify it. Do not choose it because it sounds safer in a slide deck.

Canaries are hypothesis tests

A canary deploys a small fraction of traffic to the new version and compares outcomes:

1% traffic -> verify error rate, latency, business conversion
10% traffic -> verify dependency load and saturation
50% traffic -> validate scale and cache behavior
100% traffic -> release complete

Automated analysis is only as good as the metrics. If the deployment corrupts a rare nightly workflow, HTTP canary metrics will happily pass. Know which risks a canary cannot observe.

Separate deploy from release

Deployment means code is running. Release means users experience behavior. Feature flags, entitlements, or gradual exposure let you decouple the two. This is powerful for risky workflows, but flags are inventory. Every flag needs an owner, expiry, default behavior, and removal plan.

Field notes

  • Database migration rollback is usually a forward fix, not down migration nostalgia. Design reversible change sequences.
  • Keep old and new serialization formats compatible during asynchronous processing; queued messages can outlive the deploy.
  • A health check that depends on every optional dependency can prevent otherwise safe rollouts.
  • Record deployment provenance in telemetry: version, commit, pipeline, operator, and migration version.
  • Practice rollback and restoration before the urgent day. A rollback button nobody has tested is a rumor.

Was this lesson helpful?

Sign in to rate