AlgoMaster Logo

Deployment Strategies Overview

10 min readUpdated October 26, 2026
AI Mock Interview

Practice this topic in a realistic system design interview

Listen to this chapter
Unlock Audio

Deployment Strategies Overview

Suppose your application is running on ten servers, all using version 1. Your team has finished building version 2, tested it thoroughly, and is now ready to release it to production.

But deploying new code always comes with some risk. In fact, software releases are one of the most common causes of production incidents.

A deployment strategy is the plan for moving traffic from the old version to the new one. Each strategy makes different trade-offs between downtime, risk, cost, and rollback speed.

This chapter covers the most common deployment strategies, how each one works, where each one can hurt you, and how to choose between them.

1. Why Deployments Are Risky

The problem is that staging environments can never fully replicate production. Production has real users, real traffic, real data, and dependencies that may behave differently under load. So a bug that went unnoticed during testing might appear within seconds of deployment.

A live system is also not sitting still while you deploy. It has open connections, requests in flight, caches full of data, and background jobs in progress.

The challenge, then, is not just getting the new version into production. It is doing so in a way that minimizes the impact if something goes wrong. That is what deployment strategies help us achieve.

2. The Questions Every Strategy Answers

Every deployment strategy comes down to a few practical questions:

  1. Downtime: Will users experience any downtime while the new version is being deployed?
  2. Exposure: How many users will see the new version at once? If version 2 has a bug, will it affect 1% of users or everyone? This is often called the blast radius.
  3. Rollback speed: How quickly can we go back to version 1 if something goes wrong?
  4. Extra infrastructure: How much additional capacity do we need during the deployment?

Each strategy handles these concerns differently, and no single approach is best at everything. Choosing the right one means understanding these trade-offs and deciding what matters most for your application.

The five strategies covered here are recreate, rolling, blue-green, canary, and shadow. After them, we'll look at feature flags, which work alongside all five.

3. Recreate

The simplest deployment strategy is called recreate, sometimes also known as a big bang deployment.

The idea is straightforward:

  1. Stop all instances running version 1.
  2. Once they're stopped, start all instances with version 2.

This approach is easy to understand and implement. Since the two versions never run at the same time, you don't have to worry about compatibility between them.

But there's a major downside. From the moment you stop the old version until the new one is ready to serve traffic, your application is unavailable. And if version 2 contains a bug, every user is affected at once.

Rolling back isn't any easier. You have to stop version 2 and bring version 1 back, which causes another period of downtime.

Despite these limitations, recreate deployments can still work well for internal tools, batch jobs, or applications with planned maintenance windows. They are also used for some stateful systems where two versions cannot safely run at the same time.

For most user-facing services, though, we need an approach that keeps the application available during deployment.

4. Rolling Deployments

A rolling deployment updates servers gradually instead of replacing everything at once.

Suppose our application is running on ten servers:

  1. Take two servers out of the load balancer.
  2. Upgrade them to version 2 and wait for them to pass their health checks.
  3. Once they're ready, add them back and move on to the next two servers.
  4. Repeat until all ten servers are running version 2.

Since most servers keep handling traffic during the rollout, the application can stay available without downtime, as long as there's enough capacity.

This is the default deployment strategy on many platforms. Kubernetes, for example, uses rolling updates by default for Deployments. It lets you control two settings:

  • maxUnavailable: how many instances can be unavailable at a time.
  • maxSurge: how many additional instances can be created temporarily during the rollout.

Together, these settings determine how quickly the deployment progresses and how much capacity remains available to handle traffic.

The Trade-offs

Rolling deployments have two important trade-offs.

The first is that old and new versions run at the same time. Halfway through the rollout, some servers are still running version 1, while others have already switched to version 2. A user might hit version 2 on one request and version 1 on the next. So both versions need to be compatible with the same requests and data. That includes API formats, database schemas, cached values, and messages on queues.

The second is rollback speed. Suppose we've already upgraded eight servers when we discover a bug in version 2. To roll back, we have to repeat the rolling process in reverse, moving servers back to version 1 in batches. This takes time, and users may keep hitting the broken version until the rollback finishes.

So what if we could switch back to the previous version in just a few seconds?

5. Blue-Green Deployments

That's what blue-green deployments are designed for. Instead of upgrading servers one by one, we maintain two separate environments:

  • The blue environment runs version 1 and handles all production traffic.
  • The green environment is an identical setup, but it runs version 2.

At first, green doesn't receive any real user traffic, so we can deploy the new version, warm it up, and run smoke tests to make sure everything works as expected.

Once we're confident, we switch the load balancer or router to send all production traffic to green. This switch can happen in just a few seconds.

Meanwhile, the blue environment stays running with the old version. If something goes wrong with version 2, we route traffic back to blue, and users are on the previous version almost immediately.

The Trade-offs

Blue-green lets us release new versions without downtime and roll back much faster than the strategies we've seen so far. But there are a few trade-offs.

  1. Infrastructure cost. During the deployment, we need to keep two complete production environments running.
  2. Database compatibility. Both environments usually share the same database. If version 2 makes a schema change that version 1 can no longer handle, switching back to blue won't solve the problem.
  3. All-at-once exposure. When we switch traffic to green, every user starts using version 2 at once. If a bug only appears under real production traffic, it can affect everyone before we have a chance to react.

So while rollback is fast, the potential impact is still large. What if we could reduce that risk by testing version 2 with a small group of real users first?

6. Canary Releases

A canary release takes a more cautious approach.

The name comes from the canaries that miners once carried into coal mines. If a bird showed signs of distress, it warned the miners that the air was unsafe before they were seriously affected.

Canary releases follow a similar idea. Instead of sending all production traffic to version 2, we deploy it alongside version 1 and send only a small percentage of traffic to it, say 1%. The other 99% keeps using version 1.

We then monitor the new version closely, comparing its error rates, latency, and important business metrics with those of the old version.

If everything looks good, we gradually increase the traffic to version 2: 1% → 5% → 25% → 50% → 100%.

If something goes wrong at any stage, we route traffic back to version 1. This lets us catch problems early, before they affect a large number of users.

What Canary Releases Need

Canary releases work well, but they depend on a few things.

  1. Good monitoring. A canary is only useful if we can tell whether the new version is performing well. That means metrics split by version.
  2. Enough traffic. If a service only gets a few requests per minute, sending 1% of traffic to the canary won't give us enough data to detect problems reliably.
  3. Sticky routing. It's usually better to keep each user on the same version. If users switch between versions on every request, they might see inconsistent behavior, especially if the UI or API responses have changed. Many teams route users based on a stable identifier, such as their user ID.
  4. Automation. Larger teams often automate the whole process. At each stage, the system compares the canary's metrics with the old version and decides whether to continue the rollout or roll back.

So canary releases limit the impact of bugs, but some real users still see the new version. What if we could test it with real production traffic without affecting any users at all?

7. Shadow Deployments

That's what a shadow deployment, also known as traffic mirroring, lets us do.

Version 1 keeps serving all users as usual. At the same time, we send a copy of each incoming request to version 2. The new version processes these requests, but its responses are discarded. Users only get responses from version 1, so their experience doesn't change.

This lets us see how version 2 performs under real production traffic without exposing users to its responses. We can compare latency, error rates, and even the responses produced by both versions. It is a good fit for rewrites of performance-sensitive code such as search, ranking, or recommendations.

There's one important risk: side effects. Suppose a mirrored request processes a payment or places an order. If version 2 also charges the customer or sends a confirmation email, that action could happen twice.

To avoid this, shadow deployments work best for read-only operations. For requests that involve writes, we need to isolate the side effects, for example by replacing external calls with stubs or sending writes to test storage.

8. Feature Flags: Deploy vs Release

So far, we've looked at strategies that control how new code is deployed across servers. There's another way to reduce risk: controlling which features users can access. This is where feature flags come in.

With feature flags, we deploy the new code to production but keep the feature disabled behind a flag. The code is already running on the servers, but users keep seeing the old behavior.

When we're ready, we enable the feature for internal users first, then a small percentage of customers, and eventually everyone. If something goes wrong, we turn the flag off without redeploying anything.

This separates two ideas that are easy to mix up:

  • Deploy: getting code into production.
  • Release: making a feature available to users.

Feature flags work alongside any of the deployment strategies we've discussed. For example, a team might use a rolling deployment to ship the new code, then gradually enable the feature with a flag.

9. Choosing a Strategy

So how do you choose the right deployment strategy?

Start with downtime. How much downtime can your application tolerate? If a short maintenance window is acceptable, recreate might be all you need.

Then think about the impact of a failed release. For something like an internal dashboard, a rolling deployment with proper health checks is usually enough. For critical services like checkout or payment APIs, you might prefer a canary release to limit the number of affected users, or blue-green for faster rollbacks.

Consider your monitoring. A canary release is only useful if you can reliably compare the performance of the two versions. Useful signals include error rate, latency (p50, p95, p99), saturation such as CPU or queue depth, and business metrics like checkout success rate. A process being "up" is not enough; real requests need to succeed.

Check database compatibility. Rolling, blue-green, and canary all run old and new code against the same database at some point. Schema changes need to be backward compatible: add new columns before reading them, and drop old columns only after the old code is gone.

SituationReasonable Strategy
Internal tool, batch job, or maintenance window is acceptableRecreate
Stateless service with several instances, like an internal dashboardRolling
Critical API where rollback speed matters mostBlue-Green
Critical service like checkout, with good per-version metrics and enough trafficCanary
Rewrite you want to test on real traffic, with side effects isolatedShadow
Risky feature you want to turn on graduallyAny deployment + feature flag

Combining Strategies

In practice, teams often combine several strategies. For example, you might use rolling updates to deploy the new code, gradually increase traffic to the new version with a canary release, and control individual features with feature flags.

Each step catches a different kind of problem. Staging catches obvious bugs, the canary catches problems that only show up under real traffic, the rolling deploy finishes the rollout without a second full fleet, and the flag lets you turn the feature on when you're ready.

Summary

Deployment strategies determine how we move from an old version of an application to a new one while managing risk.

  • Recreate stops everything and starts the new version. It is simple, but it causes downtime and exposes every user at once.
  • Rolling upgrades servers in batches. It avoids downtime, but old and new versions run side by side, and rollback is slow.
  • Blue-green runs two environments and switches traffic between them. Rollback takes seconds, but it costs a second environment and every user moves at once.
  • Canary sends a small slice of traffic to the new version and grows it while watching metrics. It needs good monitoring and enough traffic.
  • Shadow mirrors real traffic to the new version and discards its responses. Users are never affected, but side effects must be isolated.
  • Feature flags separate deploying code from releasing a feature, and work with any of the above.

Whichever strategy you choose, backward compatibility, reliable health checks, and good monitoring are essential for safe deployments.

Quiz

Deployment Strategies Overview Quiz

10 quizzes