A map of the ways to put new code into production, and the risk each one carries.
A deployment strategy is the plan for moving a new version of your software from "finished" to "running for real users", with as little pain as possible if something is wrong.
Writing code is only half the job. The other half is releasing it. A release changes a running system that real people are using at that very moment, so it is one of the most common causes of outages.
A deployment strategy answers three questions. How do users keep being served while the change happens? Who sees the new version first? And how do we undo it if it goes wrong?
| Strategy | How it works | Downtime | Extra cost | Rollback | Best for |
|---|---|---|---|---|---|
| Recreate | Stop all old, start all new | Yes, a short outage | None | Redeploy the old version (slow) | Dev and test, or apps that can not run two versions |
| Rolling | Replace servers in small batches | None | Small (maybe a surge server) | Roll forward or reverse the roll (slowish) | Most stateless services |
| Blue-green | Run old (blue) and new (green) side by side, then switch | None | High (a second full environment) | Flip traffic back (very fast) | Releases that must be safe and quick to undo |
| Canary | Send a small share to the new version, then grow it | None | Small | Send the share back to 0% (fast) | Risky changes, large user bases |
| Technique | What it adds |
|---|---|
| Feature flags | Release the code without turning the feature on. Switch it on for some users later. |
| Shadow (mirror) traffic | Copy real requests to the new version and ignore its answers, just to compare. |
| A/B testing | Show different versions to different users to measure which one is better, not just safer. |
| Immutable infrastructure | Never change a running server. Replace it with a new one built from a fresh image. |
| Automatic rollback | A tool watches error and latency numbers and goes back for you. |
Replace the servers a few at a time. The share of users on the new version grows steadily over 10 minutes.
A simplified model with a simulated clock and no random numbers. The extra-server and rollback numbers are illustrative, not measurements. Real values depend on your platform and your settings.
| Term | Meaning in easy words |
|---|---|
| Deployment | Putting a version of the software onto the servers that run it |
| Release | Making that version available to users (often the same moment, but not always) |
| Downtime | Time when users can not use the service |
| Blast radius | How many users a bad change can hurt |
| Rollback | Going back to the last good version |
| Rolling update | Replacing servers in small batches |
| Blue-green | Two full environments, with traffic switched from one to the other |
| Canary | Sending a small share of users to the new version first |
| Readiness check | A test that tells the load balancer a new server can take traffic |
| Traffic shifting | Changing what share of requests goes to each version |
| Backward compatible | A newer version that still works with data and callers made for the older one |
| Choice | We gain | We lose |
|---|---|---|
| Recreate | Simplest, no mixed versions | Downtime, and the biggest blast radius |
| Rolling | No downtime, low extra cost | Slow rollback, and two versions run for a while |
| Blue-green | Instant switch and instant rollback | Double the servers while releasing |
| Canary | Smallest blast radius, real-user proof | Slower release, needs monitoring and traffic control |
| Faster rollout | Less time with mixed versions | Less time to notice problems |
| Slower rollout | More time to watch the numbers | Longer release, and more time in a mixed state |