Mutable and Immutable Infrastructure

🔮 We know who we are, yet we know not who we may be 🔮

Mutable Infrastructure

To define mutable infrastructure, I'll give you an example.

Your software, the Marvel-rate-inator, which rates different Marvel characters based on their power level and how cool they are (Silver Surfer is definitely the highest rated), is used by millions of people around the world.

Let's say you have 20 servers that people are connecting to in order to use your software. Every time you release a new build, you simply update the software on each of the 20 servers you currently have running.

In this scenario, you would say you have a mutable infrastructure. Mutability refers to the tendency for something to change, and in this case, our software definitely changes, since we are updating the software on the servers.

image.pngYou keep the same server, just update the software running on it.

Immutable Infrastructure

You can probably guess that immutable infrastructure is the exact opposite of mutable infrastructure.

However, it's important to know the way in which the infrastructure is immutable. We'll keep going with the example of your revolutionary, award-winning, debate-ending, copyright-infringing application.

You realize that, after many updates to your servers, various things start to break. One error pops up on server 17, a different error shows on server 4, some servers have no errors, and it's all a mess even though you've tried to keep the software the same on all servers.

So, you decide to adopt an immutable infrastructure.

Instead of updating the software on your existing servers, you instead create new servers or virtual machines, created from an image of a working server, and then update that one server to the new version. From there you test and debug the new version, and once you have verified it's production-ready, you can deploy that server to the public and decommission your old server.

When it's time for a new update, you simply start up another VM, created from an image of the last working VM, and update that new VM, and the cycle continues.

You now have an immutable infrastructure.

This infrastructure is considered immutable because you are not supposed to make changes to the server once it is deployed to production. You simply make an image of that server, and use that image to launch a new server that will eventually go to production and the old VM will be decommissioned.

image.pngWith immutable infrastructure, you create a new server instead of updating the one currently in production.


If you'd still like an explanation on Mutable vs Immutable Infrastructure, HashiCorp (the creators of Terraform) has a great video on this topic: youtube.com/watch?v=II4PFe9BbmE

Feel free to reach out to me with any questions on this subject or anything cloud related!

👨‍🎤