Unit 2 · Software engineering · Lesson 7 of 15
Deployment, observability, rollout and schema migration
Step 1: Learn the ideas
- Continuous integration and small, frequent merges
- Build once, promote artifacts; configuration separate from code
- Rolling, blue-green and canary deployments
- Feature flags: release, ops, experiment and permission toggles
- Rollback versus roll-forward and rollback safety
- Expand, migrate and contract schema changes; backfills
- Structured logging, metrics and distributed tracing
- Golden signals, SLO-based alerting and dashboards
- Compatibility between adjacent service versions
- Reviewing a bad release after the fact
Why it matters
Many production incidents start with a change: a deploy, a configuration push or a database migration. The practices in this topic make changes small, observable and reversible, so that a bad change reaches few users and is undone quickly. Interviewers raise them in system design ("how would you roll this out?"), in incident discussions ("how did you notice, and what did you do?") and in project deep dives, and the expected depth rises with level: a graduate should know the vocabulary and the reasons, while a senior engineer should be able to plan a multi-service migration that never takes the system down.
Core ideas
Pipelines. Continuous integration merges small changes often and runs automated builds and tests on each, so integration problems surface within minutes rather than at release time. A deployment pipeline builds an artifact once (a container image, a binary) and promotes that same artifact through environments, with configuration supplied per environment; rebuilding per stage invites "it worked in staging" surprises. Reproducible builds with pinned dependencies make every release traceable to exact inputs.
Progressive delivery. A rolling update replaces instances gradually; blue-green keeps two complete environments and switches traffic between them; a canary sends a small slice of traffic to the new version and compares its behavior with a control population before widening. A useful canary has predefined success metrics (error rate, latency percentiles, saturation, key business signals), enough traffic and time to detect problems, and an automatic stop. Feature flags separate deploying code from releasing behavior: code ships dark, is enabled for internal users, then a share of tenants, then everyone, and a kill switch turns it off without a deploy. Flags are also debt, since each one multiplies the states you might need to test, so remove release flags once a feature is fully on.
Rollback and compatibility. Rollback is only fast if the old version can run against the current state. Old and new versions coexist during every rolling deploy, and if you may roll back from version N+1 to N, then N must cope with anything N+1 wrote. The standard technique is two-phase: first ship code that can read the new format while still writing the old one, and only when it runs everywhere ship code that writes the new format.
Expand, migrate, contract. A schema change becomes a sequence of individually safe steps. Expand: add the new column or table, nullable or with a default, and deploy code that writes both old and new forms. Migrate: backfill existing rows in throttled batches, switch reads to the new form and verify parity. Contract: once nothing reads or writes the old form, stop writing it and drop it. Each step can be reversed on its own and none needs downtime. Watch for statements that lock or rewrite large tables, and use online alternatives where your database offers them, such as PostgreSQL's CREATE INDEX CONCURRENTLY.
Observability. Logs record discrete events with context; make them structured and include request, trace and tenant identifiers. Metrics are cheap numeric time series for dashboards and alerts; the SRE book's four golden signals are latency, traffic, errors and saturation. Traces follow one request across services as a tree of spans and show where time went and which dependency failed. Alert on user-visible symptoms tied to service level objectives rather than on every internal cause, and give every alert an owner and an action.
Common misconceptions
- "Rollback is always the safe option." If the new version already wrote data in a new format or ran a destructive migration, the old version may fail; establish rollback compatibility before deploying.
- "Feature flags make deployments risk-free." A flag flip is a production change that needs the same care, testing and audit trail as a deploy.
- "A canary without errors proves the release is safe." Small or unrepresentative traffic, short bake times and missing metrics hide slow leaks and tenant-specific bugs.
- "Logs are enough." Logs alone make aggregate questions slow and expensive and do not show cross-service timing; metrics and traces answer different questions.
- "Rename the column in one migration during a quiet hour." A rename breaks every running instance that still uses the old name; expand, migrate, then contract.
How to approach it
Read the SRE book chapter on release engineering and the SRE Workbook chapter on canarying, then Sadalage and Fowler's article on evolutionary database design, Pete Hodgson's article on feature toggles, and the OpenTelemetry observability primer. Practice by writing a rollout plan for a real change you made, such as adding a column to a production table: list each deploy, what is compatible at each point, the metrics you would watch and the rollback for every step. In interviews, present the plan in phases with explicit verification gates, and say how you would detect a problem before users report it. Mid-level candidates are expected to change one service safely; senior candidates should coordinate changes across services, data and teams.
Suggested order
- 1Read SRE book Ch. 8 (Release Engineering) for the principles behind repeatable builds, packaging, configuration and automated releases.
- 2Read the SRE Workbook Ch. 16 (Canarying Releases) and write the success metrics and stop conditions you would use for a canary of a service you know.
- 3Read Pete Hodgson’s “Feature Toggles (aka Feature Flags)” and classify the flags in a product you know as release, ops, experiment or permissioning toggles.
- 4Read “Evolutionary Database Design”, focusing on migrations and the transition phase, then write an expand/migrate/contract plan for renaming a column used by two services, with a rollback for each step.
- 5Read the OpenTelemetry observability primer and add structured logs with a request ID, three metrics and one trace span to a small service of your own.
- 6Read SRE book Ch. 6 (Monitoring Distributed Systems) for the four golden signals and symptom-based alerting.
Step 2: Check off what you can do
Tap each one you can genuinely do or explain. Each earns 10 XP.
Step 3: Go deeper
Site Reliability Engineering (Google SRE book)Start here
Google (free online edition)Section: Ch. 8: Release Engineering
Principles of repeatable, hermetic, automated releases and of managing configuration alongside code.
Open(opens in a new tab)Link responded, 5 Oct 2026Canarying Releases (The Site Reliability Workbook, Ch. 16)Start here
Google (free online edition)How to set up and evaluate canaries: metric selection, control populations, duration, dependencies and pitfalls.
Open(opens in a new tab)Link responded, 5 Oct 2026Evolutionary Database Design
martinfowler.comSchema changes as versioned, continuously integrated migrations, with a transition phase in which old and new structures coexist; the basis of expand-and-contract changes.
Open(opens in a new tab)Link responded, 5 Oct 2026Feature Toggles (aka Feature Flags)
martinfowler.comCategories of feature toggles, how long each should live, and how to manage toggle configuration and debt.
Open(opens in a new tab)Link responded, 5 Oct 2026OpenTelemetry: Observability primer
OpenTelemetry documentation (CNCF)Vocabulary for logs, spans, traces and metrics, and how trace context propagates between services.
Open(opens in a new tab)Link responded, 5 Oct 2026
Step 4: Practice
Write two plans and do one small build. Plan 1: a canary rollout for a change you shipped, with metrics, thresholds, bake time and rollback steps. Plan 2: an expand/migrate/contract change that renames or splits a column, listing each deploy, what old and new code can read and write at each point, and the backfill strategy. Build: instrument a small web service with structured logs, request IDs and an OpenTelemetry trace exported to a local collector, then break one dependency and locate the failure from telemetry alone.
No external problems are linked; follow the guidance above.
Record attempts on each problem’s page (+15 XP, +10 more when solved on your own).
Step 5: Test yourself
Answer each one out loud or on paper before you finish the lesson.
- Question 1Why should one artifact be promoted through all environments instead of being rebuilt per stage?
- Question 2What must be true for a rollback to be safe after a database change?
- Question 3Which metrics would you compare between canary and control for an API service?
- Question 4What are the risks of a long-lived feature flag?
- Question 5How does trace context propagate between services, and what breaks when one service drops it?
- Question 6Why alert on symptoms rather than causes?
You’re done when you can
- Explain in under three minutes how canary, blue-green and rolling deployments differ, and what makes a canary meaningful.
- Write an expand/migrate/contract plan for a column rename with a rollback for every step.
- Given a failed release that already wrote data in a new format, decide between rollback and roll-forward and justify it.
- Name the four golden signals and explain what logs, metrics and traces each contribute.
- Describe the lifecycle of a release flag from creation to removal.
Finish the lesson
Unlocks next: Platform engineering, infrastructure as code and safe migrations, Model serving, monitoring and drift


