Interview Prep/DevOps Fundamentals/Infrastructure & cloud basics

What is immutable infrastructure?

BeginnerConceptInfrastructure & cloud basics
Answer

In one line: Immutable infrastructure means you never modify servers or containers after they're deployed — to change anything, you build a new image and replace the old instances.

Mutable vs immutable:

  • Mutable (traditional): SSH into servers and run updates, patches and config changes in place. Over time each server becomes slightly different.
  • Immutable: bake a new image (AMI or Docker image) with the change, deploy new instances from it, and destroy the old ones.

How it works in practice:

  • Containers: to update the app, build orders:1.4.3 and roll it out; you never docker exec in and edit files.
  • VMs: build a "golden image" with Packer (OS + patches + agents + app), then replace instances in an Auto Scaling Group using a rolling instance refresh.

Benefits:

  1. No configuration drift — every instance from the same image is identical.
  2. Predictable deployments — the image you tested is exactly what runs.
  3. Easy rollback — redeploy the previous image.
  4. Better security — no SSH changes needed; servers can be locked down; patches come via new images.
  5. Fits autoscaling — new instances are ready instantly from the image.

Challenges:

  • Needs good automation (image pipelines, rolling replacement).
  • State must live outside the instances — databases, object storage (S3), persistent volumes — because instances are disposable.
  • Image builds take time, so small fixes still mean a full image cycle.

Pets vs cattle: mutable servers are "pets" (named, cared for individually); immutable ones are "cattle" (identical and replaceable).

Example: a monthly OS patch used to mean SSH-ing into 40 servers. Now a Packer pipeline builds a patched AMI, and an Auto Scaling Group instance refresh replaces servers one batch at a time with zero downtime.

Tip for interviews: mention Packer + Auto Scaling or containers, and that state must live outside the instances.

All DevOps Fundamentals questions

More on Infrastructure & cloud basics