Stage 4 · Reliability · Medium · 15 min

CI/CD and safe deployments

How a change gets from a commit to production. A pipeline builds and tests it, there are four ways to ship it, and a rollback undoes it.

What each interview level is expected to know

Learn first: Load balancing and health checks, Observability, SLOs and error budgets

After this lesson you can:

  • Follow a change from commit to production through one pipeline.
  • Compare rolling, blue-green and canary releases, and feature flags.
  • Work out how many users a bad canary affects, and plan a rollback that works.

Start here

See it in 60 seconds

From a commit to production

A pipeline carries every change through the same steps, from a saved commit to production, and a failed check stops it before users are touched.

Scene 1 of 7 · A commit starts it

A developer saves a change, called a commit, and the pipeline starts with no one pressing a button.

Commit, saved changeCommitsaved changeBuild, makes packageBuildmakes packageTests, checks itTestschecks itPackage, stored oncePackagestored onceStaging, practice copyStagingpractice copyProduction, real usersProductionreal users
  • Commit — saved change — healthy
  • Build — makes package — healthy
  • Tests — checks it — healthy
  • Package — stored once — healthy
  • Staging — practice copy — healthy
  • Production — real users — healthy
Commits
1
Stopped by a test
0
Reached production
0
  1. A commit starts it. A developer saves a change, called a commit, and the pipeline starts with no one pressing a button.
  2. Build one package. The build step turns the code into one package, the exact file that servers will run.
  3. Tests check the package. 240 automatic tests now run against that package, and nothing moves on until they finish.
  4. A failing test stops it. One test fails, so the pipeline stops here and production never sees this change.
  5. A fix is committed. The developer commits a fix, the pipeline builds a new package, and this time every test passes.
  6. Same package, staging first. The package that passed is stored once, and that same file is tried in staging, a practice copy of production.
  7. Production, a little first. Production gets that package a few servers at a time, so a missed bug reaches few users.
  8. Now you try. A unit test checks one service alone. An integration test runs services together. A bug sits between two services: checkout sends a price that payments cannot read. Which checks does your pipeline run? For example: Each service passes its own unit tests, so the bug ships. All 1,000 users in this example can hit it. A unit test checks one piece alone, so it cannot see a bug in how two pieces talk.

Scene 1 of 7: A commit starts it. A developer saves a change, called a commit, and the pipeline starts with no one pressing a button.

Key points

  1. A commit starts the pipeline by itself: build, test, package, staging, production.
  2. Build once: the package that passed the tests is the one that ships.
  3. A failed check stops the pipeline, and production keeps running the old version.
  4. Unit tests miss bugs between services, so add tests that run services together, and a canary.

Go deeper in the Deployments lab →

In plain words

Say a developer fixes the checkout button and saves the change. That saved change is called a . A is a fixed list of automatic steps that every commit goes through. It builds the code into one package, tests it, and it on a practice copy of the live system. Then it releases it to , the servers that real users reach. Running these steps for every commit is called : continuous integration and continuous delivery. A release can reach all six servers at once, or one server at a time. It can also go to a second set of servers, or to one server with 10% of the traffic first. If the new version fails, a puts the old version back.

Follow the checkout fix through the pipeline. The build step turns the code into one package, and every later step uses that same package. If any test fails, the pipeline stops there, and users keep the old checkout. If the tests pass, the release starts small, and the team watches error rates on the new servers. Only when those stay normal does the rest of the traffic move over.

The problem it solves

Without a pipeline, a release is a person copying files to servers by hand, often late at night. Steps get skipped, one server ends up with a different build, and nobody is sure how to go back. And if every server gets a faulty version together, every user hits the bug at once.

Why it matters

Many outages start with a change: new code, a new setting, a new table. An interviewer who asks "how would you roll this out?" wants two things. How do you limit the damage of a bad release, and how do you undo it?

A worked example

Say 1,000 people use an app each minute, and a new version fails half of its requests. Shipped to every server at once, about 500 people a minute see an error. Shipped as a to 10% of the traffic, 100 people reach the new version and about 50 see an error. That is 10 times fewer, and an automatic check then pulls the version back.

Think of it like…

Think of a restaurant with a new recipe. The cook serves it to one table before it goes on every menu. If that table sends it back, only one table had a bad dinner.

Where this analogy stops working

Trying a change on a few before all is the useful part. A kitchen cannot take back a meal, while software can put the old version back. But a rollback restores only the code. Data that the faulty version wrote stays wrong until someone repairs it.

Try it

See it working

Live simulationOpen the full lab →

Lab · Reliability

Deployments

Six servers behind a load balancer run version 1 of an app. Ship version 2 in one of four ways, and make it faulty if you like. Watch how much traffic reaches it, how many requests fail and how fast you can go back.

Try it

Lab time 3.0 s
Blue set: servers 1 to 6Green set: no servers runningUsers, 30 requests/sUsers30 requests/s4 in progressLoad balancer, 0% to version 2Load balancer0% to version 26 of 6 servers servingServer 1, version 1, V1Server 1version 117% · 3/3 busyV1Server 2, version 1, V1Server 2version 117% · 0/3 busyV1Server 3, version 1, V1Server 3version 117% · 0/3 busyV1Server 4, version 1, V1Server 4version 117% · 0/3 busyV1Server 5, version 1, V1Server 5version 117% · 0/3 busyV1Server 6, version 1, V1Server 6version 117% · 1/3 busyV1

The lab is busy, so only some requests are drawn as dots, few enough to follow. The numbers still count every request.

  • Users — 30 requests/s — healthy — 4 in progress
  • Load balancer — 0% to version 2 — healthy — 6 of 6 servers serving
  • Server 1 — version 1 — healthy — V1 — 17% · 3/3 busy
  • Server 2 — version 1 — healthy — V1 — 17% · 0/3 busy
  • Server 3 — version 1 — healthy — V1 — 17% · 0/3 busy
  • Server 4 — version 1 — healthy — V1 — 17% · 0/3 busy
  • Server 5 — version 1 — healthy — V1 — 17% · 0/3 busy
  • Server 6 — version 1 — healthy — V1 — 17% · 1/3 busy
  • Request
  • Response
  • Error / rejected
Traffic on version 2
0%
nothing shipped yet
Failed requests
0
since the start
Error rate now
0%
over the last 2 s
Servers serving
6/ 6
most running in this release: 6
Refused for lack of room
–
compares before and during a rollout
Time to roll out
–
Time to roll back
–

Numbers add up:94 arrived = 90 served by version 1 + 0 served by version 2 + 0 failed by the bug + 0 refused for lack of room + 4 in progressThe lab checks this sum as it runs, so a counting mistake would show here.

Controls

How to ship

One server at a time leaves, restarts on version 2 and returns.

Release

Now: Every server runs version 1.

Half of the requests that version 2 serves fail.

Pulls version 2 when over 5% of its last 20 requests failed.

Traffic
30/s

Each server handles 3 requests at once, so 6 servers have 18 slots.

Where requests went

  • Served by version 190
  • Served by version 20
  • Failed by the bug0
  • Refused for lack of room0
Error rate and traffic on version 2 (%)
Failed requestsTraffic on version 2
02550751001s2s3s
Show data table
TimeFailed requestsTraffic on version 2
1s00
1s00
2s00
2s00
3s00
3s00

What just happened

Nothing yet. Start traffic or run an experiment.

What this model simplifies
  • Every request is the same size and takes 40 to 120 ms. Real requests vary far more.
  • A request that finds every slot full fails at once. There is no queue and no retry, as a real load balancer or client would add.
  • A server always takes 2 s to start. Real servers take seconds to minutes, and some fail to start.
  • A rolling update never adds a spare server first. Real ones often start one extra server before they take one out.
  • Blue-green keeps the old servers for only 10 s. Real teams keep them for minutes or hours.
  • The release changes no database table. A real release often has to change the data first.
  • The bug fails half of the requests on version 2. Real bugs can be rare, slow, or hit only some users.
  • Health checks are instant: version 2 is judged on its last 20 requests. Real monitors need seconds or minutes to notice a problem.
  • The load balancer never fails, and it moves traffic in no time at all.

Also try: Load balancer · SLOs, error budgets & alerting

Mechanics

How it works

The pictures follow this page's example: a fix to the checkout button, made into build 412 and sent to six servers. The first shows the pipeline, the second three ways to ship, and the third a faulty release.

  1. Every commit runs the pipeline

    Pick a case to follow below

    With this case: The tests passed, and staging and then production ran the same build 412.

    Commit, fixes checkoutCommitfixes checkoutBuild and test, makes one package, NOWBuild and testmakes one packagebuild 412NOWStaging, practice copyStagingpractice copyProduction, runs build 411Productionruns build 411
    • Commit — fixes checkout — healthy
    • Build and test — makes one package — healthy — NOW — build 412
    • Staging — practice copy — healthy
    • Production — runs build 411 — healthy
    • Package or traffic
    Step 1 of 3

    Step 1 of 3 · Build and test

    Done: A commit starts the pipeline

    What happens
    A developer saves a fix to the checkout button. Nobody presses a button to start the next steps.
    Why
    Every commit runs the same steps, so none gets skipped.
    What changes
    The pipeline builds it into one package: build 412.
    Next
    The tests pass, and staging runs build 412
    Tests
    –
    not run yet
    Staging runs
    build 411
    Production runs
    build 411

    Step 1 of 3: Build and test. A commit starts the pipeline. A developer saves a fix to the checkout button. Nobody presses a button to start the next steps.

    A commit starts the steps with no one pressing a button: build, test, package. A failing test stops the pipeline, and production keeps the old version. This first half is continuous integration (CI).

    In the picture, the commit becomes build 412. If a test fails, the pipeline stops there and production keeps build 411. If the tests pass, runs build 412, and then production runs that same package.

  2. Build once, ship the same package

    Say build 412 passed the tests. Staging, the practice copy, runs build 412, and then production runs build 412, never a fresh rebuild. A rebuild could pull in newer outside code and behave differently from the one you tested. Keeping every passing build ready to release is continuous delivery (CD). Releasing each one with no person in between is continuous deployment.

  3. Pick how to ship

    Pick a case to follow below

    With this case: All at once was quick, but for a moment none of the 6 servers answered.

    Load balancer, shares the traffic, NOWLoad balancershares the trafficNOWServer 1, serves usersServer 1serves usersrestartingServer 2, serves usersServer 2serves usersrestartingServer 3, serves usersServer 3serves usersrestartingServer 4, serves usersServer 4serves usersrestartingServer 5, serves usersServer 5serves usersrestartingServer 6, serves usersServer 6serves usersrestarting
    • Load balancer — shares the traffic — healthy — NOW
    • Server 1 — serves users — healthy — restarting
    • Server 2 — serves users — healthy — restarting
    • Server 3 — serves users — healthy — restarting
    • Server 4 — serves users — healthy — restarting
    • Server 5 — serves users — healthy — restarting
    • Server 6 — serves users — healthy — restarting
    • Stop or failed request
    • Answer
    Step 1 of 2

    Step 1 of 2 · Load balancer

    Watch: All 6 servers restart together

    What happens
    Each server stops version 1 and starts version 2 at the same moment.
    Why
    This is the fastest way to ship, and the simplest.
    What changes
    For a moment, no server answers, and users see errors.
    Next
    All 6 servers run version 2
    Servers answering
    0 of 6
    Watch: nothing answers
    Servers on version 2
    0 of 6

    Step 1 of 2: Load balancer. All 6 servers restart together. Each server stops version 1 and starts version 2 at the same moment.

    All at once: every server restarts together, so for a moment nothing serves. Rolling: one server at a time. : a second full set of servers starts, then all traffic switches in one step. Canary: one server gets about 10% of the traffic first.

    In the picture, version 2 is good. All at once, every server restarts together, so for a moment none of the 6 answers. Rolling keeps at least 5 answering, but both versions run side by side for a while.

    Blue-green starts 6 more servers, so 12 run for a while. One switch then moves all traffic, and blue stays ready for a fast rollback.

  4. Watch, then widen or roll back

    Pick a case to follow below

    With this case: As a canary at 10%, the faulty version failed about 1 request in 10 until it was rolled back.

    Load balancer, shares the trafficLoad balancershares the trafficServer 1, serves users, NOWServer 1serves usersversion 2 · 10%NOWServer 2, serves usersServer 2serves usersversion 1Server 3, serves usersServer 3serves usersversion 1Server 4, serves usersServer 4serves usersversion 1Server 5, serves usersServer 5serves usersversion 1Server 6, serves usersServer 6serves usersversion 1
    • Load balancer — shares the traffic — healthy
    • Server 1 — serves users — healthy — NOW — version 2 · 10%
    • Server 2 — serves users — healthy — version 1
    • Server 3 — serves users — healthy — version 1
    • Server 4 — serves users — healthy — version 1
    • Server 5 — serves users — healthy — version 1
    • Server 6 — serves users — healthy — version 1
    • Package or traffic
    • Stop or failed request
    • Answer
    Step 1 of 3

    Step 1 of 3 · Server 1

    Done: Server 1 runs version 2 and gets 10% of the traffic

    What happens
    The load balancer sends it 10% of requests, less than an even share of about 17%. The other 5 keep version 1.
    Why
    A small share limits how many users meet a bug.
    What changes
    Both versions now serve real users.
    Next
    Version 2 fails, and about 1 request in 10 fails
    Servers on version 2
    1 of 6
    Requests failing
    0%
    none

    Step 1 of 3: Server 1. Server 1 runs version 2 and gets 10% of the traffic. The load balancer sends it 10% of requests, less than an even share of about 17%. The other 5 keep version 1.

    What these pictures simplify. These pictures move in whole steps with stated shares of traffic. Real rollouts take minutes, and a canary is often watched for a set time before it widens. The deployments lab above runs every way of shipping with live traffic.

    Compare the new version's error rate and with the old version's. With a canary at 10%, a faulty release reaches about 1 request in 10 until it is pulled. A rollback should be one command, and tried before you need it.

    In the picture, version 2 fails every request it serves. As a canary, server 1 gets 10% of the traffic, so about 1 request in 10 fails until it is rolled back. All at once, every request fails until the rollback.

  5. Feature flags: ship code switched off

    A is a switch that the code reads while it runs. Ship the new checkout code with its flag off, then turn it on for 1% of users. Turning a flag off takes seconds and needs no release.

  6. Change the database first

    During a rollout, old and new code run side by side on one database. Say version 2 needs a new column called discount. First add the column, which the old code ignores. Then ship the code that uses it. Remove an old column only when no running version reads it.

Use it when

  • Every service that real users depend on: build the pipeline before the first release, not after the first outage.
  • A canary or blue-green release for any change that is risky or hard to test, such as a new payment flow.

Skip it when

  • A canary on a service with very little traffic: 10% of 2 requests a minute is too few to judge.
  • Blue-green when a second full set of servers costs too much, or when the two versions cannot share one database.
  • A feature flag left in the code for ever: each flag adds more paths to test, so remove it once the feature is fully on.

Check yourself

What does a blue-green deployment let you do?

Judgement

Trade-offs and how it fails

What you give up

Speed
Shipping all at once is fastest and needs no extra servers, but every user gets a bad release together.
Safety
A canary or blue-green release limits the damage and is fast to undo. The price is more servers, more steps and a slower rollout.

Failure modes

  • A rollout with no spare room: with one of six busy servers out, the other five are full and refuse requests.
  • A canary that nobody checks: with no automatic check, the faulty version passes its wait and spreads to every server.
  • A rollback that cannot work: version 2 already changed the data in a way that version 1 cannot read.
  • Tests that fail at random: people learn to ignore a red pipeline, and then a real failure gets through.

In the real world

  • Kubernetes replaces the copies of a service a few at a time by default, which is a rolling update.
  • Netflix and Google built Kayenta, a tool that compares a canary's metrics with the old version's and scores the release.
  • GitHub Actions, GitLab CI and Jenkins run a pipeline on every commit. Argo CD keeps the running servers in step with a description of them that is stored with the code.
  • Amazon has described releasing a change to one server, then one data centre, then one part of the world, with a wait between each step.

Trade-offs to be ready to discuss: Rolling vs blue green · Canary speed vs safety

Check yourself

Why keep each deploy small?

Interview

What interviewers look for

  • After the design, add one line: "We'd ship behind a canary at 5 to 10% and roll back automatically if its error rate is higher."
  • Say what you would watch during the rollout: the new version's error rate and p99 latency against the old version's.
  • For a change to the data, say the order: add the new column, ship the code, remove the old column later.

Say it out loud: Why can a healthy rolling update still fail requests?

Version 2 fails half of the requests it serves. It ships as a canary with 10% of the traffic. About what share of all requests fail?

Expected depth by interview level

Levels describe the depth interviewers probe, not years of experience. Choose a level on the learning path to highlight it.

JuniorUseful
What a pipeline does, and why tests run before a release.
MidUseful
Rolling, blue-green and canary releases, and when to roll back.
SeniorExpected
A release plan for your design: the rollout, the rollback and the database change.
StaffExpected
Release safety across teams: which checks gate a release, how far a bad one spreads, and what it costs.

Practice

Apply it

Three harder questions

The first two use the idea on a new case. The last asks you to judge a design.

Apply it

Six servers each run at 90% of what they can take. A rolling deploy takes one out at a time. Can the other five carry the traffic?

Apply it

Build 412 passed every test in staging. For production, the pipeline builds again from the same commit. What is the risk?

Judge a design

Version 2 renames a column in the same release that ships its new code. The canary fails, and the team rolls back to version 1. What happens?

Next: the database change in full: how to rename a column while the old code is still running.

Go deeper

Sources and further reading

First-hand sources to check this page against and to go further. They are standards, official docs, original papers, and guides from engineering and security teams. Each link was opened on 8 November 2026.

  • Engineering guideCanarying ReleasesGoogle SRE workbookSending a small share of traffic to a new version and comparing it with the old one.
  • Engineering guideBlueGreenDeploymentMartin FowlerTwo production environments and a switch between them, so a rollback is one change.
  • Official docsDeploymentsKubernetes documentationRolling updates, maxSurge and maxUnavailable, and rolling back to an earlier version.