Go back fast when a release fails, and never patch servers in place.
A rollback means going back to the last version that worked, fast, when a release goes wrong. Immutable infrastructure makes this easy: you never change a running server. You build a new one from a versioned image and replace the old one.
Every release can fail. What matters is how quickly and how safely you can return to a good state. A fast rollback turns a scary incident into a small hiccup.
In the old style, called mutable infrastructure, you log in to a server and update it: install a package, change a setting, copy new code. After a year each server has a different history. Two servers that should be equal are not. When a release fails, an "undo" script runs on servers it was never tested on.
With immutable infrastructure, a server is built once from a recipe (a container image, a VM image) with a version number, such as app:1.4.2. To release, you start servers from app:1.4.3 and stop the old ones. To roll back, you start app:1.4.2 again. Nothing is repaired in place. The old image still exists, exactly as it was.
| Way | How it works | Good and bad |
|---|---|---|
| Redeploy the previous version | Start the old image again (or point the pipeline at the old tag) | The simplest and most common. Needs the old artifact to be kept. |
| Switch traffic back | In blue-green, point the load balancer back to the old environment | Almost instant. Needs two environments running. |
| Flip a feature flag off | Turn the new code path off without any deploy | Takes seconds. The code must be behind a flag. |
| Stop a canary | Send 0% of traffic to the new version | Limits the damage to the small share who saw it. |
| Revert the commit and redeploy | Undo the change in Git, run the pipeline again | Slower, but leaves a clear history. |
| Roll forward | Ship a quick fix as a new version | Needed when going back is unsafe, for example after a data change. |
| Restore from backup | Recover the data to a point in time | The last resort for data problems. Some recent data is lost. |
| Mutable | Immutable | |
|---|---|---|
| How a change is made | Edit the running server | Build a new image, replace the server |
| Servers over time | Drift apart | Stay identical |
| Roll back | Run an undo script, hope it fits | Start the old image |
| Debugging | βIt works on my serverβ | Same image everywhere, so reproducible |
| Logging in to fix things | Common | Discouraged. Fix the image instead. |
| Local state on the server | Often kept there | Must live outside (database, object store) |
Servers are patched in place with scripts. Over time, people also make hand changes, so some servers drift away from the rest.
Release v2 only changes code. The database is untouched.
A simplified model with no random numbers. In the patched model every third server has hand-made changes (drift). All times are illustrative and not from a real system: undoing a patch takes half the start time per server, and each drifted server needs 15 minutes of manual repair. Press Roll back to compare.
| Term | Meaning in easy words |
|---|---|
| Rollback | Returning to the previous working version after a bad release |
| Roll forward | Fixing a problem by releasing a new version instead of going back |
| Immutable infrastructure | Servers are never changed after they start. They are replaced from a new image |
| Mutable infrastructure | Servers are updated in place, one change at a time |
| Configuration drift | Servers slowly becoming different from each other because of manual or partial changes |
| Image | A packaged, versioned copy of an app and its environment (a container or VM image) |
| Artifact | Any build output you can store and deploy, such as an image |
| Registry | A store for images, where each version is kept |
| Image digest | A hash that identifies one exact image. It can never point to something else |
| Infrastructure as code | Describing servers and networks in files that are kept in version control |
| Snowflake server | A hand-tuned server that nobody can recreate |
| Choice | We gain | We lose |
|---|---|---|
| Replace servers on every change | Known state, easy undo | Each change needs a build and a roll-out |
| Patch in place | A quick small fix | Drift, and a roll-back nobody has tested |
| Keep many old images | A choice of versions to go back to | Storage cost and a longer clean-up policy |
| Always roll back first | Fast recovery | May hide a deeper problem and repeat the failure |
| Roll forward | Keeps the good part of the release | Needs a fix to be written quickly under pressure |
| Keep the old environment running (blue-green) | An instant switch back | Double the infrastructure cost for a while |