SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
  • Deployment Strategies Overview
  • CI/CD Pipelines
  • Rolling Deployments
  • Blue-Green Deployments
  • Canary Releases
  • Feature Flags
  • A/B Testing Infrastructure
  • Schema Migrations
  • Rollbacks and Immutable Infrastructure
  • Multi-Region and Active-Active
  • Infrastructure as Code (Terraform)
  • Auto-Scaling Policies
  • Zero-Downtime Deployment
  • Chaos Engineering
  • Shadow Traffic and Dark Launches
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Operations and Security/Deployment Patterns

Rolling Deployments

Replace old servers with new ones a few at a time, so the service never stops.

⏱ 12 min readBeginnerInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

A rolling deployment replaces the old version with the new one a few servers at a time, so the service keeps running the whole time.

  • Take a few servers out of the load balancer, upgrade them, check they are healthy, and put them back. Then do the next batch.
  • For a while, version 1 and version 2 run together. They must both work with the same data.
  • It needs little extra capacity and is the default in many platforms, but a rollback is slower than with blue-green.

02Concept: What is it?

Imagine you run 8 servers behind a load balancer. The simplest upgrade is to stop all 8 and start 8 new ones, but that means downtime. A rolling update does it in batches. While batch one is being upgraded, the other servers still answer every request.

Each batch goes through the same steps. First drain: the load balancer stops sending new requests, and running requests are allowed to finish. Then replace: start the new version. Then check: wait until a readiness check passes. Only then does the server join the pool and take traffic.

One round of a rolling update
⏳Drainfinish current requests
→↓
⚙️Replacestart version 2
→↓
🩺Checkis it ready?
→↓
✅Jointake traffic
⇢⇣next batch
The same loop repeats until every server runs the new version.
🧠The readiness check is the safety net
Without it, a broken new server gets traffic anyway, and the rollout happily replaces every healthy server with a broken one. With it, the update stops after the first bad batch.

03Real-Life Example

🍵Changing the Tyres on a Moving Bus Fleet
A bus company runs 8 buses on a busy route and wants new tyres on all of them. It cannot stop the whole route. So it takes two buses at a time to the garage while the other six keep running. If the new tyres on the first two buses turn out to be faulty, the company stops after those two, not after all eight. The route is a little busier while two buses are away, so the company must not take away too many at once.
Bus company
Rolling deployment
Buses on the route
Servers behind the load balancer
Two buses at the garage
A batch being upgraded
Passengers finish their trip first
Connection draining
Testing the bus before it returns
Readiness check
The other six keep running
Remaining capacity serves traffic
Stopping after two bad buses
A failed check stops the rollout
Taking too many buses away at once
A batch that is too big overloads the rest
Capacity during the update (8 servers, batch of 2)
🖥️8 / 8before
→↓
🖥️6 / 8batch drained
→↓
🖥️8 / 8batch joined
⇢⇣repeat

04Why Do We Need It?

🕒No downtime
Some servers always answer, so users do not see a maintenance page.
💰Cheap
You do not need a second full environment. At most you add a surge server or two.
🧯Stops early
With a readiness check, a bad version is stopped after one batch, not after the whole fleet.
🧰Built in
Kubernetes, load balancers and most cloud platforms support it by default.
🧩Simple to understand
One loop: drain, replace, check, join. Easy to explain and to automate.
📏Tunable
Batch size sets the balance between speed and capacity.
A rolling update is the everyday way to ship without downtime: change a few servers at a time, and only continue if the new ones are healthy.

05Where Do We Use It?

☸️Kubernetes Deployments
The default update method. Settings control how many pods can be unavailable and how many extra can be created.
☁️Auto-scaling groups
Cloud services can replace instances in batches (an instance refresh).
🐳Container platforms
Services on ECS, Nomad or Docker Swarm update tasks in batches.
🖥️Plain server fleets
Scripts or tools such as Ansible update hosts in groups behind a load balancer.
🧱Stateless web services
The best fit: any server can handle any request.
🗄️Clusters with replicas
Database or cache nodes can be upgraded one at a time, with extra care.

06Types / Parts / How It Works

The knobs of a rolling update

SettingWhat it controlsEffect
Batch size (max unavailable)How many servers are out of service at onceBigger is faster, but lowers capacity during the update
Surge (max extra)How many extra servers can be started above the normal countKeeps capacity up, costs a little more for a while
Readiness checkA test that must pass before a server gets trafficStops a bad version from spreading
Drain timeHow long running requests get to finishToo short cuts requests, too long slows the update
Min ready timeHow long a server must stay healthy before the next batchCatches problems that appear a little later
Progress deadlineHow long the rollout may take before it counts as failedTurns a stuck rollout into an alarm

Two ways to keep capacity

Drain first, or start extra first
Drain first
v1
v1
…
capacity dips by one batch
Surge first
v1
v1
v2
start new, then remove old
Old version New version
Surge keeps full capacity but needs room for the extra servers.
VisualizerRoll a new version across a fleet, one batch at a timeStep through the rollout. Make the batch bigger and the traffic higher to see capacity run out. Turn on the bug with and without the readiness check, and watch what happens to the fleet.
🖥️
S1 · v1
serving
🖥️
S2 · v1
serving
🖥️
S3 · v1
serving
🖥️
S4 · v1
serving
🖥️
S5 · v1
serving
🖥️
S6 · v1
serving
🖥️
S7 · v1
serving
🖥️
S8 · v1
serving
Serving: 8/8Capacity: 100% vs load 70%Requests failing: 0%
Step 1 of 14
Start
8 servers run version 1 and all of them serve traffic through the load balancer.
Capacity never drops below 75%, which is enough for 70% load, so users see no change. A bigger batch would finish sooner but lowers capacity more.

A simplified model: servers have equal capacity, and requests are shared evenly between the servers that are serving. Real platforms add surge servers, timeouts and retries on top of this.

07How to Use It / Steps / Implementation

Running a rolling update well

  1. 1
    Make servers stateless
    Keep sessions and files outside the server (in a database or cache), so any server can serve any request and can be replaced at any time.
  2. 2
    Write a real readiness check
    It should test that the app can really do its job (for example reach its database), not only that the process started.
  3. 3
    Enable connection draining
    Give running requests time to finish before a server stops. Handle the stop signal in the app so it shuts down cleanly.
  4. 4
    Pick the batch size from your headroom
    If the fleet normally runs at 70% load, you can take away at most about 30% of the capacity. Add surge servers if you need more.
  5. 5
    Keep versions compatible
    v1 and v2 run together and often share a database, a queue and a cache. Both must understand the same data.
  6. 6
    Watch while it rolls
    Look at error rate and latency for the new version, not only the total. Stop the rollout if they rise.
  7. 7
    Know the rollback
    To roll back, roll forward to the old version, using the same process. It takes about as long as the rollout, so practise it.
💡Set a minimum ready time
Some bugs only show after a minute (a slow memory leak, a cache that is cold). Requiring each batch to be healthy for a short time before the next batch starts catches more of them.
⚠️Do not forget long-lived connections
WebSocket and streaming connections do not finish quickly. Decide how long to wait, and make clients reconnect gracefully, or the update will cut them.

08Key Terms to Know

TermMeaning in easy words
Rolling updateReplacing servers with a new version in small batches
BatchThe group of servers changed at the same time
Connection drainingLetting running requests finish before a server stops
Readiness checkA test that tells the load balancer the server can take traffic
Liveness checkA test that tells the platform the process is alive or must be restarted
SurgeExtra servers started above the normal count during an update
Max unavailableHow many servers may be out of service at once
Graceful shutdownStopping a server cleanly: finish work, close connections, then exit
StatelessA server that keeps no user data between requests
Mixed-version stateThe time when old and new versions run together
Roll forward / backMoving to the newer version, or returning to the older one

09Pros, Cons and Trade-offs

✅ Pros
  • No downtime when done correctly
  • Needs little extra capacity
  • Stops early if the new version fails its checks
  • Supported by most platforms by default
  • Simple to understand and automate
⚠️ Cons
  • Rollback is slow because it is another rolling update
  • Old and new versions run together
  • Capacity dips during the update
  • Hard to test the new version on only some users
  • Bad readiness checks make it unsafe

Trade-offs

ChoiceWe gainWe lose
Bigger batchA faster rolloutLower capacity, bigger blast radius
Smaller batchHigher capacity, smaller blast radiusA slower rollout
Surge serversFull capacity throughoutA little extra cost, and room is needed
Long drain timeFewer cut requestsA slower update
Strict readiness checkBad versions stopped earlyRisk of a stuck rollout if the check is too picky
Rolling vs blue-greenLower costSlower rollback, and mixed versions

10Common Problems and Mistakes

Common mistakes

  1. A readiness check that only says "the process is running". The broken version still gets traffic.
  2. No draining. In-flight requests are cut and users see random errors.
  3. Batches too large. The remaining servers are overloaded, which looks like an outage.
  4. Incompatible versions. v2 writes data that v1 cannot read, so the mixed period causes errors.
  5. Stateful servers. Users lose sessions when their server is replaced.
  6. Ignoring slow bugs. The rollout finishes before a memory leak shows up.
  7. Never practising the rollback. The first time is during an outage.

Things to watch

📉Capacity dips
Check headroom before you choose a batch size, especially at peak time.
🧩Mixed versions
Messages, schemas and APIs must work for both versions at once.
🔌Long connections
Streams and sockets need a drain plan.
🧊Cold caches
New servers start with empty caches and may be slow at first. Warm them up if it matters.

11Real-World Examples

☸️Kubernetes
A Deployment replaces pods in a rolling way by default, with settings for max unavailable and max surge.
☁️Cloud instance groups
Managed groups of virtual machines can replace instances in batches, waiting for health checks.
🐳Container services
Container platforms update tasks in a rolling way, with minimum healthy percentage and maximum percentage settings.
🏭Pipelines
A CI/CD pipeline usually triggers the rolling update, then watches health and can roll back.
🗄️Database clusters
Replicas are often upgraded one by one, leaving the primary for last.
🛒Busy shops
A rolling update during a sale must respect headroom, or the remaining servers are overwhelmed.
📝Note
Setting names and defaults depend on the platform and its version. Check the documentation of the tool you use.
Mini case: 10 pods, max unavailable 2, max surge 1
➕Surge 1start a v2 pod
→↓
🩺Ready?check passes
→↓
➖Remove 2 v1drain, then stop
⇢⇣repeat
Capacity stays near full, and a failed readiness check pauses the rollout.

12Related Topics to Read Next

Deployment Strategies Overview→

How rolling compares with the other strategies.

Blue-Green Deployments→

A faster rollback, at the price of a second environment.

Canary Releases→

Test the new version on a few users first.

What are Load Balancers?→

They decide which servers take traffic during the update.

Schema Migrations→

Database changes must work for old and new code together.

Rollbacks and Immutable Infrastructure→

Going back, and replacing servers instead of patching them.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • ✔What: replace servers a few at a time, so the service never stops.
  • ✔Round: drain, replace, check, join. Repeat.
  • ✔Safety net: a real readiness check stops a bad version after one batch.
  • ✔Capacity: batch size must fit your headroom. Add surge servers if needed.
  • ✔Mixed versions: v1 and v2 share data, so keep changes backward compatible.
  • ✔Rollback: another rolling update. Slower than blue-green, so practise it.
  • ✔Needs: stateless servers, draining, graceful shutdown.
  • ✔One line: “Change a few servers, check they are healthy, then change a few more.”
← Previous
CI/CD Pipelines
Next →
Blue-Green Deployments