Shelves / Production Deployment
DP·00
Start Here: Shipping Safely
For engineers who write features but haven't owned getting them to production: what happens between "merged" and "customers use it", one change shipped step by step (a pipeline that tests and builds it once, a database change that doesn't lock the site, a deploy that drops no requests, and a backup that actually restores), the vocabulary of the volume, and how to study it.
Start here: how to use this volume
Two reading paths
This volume is about getting software into production and keeping it there: the application lifecycle, a reference production architecture, production readiness, environments, database deployment safety, zero-downtime deployment and disaster recovery, with a launch-week game day that ties them together. Every chapter has the same shape: a plain-language Start here section with small, verified examples; a How deep to go ladder; the full-depth sections; a Lab of real measurements; and a Revision sheet.
- New to deployment and operations? Read this chapter, then the chapters in order.
- Experienced? Skip this chapter. In each chapter read the revision sheet first, take its quiz, then use How deep to go to choose the sections and lab experiments to study.
A note on the labs: they run real software on one lab machine: PostgreSQL with millions of rows, HAProxy and nginx in front of real app instances under load, k6 load tests, real backups and point-in-time restores, secret scanners and reproducible builds. What one machine can't show (network distance, cloud regions, many nodes) the labs say so and add the missing numbers as clearly labelled typical figures.
Mastery levels
Every chapter uses the same six levels:
| Level | Name | You can… | Example for deployment |
|---|---|---|---|
| L1 | Recognition | define it and spot it | "that's a rolling deploy" |
| L2 | Working | use it | configure probes and a rolling deploy |
| L3 | Internals | explain why it works | explain draining, readiness and version overlap |
| L4 | Debugging | find and fix problems | find why deploys cause a burst of 503s |
| L5 | Design | shape a whole system | design a release process with canaries and rollback |
| L6 | Production | run it at scale | run progressive delivery across hundreds of services |
What happens between "merged" and "customers use it"
Writing the code for "skip a day" is perhaps a third of the work of shipping it. The rest is everything that makes the change reach users safely: tested and built once, configured per environment, deployed without dropping requests, with its database change applied without locking the site, watched once it's live, and recoverable if something goes badly wrong. The lab for each chapter measured one piece; here is the journey in order.
Step 1: a pipeline that proves it and builds it once
1 lint (ruff) pass 0.01 s
2 type check (mypy) pass 1.85 s
3 unit + API tests (pytest) pass 1.11 s
4 build artefact (wheel) pass 1.60 s
5 deploy to 'staging' + start pass 1.10 s
6 smoke test against staging pass 0.01 s
artefact sha256 961132762a07654a promoted
The artefact that passed is the one that ships, identified by its hash (chapters 187, 190).
Step 2: a database change that doesn't lock the site
The feature needs a new column. On a 2-million-row table, adding it took 0.00 s, unless a slow report happened to be running: then the change waited, and every ordinary read queued behind it for 3 seconds. With lock_timeout = '200ms' the change gave up quickly instead and could be retried; reads never waited more than 0.2 s (chapter 191).
Step 3: a deploy that drops no requests
Two instances behind a load balancer, 20 clients sending requests throughout:
| How old instances were stopped | Failed requests (of ~4,600) |
|---|---|
| killed | 194 |
| asked to stop, finishing in-flight work | 166 |
| taken out of the load balancer first, then stopped | 0 |
During the deploy, old and new versions served traffic side by side, so the change had to work with both (chapter 192).
Step 4: knowing it's ready, and recoverable
A load test found where the service saturated (about 820 requests per second, against an expected peak of 300) before users could (chapter 189). And when someone ran DELETE FROM orders by mistake, restoring last night's dump would have lost the 25,000 orders since; point-in-time recovery brought back every order up to the second before the mistake (chapter 193).
How to study deployment and operations
A routine that works
- Break things on purpose in a safe environment: kill processes, lock tables, delete data, then recover.
- Measure before and after every safety measure; a control you haven't seen work is a hope.
- Read the runbook as if it's 3 a.m.: could someone else follow it?
- Automate the checks you'd otherwise forget.
- Practise recovery regularly; time it.
Warm-up exercises
- Time your team's path from merge to production. Which stage is slowest?
- Find the largest table in a database you work with, and list which migrations on it would take an exclusive lock.
- Restart one instance of a service you run under light load and count errors.
- Restore a backup of any database you own into a fresh instance and time it.
Glossary
- Pipeline: the automated sequence of checks and steps from commit to deploy.
- Artefact: the built, versioned output that gets deployed.
- Migration: a versioned change to a database schema or data.
- Rolling deploy: replacing instances a few at a time.
- Readiness: whether an instance (or a service) should receive traffic.
- RPO / RTO: how much data and how much time you can afford to lose in a disaster.