Lesson 17 of 28How teams plan and ship
CI/CD and Release Practices
Keep main releasable, separate deploy from release with feature flags, roll out with canaries, recover fast, and read the DORA metrics honestly.
Your team's checkout service deploys every Thursday afternoon. Forty merged pull requests go out at once, something breaks, and three people spend the evening working out which of the forty did it. Rolling back undoes a week of everyone's work, so instead you hotfix under pressure, and next week the release is even bigger because people held changes back. The pipeline tooling was never the problem. The release practice was. This lesson covers the habits that let teams ship many small changes a day with less drama than one big weekly release: continuous integration as a discipline, deploy strategies, feature flags, rollbacks, and how to measure whether any of it is working.
The pipeline mechanics (jobs, caching, service containers, building and pushing an image) are covered in CI/CD for Python, so this lesson has almost no YAML. It is about what you do with the pipeline once you have it.
CI is a habit, not a tool
Having GitHub Actions does not mean you do continuous integration. CI is the practice of everyone merging small changes into the shared main branch at least daily, with an automated build and test on every change, and treating a broken main as the top priority. A team with a perfect pipeline and three-week feature branches is not integrating continuously; it is integrating rarely, with good tooling.
Three rules carry most of the value:
- Integrate at least daily. Work stays small, conflicts stay small, and you find out about your teammate's change today instead of in two weeks. Branching Strategies Teams Use explains how trunk-based development keeps branches short.
- Keep main green. Main should always build, pass tests, and be safe to deploy. If you cannot merge something incomplete safely, it goes behind a flag (more below).
- Fix the build first. When main breaks, the person whose change broke it either fixes it in minutes or reverts. Reverting is not an admission of failure; it is the fastest way back to green. Everyone else stops merging on top of a red build, because each new change makes the cause harder to find.
The pipeline must also be fast enough that people wait for it. When checks take half an hour, people batch changes to avoid waiting, which is exactly the habit CI is meant to remove.
Delivery and deployment
The "CD" in CI/CD means one of two things, and teams mix them up.
- Continuous delivery: every change that passes the pipeline could go to production. It is packaged, tested and sitting ready. A person decides when to push the button.
- Continuous deployment: every change that passes the pipeline does go to production, automatically, with no human step.
Continuous deployment needs more trust: good tests, monitoring, fast rollback and feature flags, so that shipping is boring. Mobile apps and installed software usually stop at delivery because a store review or a customer's upgrade sits between you and the user.
Whichever you do, build once and promote. The pipeline builds one artifact (a container image tagged with the commit SHA, say) and that exact artifact moves through staging and production. Only configuration changes between environments. If you rebuild for production, you are shipping something you never tested: a dependency may have resolved differently, or a base image may have moved.
Deployment strategies
How the new version replaces the old one decides how bad a mistake can get.
| Strategy | How it works | Good for | Watch out for |
|---|---|---|---|
| Rolling | Replace instances a few at a time | The default on Kubernetes and most platforms | Old and new versions run side by side during the roll |
| Blue-green | Run a full new copy, then switch all traffic at once | Instant switch and instant switch back | Double the capacity during the switch; shared database must suit both |
| Canary | Send a small share of traffic to the new version, watch, then widen | Catching problems with few users affected | Needs good metrics and enough traffic to judge |
| Shadow | Copy real traffic to the new version but discard its responses | Testing a rewrite under real load | Side effects (emails, payments) must be disabled in the shadow |
All four share one hidden requirement: old and new versions must work at the same time. During a rolling deploy, some requests hit version 41 and some hit 42. If 42 renamed a database column that 41 still reads, half your traffic fails. This is why schema changes use the expand and contract pattern described in Zero-Downtime Migrations: add the new thing, deploy code that handles both, migrate, and only then remove the old thing in a later release.
Before the deploy, all traffic goes to v41, the version you trust.
Feature flags: deploy is not release
The single most useful idea in release practice is that deploying (putting code on servers) and releasing (letting users see it) are different events. A feature flag is a runtime switch that decides which code path runs. With flags, you can merge and deploy half-finished work daily with the flag off, then release by flipping it, without a deploy.
Flags come in four broad kinds, and the kind decides how long the flag should live.
- Release flags hide unfinished or not-yet-launched work. They should live days to weeks, then be deleted.
- Ops flags, or kill switches, turn off an expensive or risky path under load ("disable recommendations if the service is slow"). They may live for years, on purpose.
- Experiment flags split users into variants for an A/B test. They live for the length of the experiment.
- Permission flags turn features on for specific customers or plans, such as a beta programme or an enterprise tier. They are long-lived and are really product configuration.
A percentage rollout turns a release flag on for a growing share of users. The trick is to make each user's answer stable: the same user must see the same thing on every request, and raising the percentage must only add users, never swap them. Hashing the flag name with the user id does both.
Press Run (⌘ Enter) to see what happens.The counts land close to 5% and 25% without being exact, which is normal for hashing. Including the flag name in the hash matters: without it, the same unlucky 5% of users would be the guinea pigs for every rollout.
In practice teams use a flag service (LaunchDarkly, Unleash, Flagsmith, GrowthBook and others) or an in-house one. OpenFeature, a CNCF project, defines a vendor-neutral flag API with SDKs for most languages, so the provider behind your code can change. Check its docs for your language.
Rollback or roll forward
When a deploy goes wrong, you have three exits, and the first job is always to stop the harm, not to understand it.
- Turn the flag off. If the change was behind a flag, this takes seconds and needs no deploy. It is the main reason to flag risky changes.
- Roll back to the previous artifact. Because you built once and kept the image tagged by SHA, this is redeploying something already proven. Make it one command or one button, and practice it.
- Roll forward with a fix. Sometimes right, when the fix is tiny and obvious, but under pressure "tiny and obvious" is often wrong, and a rushed fix goes through less review.
The default under pressure is: flag off or roll back first, fix forward calmly afterwards. The exception is data. A migration that dropped a column, or a bug that wrote bad rows, cannot be undone by redeploying old code. The old code may even crash on the new schema. That is why destructive schema steps go in a separate, later release (expand and contract again), and why data fixes need their own plan.
Measuring delivery: the DORA metrics
DORA (DevOps Research and Assessment, now part of Google Cloud) has surveyed tens of thousands of professionals since 2014 and found that a few delivery metrics predict both team and organisational outcomes. They are the standard vocabulary for "how well do we ship?". Its recent reports (2024 onward) describe five software delivery metrics:
- Deployment frequency: how often you deploy to production.
- Change lead time: time from a change being committed to it running in production.
- Failed deployment recovery time: how long it takes to recover when a deployment causes a failure. Older material calls this "time to restore service" or MTTR.
- Change fail rate: the share of deployments that cause a failure needing immediate intervention, such as a rollback or hotfix.
- Deployment rework rate: the share of deployments that are unplanned, made to fix a problem users hit in production. This is the newest of the five.
Recent reports discuss them in two groups, throughput (how fast changes flow) and instability (how often changes go wrong), and DORA's central finding has held for years: these are not a trade-off. The teams that deploy most often also tend to fail least and recover fastest, because small changes are easier to test, review, and undo.
Two other things changed recently that older blog posts get wrong. The well-known "elite, high, medium, low" performance tiers were dropped in the 2025 report, State of AI-assisted Software Development, in favour of a set of team profiles. That report also found that AI adoption tends to raise throughput but also instability, which is a good reason to watch both groups rather than one. Definitions and groupings shift between editions, so check dora.dev before quoting a definition or a benchmark number.
Here is a week of deploys turned into four of the metrics:
Press Run (⌘ Enter) to see what happens.Notice the median, not the mean, for lead time: one change that sat in review for a week should not hide that most changes ship within a day.
What does this print?
# ok = fine, failed = caused an incident,
# fix = an unplanned deploy to fix a bug users hit
log = ["ok", "ok", "failed", "fix", "ok",
"ok", "ok", "failed", "fix", "ok"]
cfr = log.count("failed") / len(log)
rework = log.count("fix") / len(log)
print(f"{cfr:.0%} {rework:.0%}")Use the metrics to improve your own team's system, never to rank individuals or compare unlike teams. Make deployment frequency a target and someone will split one change into ten deploys.
Release trains, freezes and change approval
Not every team can ship continuously, and you will meet some heavier practices.
- A release train leaves on a schedule (every two weeks, say) with whatever is ready. Mobile teams use them because store review makes every release costly. The rule that makes trains work: the train never waits for a late feature. The feature catches the next one, which is easy if it was behind a flag.
- A freeze window stops deploys during a risky period: a big sale, the end of the financial year, holidays when few people are on call. Freezes are reasonable for short, high-stakes periods. A long freeze just builds a bigger, riskier release for the day it ends.
- Change approval means someone signs off before a deploy. Peer review in the pull request is approval, and a good one. A separate change advisory board that meets weekly to approve deploys it did not write or review is a different thing. DORA's research (notably its 2019 report) found that heavyweight external approval was associated with slower delivery and was not associated with fewer failures. The approvers are too far from the change to judge it, so it adds delay without adding safety.
If you work somewhere with a change board, often in regulated industries, do not fight it. Show that your checks, reviews and audit trail are stronger evidence than a meeting; many organisations then pre-approve standard low-risk changes.
Match each situation to the practice that fits best.
How this shows up at work
In your first weeks, ship one change to production with someone watching, and learn where the rollback button is before you need it. Put risky changes behind a flag and write the removal ticket at the same time. The next lesson, Semantic Versioning and Changelogs, covers what happens when the thing you release is a library or an API that other people depend on.
- continuous integration
- Merging small changes to main at least daily, with an automated build and test on each, and fixing a broken main first.
- continuous delivery
- Every change that passes the pipeline is ready to release; a person decides when to deploy.
- continuous deployment
- Every change that passes the pipeline is deployed to production automatically.
- canary release
- Sending a small share of traffic to a new version and comparing its health to the stable version before widening.
- feature flag
- A runtime switch that chooses a code path, separating deploying code from releasing it to users.
- expand and contract
- Changing a schema in steps so old and new code both work: add, migrate, switch, then remove later.
- DORA metrics
- Five delivery measures: deployment frequency, change lead time, change fail rate, failed deployment recovery time and deployment rework rate.