liveBook · Manning

Chapter 9: Architecting for the Cloud: Trading Pets for Cattle and Concrete for Code

What you will learn in chapter 9 of Grokking Software Architecture

This chapter introduction previews cloud architecture topics, including disposable servers, compute tradeoffs, Infrastructure as Code, and automated services.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduction previews cloud architecture topics, including disposable servers, compute tradeoffs, Infrastructure as Code, and automated services.

Introduction

Introduces the gap between software working locally and running reliably in its real deployment environment, usually the public cloud.

Key terms: works on my machine, Public Cloud, on-premises data center

9.1.1 The Cloud is Not Magic: The Multi-Tenant Reality

This section explains that public cloud applications share physical hardware with other tenants, which can affect performance even when the application code is sound.

Key terms: public cloud, Multi-Tenancy, Noisy Neighbor

9.1.2 The Architectural Mindset Change

This section explains why cloud architecture requires a change in how applications and infrastructure are designed, not merely a move to cloud-hosted servers.

Key terms: Cloud Architecture, stateful, temporary, disposable, Infrastructure as Code (IaC), version-controlled text files, executable blueprints, repeatability

9.1.3 But Wait… Isn’t This Infrastructure, Not Architecture?

This section explains why cloud infrastructure is an architectural concern: it replaces fixed hardware limits with usage-based flexibility, operational complexity, and cost risks.

Key terms: on-premises data centers, Scalability, operational complexity, billed entirely by usage, dynamically expand and contract, elastic cloud environment, Infrastructure as Code (IaC), Decision Scribe, codebase

9.1.4 OK, So How Do I Actually Start?

This section gives a small, safe way to start practicing cloud architecture with Terraform while keeping costs under control.

Key terms: Infrastructure as Code (IaC), Terraform CLI, resource block, main.tf, cloud-agnostic, Free Tiers, LocalStack, deployment, architectural constraint, Billing Alarm

9.2 The Cloud-Ready Diagnostic

This section uses three questions to distinguish cloud-ready architecture from an application merely running on rented cloud servers.

Key terms: Wipeout Test, Stateful, cloud-native, Midnight Patch Test, Manual Patches, configuration drift, Meteor Test, Availability Zone

9.3 Pets vs. Cattle

This section introduces the “Pet” server model by explaining why early servers were treated as individual, valued machines.

Key terms: Pet server model

9.3.1 The Problem with Pets

This subsection explains why a hand-maintained, stateful “pet” server makes failures costly and difficult to recover from.

Key terms: Pets, hand-configured, Stateful, user session data, temporary files, uploaded images

9.3.2 The "Cattle" Revolution

This section explains why quickly provisioned cloud servers can be treated as disposable, interchangeable “cattle” rather than individually maintained “pets.”

Key terms: Cattle, pets, ephemeral virtual server

9.3.3 The Architectural Rule: Stateless Design

This section explains why cloud applications keep state off disposable servers and how that choice enables resilience, scaling, and reuse of existing architectural patterns.

Key terms: Stateless, externalize its state, local server, managed Database, Object Store, Pets vs. Cattle, Scalability, Reliability, Load Balancer, consumers

9.4 The Compute Spectrum: Control vs. Convenience

Introduces cloud compute choices as a spectrum between control over the environment and convenience provided by the cloud provider.

Key terms: compute spectrum, control, convenience, underlying environment

9.4.1 1. The "Do It Yourself" Model: Virtual Machines (IaaS)

Explains what a cloud virtual machine leaves you responsible for, the control and cost tradeoffs, and when raw IaaS is a defensible choice.

Key terms: Infrastructure as a Service (IaaS), Virtual Machines, hypervisor, root access, Absolute Control, 3:00 AM Tax, Lift and Shift, Pet, Commercial Off-The-Shelf (COTS), raw IaaS

9.4.2 2. The Sweet Spot: Containers (CaaS)

Explains how Containers as a Service packages applications into repeatable images, what the provider and developer each manage, and when its portability is worth its operational overhead.

Key terms: Containers as a Service (CaaS), Image, runtime, dependencies, Absolute Portability, Orchestration Overhead, Kubernetes, Microservices Architectures, Polyglot Environments, Cloud Agnosticism

9.4.3 3. The "Just Run My Code" Model: Platform as a Service (PaaS)

This section explains how PaaS runs application code without requiring teams to manage servers, and when that convenience is worth its constraints.

Key terms: PaaS, application code, environment variables, basic scaling rules, Developer Velocity, Black Box Trap, OS security patches, Startups and MVPs, Standard Web Apps, Zero-Ops Teams

9.4.4 4. The Ultimate Abstraction: Serverless (Faas)

Explains how serverless functions run on demand, what control and code constraints that entails, and when its scaling and pricing tradeoffs make it useful.

Key terms: Functions-as-a-Service (FaaS), Serverless, trigger, temporary environment, scale down to zero, Cold Start, temporary clones, zero local state, strict time limit, Unpredictable, Spiky Traffic

9.4.5 5. The New Frontier: AI as a Service (AIaaS)

This section explains what AI as a Service abstracts, when its tradeoffs make it useful, and why factual answers need database-grounded RAG.

Key terms: AIaaS, prompt, payload, API endpoint, nondeterministic, unstructured data parsing, natural language interfaces, generative workflows, deterministic storage engine, probabilistic prediction engine

9.4.6 How the Architect Chooses

This section shows how to choose a cloud compute model by matching a project's constraints to the balance of control and convenience each option offers.

Key terms: Control, Convenience, tradeoffs, IaaS, Virtual Machines, CaaS, Containers/Docker, PaaS, Managed Platforms

9.5 Spotlight: Serverless In-Action

Contrasts moving an application to a cloud VM or container with adopting serverless, explaining why serverless requires architectural changes.

Key terms: Serverless (FaaS), Infrastructure change, Architectural shift

9.5.1 Event-Driven by Default

This section contrasts always-running applications with serverless functions that run in response to events, then describes a function’s short-lived execution and billing model.

Key terms: Serverless Function, Event, Function-as-a-Service, statelessness

9.5.2 How Serverless Changes Your Code (The Rules of the Road):

This section explains three coding constraints imposed by serverless functions: statelessness, execution time limits, and cold starts.

Key terms: No Luggage, Strict Statelessness, external database, Short Fuse, Time Limits, bite-sized pieces, Fast Ignition, Cold Start, external dependencies, deployment package

9.5.3 The Serverless Sweet Spots: A Deeper Look

Identifies workloads where serverless functions fit well: traffic spikes, scheduled or event-driven work, shared utilities, and background compute.

Key terms: Serverless, Spiky API, Nightly Janitor, Cron Jobs, Cloud Glue, Webhooks & Triggers, Message Courier, Consumers, message queue, Shared Utility

9.5.4 Serverless and the "-ilities"

This section explains how serverless can improve user experience and reduce idle infrastructure costs while sacrificing portability.

Key terms: Serverless, Usability, Affordability, ephemeral cloud functions, Portability, vendor lock-in, proprietary event triggers, security roles, core routing logic

9.5.5 The Next Challenge: Escaping the Dashboard

The section explains why provisioning a complex cloud environment by manually clicking through a provider’s dashboard is a mistake and calls for a code-based approach instead.

Key terms: provisioning, cloud provider's website, stop clicking and start coding

9.6 Infrastructure as Code (IaC): Defeating the "ClickOps" Anti-Pattern

The section identifies manual cloud-console resource creation as ClickOps and warns against using it to build infrastructure.

Key terms: ClickOps, Create Resource

9.6.1 The "Snowflake" Server and “The Curse of ClickOps”

This section explains why manually configuring cloud infrastructure creates servers that are hard to reproduce and environments that drift apart.

Key terms: ClickOps, Snowflake Server, Configuration Drift, Staging, Production

9.6.2 The Solution: Infrastructure as Code (IaC)

This section introduces Infrastructure as Code as a version-controlled, declarative alternative to manually configuring cloud infrastructure.

Key terms: Infrastructure as Code (IaC), Git, deployment engine, ClickOps, Imperative, Declarative, desired end state, IaC engine, Terraform, HCL

9.6.3 The Superpowers of IaC

This section explains three benefits of infrastructure as code: reviewed changes, repeatable environments, and faster disaster recovery.

Key terms: IaC, Git, Pull Request, Peer Review for Servers, Perfect Replication, Staging, Production, Terraform file, configuration drift, Disaster Recovery as a Keystroke

9.7 Infrastructure as Code in Practice: The Declarative Blueprint

Introduces Terraform as a declarative infrastructure blueprint and explains, at a high level, how its state file helps keep deployed infrastructure aligned with that blueprint.

Key terms: Terraform, Infrastructure as Code (IaC), Declarative Blueprint, HashiCorp Configuration Language (HCL), Imperative, State File, digital memory bank

9.7.1 The Architect's Infrastructure Review

This section shows architects how to review cloud infrastructure for alignment with the design, ongoing cost, identity boundaries, and dangerous deployment changes.

Key terms: infrastructure code, configuration files, structural blueprint, Operating Expense, provisioned, cloud bill, FinOps, Identity, Authentication, Authorization

9.7.2 The Digital Memory Bank: The State File

Explains how Terraform uses a state file to compare infrastructure code with existing cloud resources and make only the changes needed.

Key terms: Terraform, State File, three-way comparison, Your Code, The Real Cloud

9.7.3 The Danger: The Single Point of Failure

This section explains how lost or conflicting Terraform state can endanger infrastructure, and how remote state, locking, modules, and secure storage reduce those risks.

Key terms: State File, terraform.tfstate, single point of failure, Remote State, State Locking, Separation of Concerns, Modules, .gitignore, secure remote storage backend

9.8 The Immutable Infrastructure Mindset

This section introduces the need to rethink server management when Infrastructure as Code makes rapid provisioning possible, without yet explaining the immutable infrastructure mindset.

9.8.1 The Developer's Parallel: Variables vs. Constants

This subsection uses mutable and immutable code objects to explain why cloud architects should not allow manual changes to live servers, including the predictability and peace of mind that result.

Key terms: Mutable, Immutable, server, live production server, undocumented change, unpredictable server states

9.8.2 Never Patch a Live Server

Explains why live servers should be replaced rather than patched, and how an immutable deployment can switch traffic safely to a new version.

Key terms: Immutable Infrastructure, Configuration Drift, Snowflake, immutable deployment pipeline, Terraform (IaC), Dockerfile, Blue-Green Deployment, Blue environment, Green environment

9.8.3 Why Architects Demand Immutability

This section explains why architects favor immutable application infrastructure, where that rule stops, and how to begin applying it to a staging server.

Key terms: immutability, Zero Configuration Drift, Snowflake Server, blueprint, Trivial Rollbacks, Security by Destruction, load balancer, old, frozen server, Stateful Databases, Application Layer

9.9 The Dork Side: "Friends Don't Let Friends Type in Production" (The AWS S3 Outage)

The 2017 AWS S3 outage illustrates how a mistyped production command can cascade through cloud services and why infrastructure changes need reviewable safeguards.

Key terms: ClickOps, production terminal, Infrastructure as Code (IaC), cascading failure, checkpoint, architectural red flag, safe, repeatable reviews

9.10 Your "In Action" Mission: Scaffolding a Service

This section asks readers to sketch cloud resources for a recommendation service and explains why shared cloud infrastructure requires planning for unpredictable conditions.

Key terms: Terraform, HCL, resource blocks, backend API, in-memory cache, secure bucket, Noisy Neighbor, shared, private hardware

9.11 Checklist

This checklist prompts readers to recall cloud architecture concepts covered earlier in the chapter without explaining them in this section.

9.12 Recap

The recap ties cloud-ready application design, compute and cost tradeoffs, and automated infrastructure management into a set of architectural takeaways.

Key terms: Pets, Cattle, Statelessness, Compute Spectrum, IaaS, CaaS, PaaS, FaaS, AIaaS, ClickOps

Where this is used later

Concepts explained in this chapter

← Chapter 8: The Database as an Architectural Pillar: Choosing Between Strict Order and Massive Scale Chapter 10: Architecting for Resilience and Scale: Preparing for the Worst, Scaling for the Best →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.