Blue-green deploy lab
Design retries, degradation, and recovery
When schema migration applied only on blue — green rollback serves 500s, the system must degrade on purpose without widening blast radius.
1Try it yourself
Decision drill
Blue-green deploy desk
Two full environments — swap traffic atomically, revert fast if metrics break.
1/3v2 passes smoke on the idle (blue) environment. Green still serves 100%.
2Learn the idea
Read
Classify and bound retries
Map failure classes for router → green|blue /v1/rag/answer: retryable vs fatal vs needs-human. Retries need budgets, jitter, and idempotency rules aligned to blue must pass smoke + /readyz before cut; old green kept warm for 30m rollback. The chapter’s signature failure — schema migration applied only on blue — green rollback serves 500s — must take a deliberate branch, not a generic catch-all.
Read
Containment path
Implement the degrade/rollback/refuse behavior release engineer flipping 100% router cut after green smoke needs when BG-SCHEMA-ONESIDE-11 repeats. Prefer scoped controls (one flag, one weight, one tenant, one secret version) over fleet-wide restarts. Preserve evidence; do not delete logs to “clean the demo.”
Read
Implementation artifact
./router_cut.sh --to green --reason schema_mismatch
Read
Verify harm reduction
After containment, check cutover_seconds and postcut_error_rate moves in the safe direction and watch for retry amplification. Write the stop condition that ends the incident response for this lab.
Read
Stage depth
Chaos note: inject only one fault class at a time and restore fixtures after. Watch for dual failures — dependency down and retry amplifier — which is how schema migration applied only on blue — green rollback serves 500s becomes an outage. Customer communication templates (even if only for the drill) beat silence. If you queue deferred work, define poison-message handling. Budget documents should state the maximum extra spend allowed during retries. Close the loop by linking the containment action to a dashboard panel for cutover_seconds and postcut_error_rate.
Read
Field notes for `blue-green-lab` / `failure-handling`
Draw a state diagram for degrade modes and put it in the repo as ASCII if needed. Cap concurrent retries across the process, not only per request. Ensure cancellation propagates to downstream HTTP clients. When failing closed, choose a user-visible message that does not leak internals. Practice the single command that flips the kill switch or weight to zero. After recovery, drain or inspect deferred work before declaring green. In this chapter the product is RAG API with complete green/v1 and blue/v2 stacks behind one router, the human stakeholder is release engineer flipping 100% router cut after green smoke, and the incident id you design against is BG-SCHEMA-ONESIDE-11. Re-state the oracle in your notes — cutover < 30s; rollback restores green with zero dual-write divergence — and keep the invariant visible: blue must pass smoke + /readyz before cut; old green kept warm for 30m rollback. Track cutover_seconds and postcut_error_rate as the scoreboard. Surface under change control: router → green|blue /v1/rag/answer. If you only have forty minutes, finish the fixture for schema migration applied only on blue — green rollback serves 500s before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.
Go deeper
Before you start
Why this matters
Assume schema migration applied only on blue — green rollback serves 500s is happening right now. Write the first safe action, the signal that confirms containment, and the action you will not take (infinite retry, broad restart, deleting evidence). Tie the plan to invariant: blue must pass smoke + /readyz before cut; old green kept warm for 30m rollback.
In the wild
See how this idea shows up as a product and a company — then come back to the lesson. Skills transfer across vendors.
Related lessons
Check your understanding
Page assessment
Answer from memory. Completion is saved from this evidence, not from opening the next page.
All responses are required.