Bookmarks

Immutable infrastructure

An approach in which servers are never modified after deployment: any change is built into a new image, and the old instance is replaced outright.

Also: immutable infrastructure, immutable servers

checked 18 Nov

All terms

The idea is simple: a finished server is not tweaked further but thrown away. The OS, packages, code and configuration are baked into an image; when an update comes out, a new image is built, instances are spun up from it and the old ones are switched off. The approach was named and described in 2013, and with the spread of clouds and containers it became the norm.

How it works

Changes live only in the repository and reach the servers through the build pipeline: a change goes into the base image, the image is verified by tests, and new instances then roll out to replace the old ones. Logging into a running server and editing a file by hand is exactly what the approach does not forgive: such a change will vanish at the next replacement, and until then it is a source of unexpected drift. Configuration management tools are not run against a live instance: any change to a running system is a risk.

StepMutable approachImmutable approach
Changean engineer logs in over SSH and edits the config on a live serverthe change is committed to the repository and an image build is started
Deploymentpackages are installed and the machine is configured in placenew instances are spun up from a ready-made image
Rollbacksomeone recalls what was changed and when, then reverts it by handswitching back to the previous image
Stateservers live for years and drift apartservers are disposable and built identically

Servers built from the same image behave identically: they do not accumulate configuration drift, and the test environment matches production. Rollback is predictable — it is the previous image, not an attempt to undo a dozen changes.

Where the term comes from

The idea grew out of the fight against “snowflakes” — servers assembled by hand and unlike one another: configuration automation made it possible to tear a server down and rebuild it at any moment (the “phoenix”), and immutability became the logical conclusion of that line. On 13 June 2013 Kief Morris described the Immutable Server pattern, noting that his colleague Ben Butler-Cole had coined the word; on 23 June Chad Fowler published the essay “Trash Your Servers and Burn Your Code” about immutable infrastructure. He compared an old server to a house of cards: one-off config changes made during incidents, code released outside the normal process and forgotten cron jobs pile up until people are afraid to touch the system. Netflix, for example, ran on immutable images — it built its own images for Amazon EC2 with the Aminator tool.

The compute part is made immutable: virtual machines, containers, nodes. Data and state are not replaced this way — databases, disks and persistent volumes live longer and need ordinary maintenance and backups; logs are shipped to centralised collection. Differences between instances of the same role are kept to a minimum: configuration and secrets are supplied from outside — through environment variables, platform metadata or a secrets store — and are not baked into the image.

Sources

the term is written from these pages

Verified 18 Nov

Not to be confused with

what it is mixed up with and how it differs

  • IaCInfrastructure as Code

    IaC describes infrastructure as code but can modify existing servers in place; immutable infrastructure always builds new ones.

In depth in the references

where the topic is covered in detail