What does "pets vs cattle" mean?
BeginnerConceptInfrastructure & cloud basics
Answer
In one line: "Pets vs cattle" compares two ways of treating servers: pets are unique, named and carefully nursed back to health; cattle are identical, numbered and simply replaced when one gets sick.
Pets
- Named servers like
db-prod-01or "Zeus". - Built and configured by hand over years.
- If one fails, it's an emergency — people log in and fix it.
- Hard to rebuild, because nobody knows exactly how it was set up.
Cattle
- Identical instances, created automatically from code and images (
web-7f9c2). - If one is unhealthy, it's terminated and a new one replaces it automatically.
- Scaling means adding more of the same.
What makes cattle possible:
- Infrastructure as Code and golden images (Terraform, Packer, Docker).
- Auto Scaling Groups, Kubernetes ReplicaSets and health checks.
- Stateless apps — sessions in Redis, files in S3, data in managed databases.
- Centralised logging, so you don't need to log into a server to see what happened.
Benefits of treating servers as cattle:
- Self-healing and easy scaling.
- No drift, consistent environments.
- Faster recovery from failures.
- Less time spent on manual maintenance.
Are pets ever OK? Some systems are still pet-like — for example a legacy database or a special licensed server. The goal is to reduce them and to protect and automate them as much as possible (backups, IaC, runbooks).
Example: in Kubernetes, if a pod crashes, the ReplicaSet creates a new one — nobody logs in to fix it. That's cattle.
Tip for interviews: link the idea to stateless design and automation, which are what actually make cattle possible.
More on Infrastructure & cloud basics
What is the difference between declarative and imperative infrastructure?BeginnerWhat is idempotency, and why is it important in automation?BeginnerWhat is configuration drift, and how do you prevent it?BeginnerWhat is immutable infrastructure?BeginnerWhat is cloud computing, and what are IaaS, PaaS and SaaS?BeginnerWhat is the shared responsibility model in the cloud?Beginner