Skip to main content

Pets vs. Cattle 2.0: An analogy and approach for modern infrastructures

digital business intelligence growth
(Image credit: Image Credit: Shutterstock/Sergey Nivens)

Pets vs. cattle is an analogy with modest beginnings that has grown into an industry staple. A simple Google search will spawn more than four million results and a myriad of developer memes. 

The actual, original quote was “cattle, not pets.” Microsoft Engineer Bill Baker used it during a discussion about SQL deployments to explain how server treatment changed over time. 

At its heart, the illustration is simple: it is based on considering how much bandwidth a farmer puts into caring for a cute pet like a puppy or kitten, versus how much care goes into maintaining a herd of cows on a farm. 

The puppy will get all the trappings of individualized attention, like a name, toys, tasty food and treats, and specialized medical care when they are sick or injured. 

On the other hand, cattle typically do not have names and they do not require the same level of nurturing and attention as the puppy. 

The two sets of animals are equally essential to the farmer, but for different reasons.  And most critically, the level of maintenance differs wildly.

Applying this idea, management styles of servers would depend on the grouping:

Pets: Servers get unique names and special treatment – when they are ‘sick’ they are carefully nursed back to health, often with a substantial financial investment and allocated resources.

Cattle: Servers are part of an identical group and numbered, not named.  They receive no special treatment and when they go wrong, they are replaced rather than repaired in place.

The analogy has received a lot of recent attention because of the way infrastructures and management have changed since the early days of the internet. 

Organizations have realized the need to eliminate their tendency to rely on one large, monolithic entity, forcing technology leaders to go against their instincts, and overcome significant cultural barriers. 

This has been driven by the desire to enjoy the increased security and flexibility of modern infrastructures. 

Making the decision 

Developers have had to realize that while the treatment of pets sounds more positive, it is the cattle approach that they need to target. The cold, somewhat harsh truth of business is that cattle are essential; pets are less so. 

This is not to say the cattle approach will work all the time. Not everything is disposable, and when an asset is not, it requires pet treatment. The goal is to minimize the number of pets and maximize cattle to create an easy to protect and manage infrastructure.

The practical application of pets vs. cattle centers on minimizing the systems which require individual attention. Automation is a crucial component, as the sheer number of cattle is unsustainable without it. Another is the deployment of immutable infrastructure.

At first glance, the immutable infrastructure—which cannot be changed—seems counterintuitive to the cattle approach. However, it is immutable because the server is disposable. If there is something wrong with it, it is not reconfigured or patched. It is replaced with a new server built from a standard image, with necessary changes incorporated. It can be thought of as cloning the cattle but making improvements with each iteration.

Patches and updates are an unavoidable reality of operations at scale; they ensure the ongoing security and compliance of the infrastructure. Legacy operations apply these patches in place, often inconsistently fashion, which can result in further issues. 

Immutable systems move this responsibility to the image creation process, and optimize for replacing the running image quickly, reducing the scope of change to a single, well-developed and well-tested image that can be deployed repeatedly.  Critically, this is often without interruption to ongoing operations. These systems also cut configuration drift cases, where changes are not mapped effectively, making reproduction into a backup or secondary source near impossible.

Infrastructure as code (IaC) is a crucial component of building these immutable systems. Establishing the IaC code base ensures rapidly configured replacement servers. Accessible IaC repositories are essential. 

Users should be able to understand the code provisioning to troubleshoot problems and run applications. IaC also helps eliminate the need for extensive documentation. Changes are visible within the code itself. Excessive or dated documentation increases error risk, so this is a definite benefit.

Essentially, the cattle philosophy minimizes changes to the configuration, breaks programs down to their smallest possible components, and leverages automation to control all these moving parts. The result is an infrastructure that is scalable, secure, and flexible.

Expanding the farmyard - additions to the analogy 

We need to add another important analogy to the mix, and it involves chickens. In 2015, Bernard Golden used this concept to describe the containers necessary in such a flexible environment. 

Chickens, unlike cattle, are small and require little space. That means you can use a lot more of them while minimizing the resources they consume. On top of that, chickens have much shorter lives than cattle. Cluster (cattle) instances have lifespans of days. The longevity of containers (chickens) is measured in minutes.

There is also a speed element involved. Physical servers take the longest amount of time to provision and configure, followed by VMs (with appropriate automation in place) and then Containers. The closer you move to a well-architected container model, the faster it is to remove and replace one of the components. 

Container orchestration is another vital component of the practical cattle environment, as microservice architectures require the deployment of granular level services. This process allows teams to automate tasks related to provisioning and deploying containers, allocating resources between them, and monitoring their health.

All of this comes together with could-native providers to enable the organization to scale rapidly in both directions (up and down) to meet the demands of the consumer of the application.

Herding cattle in the organization

Over time, other industry experts have added their own entities to the cattle, not pets analogy. Insects may be used to refer to a serverless environment that makes use of ephemeral applications and services. Snowflakes was a term coined to describe highly delicate, detailed servers that developers try to avoid. All these additions serve a single purpose: to help developers put the analogy to practical use.

Organizations should not eliminate pets in the pets vs cattle analogy entirely. Instead, they can be isolated to instances of absolute need. This strategy ensures administrators can concentrate their efforts on irreplaceable pets while taking a more turn-key approach to disposable assets. Working with a team of infrastructure experts who leverage decades of experience can help a business keep its cattle grazing on green pastures.

Andrew Leigh, CMO, Copado (opens in new tab)

Andrew Leigh is the SVP of marketing for Copado. He is a cloud computing exec with 20+ years of sales, marketing and product management experience in the enterprise software industry.