Shelves / Production Deployment
DP·194
Deployment and Operations Projects
Six build-it-yourself projects that take a small service from a walking skeleton to a launch you'd trust: a pipeline that builds once and promotes by digest, a reference deployment with a measured latency budget, a readiness gate backed by evidence, safe migrations under load, zero-downtime deploys proven with a load test, and a disaster-recovery drill with measured RPO and RTO, each with milestones, measurable definitions of done and stretch goals.
How to approach the projects
From "it runs" to "it ships safely, every time"
Use one small service through all six projects: TiffinBox's skip API from chapter 187's lab, or a service of your own with a PostgreSQL database. Everything here runs on a laptop or a single small VM (Docker or k3s helps for projects 2 and 5); a cloud account makes project 6 more realistic but isn't required.
| # | Project | Main chapters | Roughly |
|---|---|---|---|
| 1 | Pipeline: build once, promote by digest | Start Here, 187, 190 | 1 week |
| 2 | A reference deployment and its latency budget | 188 | 1 week |
| 3 | A readiness gate backed by evidence | 189 | 1 week |
| 4 | Safe migrations under load | 191 | 1 week |
| 5 | Zero-downtime deploys, proven | 192 | 1 week |
| 6 | A disaster-recovery drill | 193, game day | 1 week |
New to operations? Do them in order on the same service; the result is a launch-ready system you can demonstrate. Experienced? Do 4, 5 and 6, and run your own game day at the end.
The working method
- Break it on purpose in a safe environment before claiming it's safe.
- Measure before and after every control.
- Automate the checks; a control that depends on someone remembering will be forgotten.
- Write the runbook while you build, and have someone else follow it.
- Record evidence: logs, load-test results, restore timings, in the repository.
The six projects
Project 1: pipeline, build once, promote by digest
Goal. A pipeline that turns a commit into a signed, tested artefact and promotes exactly that artefact through environments.
Milestones. Walking skeleton → lint, type check, unit and API tests, contract check → reproducible build (container image or package) → SBOM, scan and signature → deploy to staging by digest → smoke test → manual or automatic promotion to "production" by the same digest → layered, validated configuration and secrets from a manager → secret scanning on history.
Done when. Two builds of the same commit produce the same digest; production and staging run the same digest (shown by a script); a planted type error, a planted boundary bug with its test, and a planted secret each stop the pipeline at the expected stage.
Stretch. Preview environments per pull request with automatic teardown.
Project 2: a reference deployment and its latency budget
Goal. The service deployed behind a reverse proxy or load balancer with TLS, a cache, a database and a queue, with a latency budget per hop.
Milestones. Architecture diagram with failure domains → reverse proxy with TLS and keep-alive → connection pooling → cache with timeouts and fallback → a queue for async work with an idempotent worker → tracing across hops → a measured latency budget (p50 and p99 per hop) → a written degraded mode for each dependency.
Done when. A trace shows every hop for one request; the budget table matches traces within 20%; stopping the cache or the queue degrades the service as written, without errors on the main path.
Stretch. Add simulated network delay between tiers and re-plan the budget.
Project 3: a readiness gate backed by evidence
Goal. A readiness manifest in the repository whose checks are verified automatically.
Milestones. Manifest across the six areas → evidence checks (headers, health and readiness endpoints, SLO file, alert rules, runbook links, recent restore log, load-test result) → an open-model load test to 2× peak and to saturation → SLOs with multi-window burn-rate alerts → a CI job that blocks a release on any failed blocker.
Done when. The capacity curve and saturation point are recorded; every blocker is checked by code, not a tick box; removing a security header or an alert rule makes the gate fail.
Stretch. A weekly scheduled run of the gate against production that opens an issue on regression.
Project 4: safe migrations under load
Goal. Schema changes that never stall the service.
Milestones. A table with at least a million rows and steady traffic → reproduce the lock-queue trap → migration tool with lock_timeout, statement_timeout and retries → linter in CI (timeouts, concurrent indexes, volatile defaults, NOT NULL via NOT VALID) → a column rename via expand/contract across three deploys → a batched, resumable, throttled backfill → post-migration data validation.
Done when. Under steady traffic, p99 latency stays below an agreed bound (e.g. 200 ms) throughout every migration and backfill; the linter blocks each unsafe pattern; the rename completes with zero errors.
Stretch. Monitor and cap replica lag during the backfill.
Project 5: zero-downtime deploys, proven
Goal. Deploys and rollbacks with zero failed requests under load.
Milestones. At least two instances behind a load balancer → startup, readiness and liveness probes → graceful shutdown with drain → a load test running during every deploy → backward-compatible API and event changes → a canary with automated analysis and automatic rollback → feature flags with a kill switch.
Done when. Ten consecutive deploys and two rollbacks under load produce zero failed requests; a deliberately bad canary is rolled back automatically within the analysis window; the kill switch disables a feature in under 10 seconds without a deploy.
Stretch. Blue/green for the same service, compared on cost and rollback time.
Project 6: a disaster-recovery drill
Goal. Measured RPO and RTO for the service's data, and a rehearsed response.
Milestones. Backups with continuous WAL archiving (pgBackRest, WAL-G or Barman) stored separately with restricted credentials → an accidental-deletion drill with point-in-time recovery into a new instance and selective copy-back → a full restore timed end to end → a failover drill (replica promotion, fencing, reconnect) → a runbook followed by someone who didn't write it → a game day with injected failures and a scored postmortem.
Done when. Measured RPO and RTO meet written targets; the deletion drill recovers every row up to the target time; the runbook is followed successfully by another person; each postmortem action item is either done or has an owner and date.
Stretch. Make the restore drill a scheduled job that reports its RTO weekly.
Tracking your progress
Portfolio checklist
Keep pipeline definitions, infrastructure code, manifests, load-test results, migration logs, runbooks, drill timings and postmortems in the repository. Operational evidence is concrete: "same digest in staging and prod, verified by script; p99 stayed under 40 ms during a 2-million-row backfill; 10 deploys and 2 rollbacks with 0 failed requests of 50,000; saturation at 820 req/s against a 300 req/s peak; PITR restored every row to 14:30:00 with a measured 6-minute RTO; game day mitigation times 10 → 2 minutes after fixes" is what makes the portfolio credible.
Mapping to mastery levels
Completing projects 1–3 with their checks puts you at L2 across the volume. Doing their stretch goals and explaining every mechanism is L3–L4. Designing and defending projects 4–6 (migrations, deploys and recovery that stay safe under load, with evidence and rehearsed responses) is L5 work, the level platform, SRE and senior backend roles probe.