System Design · 08. Shipping · 10 min · Intermediate

CI/CD & Deployments

Ship small changes often, and make a bad one cheap to undo.

In short

CI builds and tests every change; the pipeline makes one artifact; delivery puts it in staging and is ready for production at a click, or with no click at all.

Release it with a rolling, blue-green or canary method, hide risky features behind flags, and keep a quick rollback. Small, frequent, reversible: a bad change then reaches 5% of users for a few minutes.

Key ideas

  • CI answers "does my change work together with everyone else's?" within minutes. (step 2)
  • CD makes releasing boring. A boring release is a safe release. (step 4)
  • Canary limits the blast radius: a bug hurts 5% of users for minutes, not 100% of users for an hour. (step 7)

Good to know

  • Each stage is a gate. The fastest, cheapest checks go first, so a mistake fails in seconds, not minutes. (step 3)
  • Great when you want a fast, simple undo. Cost and the all-at-once switch are the trade-off. (step 6)
  • Rollback speed by method: flag flip, canary or blue-green switch in seconds; rolling back a rolling deploy takes another full roll, here 8 minutes. (step 9)

Watch out

  • Rare releases make each release riskier, which makes people release even less. Break that circle with small, frequent, automatic ones. (step 1)
  • Change the database in two steps: first add the new column (both versions work), later remove the old one. Never rename it in one go. (step 5)
  • Flags pile up. Remove each one after the feature is fully released, or the code fills with old branches. (step 8)
Git repositoryCI runnerBuild artifactsProduction

Key numbers

Users seeing the change
5% to 100%
Downtime
0 min
Time to undo
seconds

Terms

Continuous integration (CI)
Merging small changes often, with an automatic build and tests on every push.
Build pipeline
An ordered list of automatic stages that turns a commit into a tested artifact.
Artifact
The one built package (for example a container image) that is deployed to every environment.
Continuous delivery
Every green build is ready to go to production with one click.
Continuous deployment
Every green build goes to production automatically, with no click.
Rolling deploy
Updating servers one at a time so the service never goes down.
Blue-green deployment
Two full environments; deploy to the idle one and switch traffic in one step.
Canary release
Sending the new version to a small share of traffic first and watching it.
Feature flag
A setting that turns new code on or off without a deploy.
Rollback
Going back to the previous version after a bad release.