Chapter 9: Architecting for the Cloud: Trading Pets for Cattle and Concrete for Code
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
- Local Success Versus Deployment. Explain why code that passes tests on a developer’s machine may still fail after deployment, and why architecture must account for the environment where the software actually runs.
- Public Cloud Multi-Tenancy. Explain that the public cloud runs in providers’ data centers and that customers generally rent private space on shared physical hardware, not an entire machine.
- Noisy Neighbor Performance Risk. Explain how another tenant’s heavy use of shared resources can slow an application even when its code is well written.
- Cloud Migration Versus Cloud Architecture. Distinguish moving an application to a cloud server from designing for the cloud. Explain why treating cloud hardware as temporary and disposable calls for a different architectural mindset.
- Infrastructure as Code Mindset. Explain what Infrastructure as Code is and how it replaces manual, one-off server setup with a repeatable workflow. Describe the section’s suggested first step for practicing that mindset.
- Cloud infrastructure tradeoffs. Explain how moving from on-premises servers to rented cloud compute changes an architect’s tradeoffs. Distinguish the predictable environment and scalability ceiling of fixed hardware from the cloud’s flexibility, operational complexity, and potential for higher costs.
- Usage based elastic design. Explain why usage-based cloud billing calls for a system that can expand and contract, rather than merely relocating a rigid on-premises design.
- First Terraform cloud experiment. Describe how to start a small Infrastructure as Code experiment and why the section recommends Terraform for a first project.
- Cloud practice cost controls. Explain why cost must be treated as an architectural constraint in cloud practice and name the safeguards the section recommends.
- Server loss and state. Explain how deleting a server tests cloud readiness: if locally stored images or sessions disappear with it, the application is stateful and not yet cloud-native.
- Manual patches and drift. Describe how logging in to a server to fix a vulnerability exposes a cloud-readiness problem: manual patches can leave servers configured differently and hard to reproduce.
- Single-zone outage exposure. Explain why running the entire application in one availability zone fails the meteor test: an outage at that physical location can take the whole business offline.
- Pet Server Model Origins. Explain why early servers were treated like pets: acquiring and setting up physical hardware took substantial time, money, and manual effort, so teams treated individual machines as valuable and even named them.
- Hand-Configured Server Recovery. Explain why a pet server is difficult to replace when it fails completely. Describe the effect on the application and users.
- Local State Loss. Explain what it means for a pet server to be stateful and what happens to its locally stored information if the server dies.
- Disposable cloud server model. Explain why cloud servers are treated as cattle and what happens when one fails.
- State Outside Disposable Servers. Explain why a cloud server must not hold unique data, and describe where an application should put that data instead.
- Interchangeable Servers and Elastic Scale. Explain how externalizing state lets identical servers handle requests or queued messages, scale up for a surge, and disappear afterward.
- Cloud compute control tradeoff. Explain how choosing where to run code in the cloud trades control over the environment for convenience and reduced maintenance work.
- IaaS responsibility boundary. Explain what the cloud provider manages for a virtual machine and what the customer must manage.
- VM control and operating costs. Describe the control a VM provides and the maintenance and billing costs that accompany it.
- Appropriate virtual machine use cases. Justify when a VM is appropriate despite the advice against starting most new projects on raw IaaS.
- Container images and responsibilities. Explain what goes into a container image and how responsibilities are divided in CaaS. Describe why containers started from one image are identical.
- Portability and orchestration tradeoff. Explain why containers are presented as a compromise between control and convenience, including their portability benefit and the costs of operating a fleet.
- PaaS responsibility boundary. Explain what a team provides to a PaaS provider, what the provider handles, and how this differs from managing virtual machines or containers.
- PaaS convenience tradeoff. Explain why PaaS can speed up deployment and why its hidden infrastructure can become a constraint.
- On-Demand Function Execution. Explain what serverless FaaS abstracts away and trace what happens when a function is triggered.
- Scaling Cost and Cold Starts. Explain how scaling to zero and running temporary copies affect serverless cost, burst handling, and response time.
- Serverless Code Constraints. Describe why adopting serverless changes application code rather than only its hosting.
- AIaaS abstraction and request. Explain how AIaaS goes beyond serverless by abstracting the problem-solving logic as well as the hardware, and describe what an application sends to the managed model.
- AIaaS suitability and tradeoffs. Justify when AIaaS is a good architectural choice and when it is not, using its capabilities, response variability, and cost.
- AI model versus database. Distinguish an AI model’s probabilistic answers from a database’s retrieval of stored data, and explain the resulting risk for factual questions.
- RAG factual grounding flow. Trace how Retrieval-Augmented Generation combines database retrieval with AI generation to reduce hallucinations.
- Control and convenience tradeoff. Explain why no cloud deployment model is universally best and how a project's needs and constraints shape the choice.
- Compute model decision cues. Apply the section's quick-decision guide to match four stated needs with IaaS, CaaS, PaaS, or FaaS.
- Serverless as an architectural shift. Explain why moving an application to serverless requires more than the infrastructure change of moving it to a cloud VM or container.
- Event-Triggered Serverless Code. Distinguish a serverless function from an application on a virtual machine or in a container: the cloud provider listens for events, while the function remains dormant until triggered.
- Short-Lived Function Execution. Trace what happens when an event triggers a serverless function, including the temporary execution environment, its destruction afterward, and billing for active running time.
- Stateless Function Data Handling. Explain why serverless code cannot rely on local files or global variables to retain important data between runs, and where it should save that data instead.
- Function Execution Time Limits. Explain how a hard execution limit affects the choice and design of serverless workloads.
- Cold Start Dependency Costs. Explain what causes a serverless cold start and how the section says to reduce its delay.
- Burst and Schedule Economics. Explain why serverless suits an API with sharp traffic spikes and a short nightly job: capacity is available when needed without paying to keep a virtual machine running through idle periods.
- Event Reactions and Queue Consumers. Describe how a serverless function can react to a trigger, such as a new user being added, or consume queued requests; explain how functions process a surge in parallel and disappear when the queue empties.
- Background Compute Offload. Explain why a heavy task can be moved to a background serverless function rather than run synchronously on a mobile device or the primary web server.
- Serverless usability and affordability. Explain how offloading work to ephemeral cloud functions can keep the user's device responsive while avoiding the cost of servers running continuously for occasional heavy tasks.
- Serverless portability tradeoff. Explain why the section treats serverless convenience as a portability tradeoff, including what makes a move to another cloud provider or backend language difficult.
- Cloud Provisioning at Scale. Explain why manually creating cloud resources through a provider’s website becomes a poor approach as an architecture grows, and state the section’s recommended shift.
- Manual provisioning and ClickOps. Describe ClickOps as creating cloud resources through a provider’s web portal by clicking through setup screens, and state that the section warns against this approach.
- Snowflake servers from ClickOps. Explain how configuring infrastructure through a web interface can create a Snowflake Server and why that makes rebuilding or scaling unreliable.
- Configuration drift across environments. Describe how forgotten manual settings and changing cloud interfaces lead to configuration drift between intended, staging, and production setups.
- Infrastructure as Code workflow. Explain that Infrastructure as Code describes desired infrastructure in text, stores it in Git, and uses a deployment engine to build it rather than relying on manual portal clicks.
- Imperative and declarative thinking. Distinguish ClickOps’ step-by-step instructions from IaC’s declaration of a desired final state, and explain what the IaC engine does with that declaration.
- Peer Review for Infrastructure. Explain how storing infrastructure definitions as code lets developers review proposed cloud changes before they go live, reducing configuration mistakes and self-inflicted outages.
- Repeatable Staging Environments. Describe how an IaC definition can be used to create a staging environment matching production, avoiding manual setup and configuration drift.
- Infrastructure Disaster Recovery. Explain how an IaC definition helps rebuild infrastructure after a catastrophic deletion and why that improves recovery compared with manual ClickOps.
- Declarative Terraform blueprints. Explain how Terraform lets an architect describe desired cloud infrastructure in HCL rather than write provider-specific API calls or imperative setup logic. Compare this to declaring the desired result in SQL and letting an engine work out how to achieve it.
- Cloud Cost as Constraint. Explain why cloud cost must be considered from the start of an architectural decision, using the section’s examples of provisioned capacity and runaway activity.
- Identity and Access Boundaries. Distinguish authentication from authorization and describe how least privilege should shape a cloud service’s credentials and permissions.
- Execution Plan Safety Check. Describe how to inspect an IaC execution plan before applying a change and what to do if it proposes destroying a critical resource.
- State File Reconciliation. Explain how Terraform uses a state file alongside the code and the real cloud to decide what, if anything, to change when infrastructure code runs again.
- State File Failure Risk. Explain why losing a local Terraform state file can cause Terraform to create duplicate resources and leave existing ones unmanaged, and how remote state reduces that risk.
- Concurrent Deployment Protection. Explain why simultaneous deployments using local state can conflict and how remote state locking coordinates them.
- Immutable Servers as Objects. Explain the parallel between mutable and immutable code objects and server states: mutable objects can be changed after creation, while an immutable object's update means creating a new one. Apply that parallel to the old practice of patching a live server and the cloud-era rule against it.
- Immutable servers and configuration drift. Explain why immutable infrastructure forbids modifying a deployed server or container, and how live patches create configuration drift.
- Replacement deployment sequence. Trace how an immutable deployment updates a server without changing the live instance.
- Blue-green traffic switch and rollback. Describe the Blue and Green environments and explain how switching traffic between them makes a release safer.
- Predictability Without Configuration Drift. Explain how preventing manual server changes keeps staging and production built from the same blueprint, even when their environment settings or instance sizes differ.
- Rollback and Security Benefits. Describe how keeping an old server available simplifies rollback, and how automatically replacing servers removes malicious changes on a breached server.
- Stateful Database Exception. Distinguish the immutable, stateless application layer from the persistent data layer, explaining why a live production database cannot simply be destroyed and rebuilt.
- Production Typo and Cloud Outage. Trace how a mistyped command during a live production change caused a widespread S3 outage, and explain why the section favors Infrastructure as Code over typing directly in production.
- Recommendation Service Resource Blueprint. Describe the three kinds of resources the Shop-Zilla Recommendation Engine needs and how they would be represented in a Terraform blueprint, without needing exact HCL syntax.
- Shared Cloud Unpredictability. Explain what predictability the service gives up by moving to shared cloud infrastructure and name the kinds of disruption the section highlights.
- Replaceable and stateless servers. Explain why cloud-ready servers should be replaceable and applications stateless: session data and files belong in external storage so any server can handle a request.
- Compute control and cost tradeoffs. Describe how cloud compute choices trade control for convenience, and explain why the ongoing cloud bill must be treated as an architectural constraint.
- Reproducible and immutable infrastructure. Explain how Infrastructure as Code replaces manual configuration with declarative, version-controlled blueprints, and describe why state management and replacement images matter.
What it builds on
- Step 3: The Sketch (The "How") (chapter 1) · Introduces weighing architectural options and tradeoffs.
- The Event Lifecycle (chapter 7) · Queued messages provide the work that multiple consumers can process.
- Inside, Ports, and Adapters (chapter 5) · Ports and adapters separate core logic from infrastructure implementations.
- API as a Public Contract (chapter 6) · An API defines how clients communicate with the server.
- The AI Revolution: Vector Databases (chapter 8) · The earlier introduction of vector databases as a data-model option.
- The Distribution Patterns: Queue vs. Topic (chapter 7) · The distinction between queued messages and their consumers.
- The “-ilities”: Your Vocabulary of Quality (chapter 2) · The architectural “-ilities” used to evaluate a choice.
- Declarative Querying (The Universal Standard) (chapter 8) · Introduces declarative querying as a way to specify a result without prescribing every step.
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.
- Local Success Versus Deployment: Explain why code that passes tests on a developer’s machine may still fail after deployment, and why architecture must account for the environment where the software actually runs.
Why it matters: It shifts your attention from whether code works locally to whether the application can run in its intended environment.
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.
- Public Cloud Multi-Tenancy: Explain that the public cloud runs in providers’ data centers and that customers generally rent private space on shared physical hardware, not an entire machine.
Why it matters: Recognizing shared hardware gives you a more realistic picture of what a cloud provider supplies. - Noisy Neighbor Performance Risk: Explain how another tenant’s heavy use of shared resources can slow an application even when its code is well written.
Why it matters: A slowdown in the cloud is not necessarily a problem in your application’s code.
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.
- Cloud Migration Versus Cloud Architecture: Distinguish moving an application to a cloud server from designing for the cloud. Explain why treating cloud hardware as temporary and disposable calls for a different architectural mindset.
Why it matters: A cloud bill alone does not tell you whether an application can benefit from cloud architecture. - Infrastructure as Code Mindset: Explain what Infrastructure as Code is and how it replaces manual, one-off server setup with a repeatable workflow. Describe the section’s suggested first step for practicing that mindset.
Why it matters: Treating infrastructure like application code makes environments reproducible rather than dependent on remembered manual steps.
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.
- Cloud infrastructure tradeoffs: Explain how moving from on-premises servers to rented cloud compute changes an architect’s tradeoffs. Distinguish the predictable environment and scalability ceiling of fixed hardware from the cloud’s flexibility, operational complexity, and potential for higher costs.
Why it matters: Cloud decisions are architectural tradeoffs, not just deployment choices. - Usage based elastic design: Explain why usage-based cloud billing calls for a system that can expand and contract, rather than merely relocating a rigid on-premises design.
Why it matters: A cloud migration must account for how the system responds to changing demand and usage costs. - Infrastructure as documented requirements: Describe the architectural role assigned here to Infrastructure as Code: keeping the system’s required environment documented in the codebase rather than treating infrastructure as separate from design.
Why it matters: Recording environment requirements makes infrastructure part of the architectural decision rather than an undocumented afterthought.
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.
- First Terraform cloud experiment: Describe how to start a small Infrastructure as Code experiment and why the section recommends Terraform for a first project.
Why it matters: Starting with one small resource makes cloud architecture something you can practice rather than just read about. - Safe practice and correction: Explain how to practice cloud architecture with limited risk and what the section says to do after an accidental deletion in the code.
Why it matters: A low-risk place to experiment makes mistakes part of learning rather than a reason not to start. - Cloud practice cost controls: Explain why cost must be treated as an architectural constraint in cloud practice and name the safeguards the section recommends.
Why it matters: A small learning experiment can still cost money if its resources are left running.
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.
- Server loss and state: Explain how deleting a server tests cloud readiness: if locally stored images or sessions disappear with it, the application is stateful and not yet cloud-native.
Why it matters: The wipeout question reveals whether losing one server also means losing data. - Manual patches and drift: Describe how logging in to a server to fix a vulnerability exposes a cloud-readiness problem: manual patches can leave servers configured differently and hard to reproduce.
Why it matters: The midnight-patch question spots a fragile habit even when the application runs in the cloud. - Single-zone outage exposure: Explain why running the entire application in one availability zone fails the meteor test: an outage at that physical location can take the whole business offline.
Why it matters: The meteor question shows that cloud hosting alone does not remove a single physical point of failure.
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.
- Pet Server Model Origins: Explain why early servers were treated like pets: acquiring and setting up physical hardware took substantial time, money, and manual effort, so teams treated individual machines as valuable and even named them.
Why it matters: It gives you the starting point for understanding why treating every server as special became an architectural concern.
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.
- Hand-Configured Server Recovery: Explain why a pet server is difficult to replace when it fails completely. Describe the effect on the application and users.
Why it matters: A server that must be nursed back to health or rebuilt by hand can turn one failure into a prolonged outage. - Local State Loss: Explain what it means for a pet server to be stateful and what happens to its locally stored information if the server dies.
Why it matters: A pet server’s failure can mean lost data, not just an unavailable application.
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.”
- Disposable cloud server model: Explain why cloud servers are treated as cattle and what happens when one fails.
Why it matters: Treating servers as replaceable changes how you respond when one stops working.
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.
- State Outside Disposable Servers: Explain why a cloud server must not hold unique data, and describe where an application should put that data instead.
Why it matters: A disposable server is safe to replace only when its loss does not also lose user data. - Interchangeable Servers and Elastic Scale: Explain how externalizing state lets identical servers handle requests or queued messages, scale up for a surge, and disappear afterward.
Why it matters: Interchangeable instances let the system absorb a surge without committing to permanent servers. - Existing Patterns in Cloud Design: Describe how statelessness works with, rather than replaces, earlier architectural patterns, using examples from this section.
Why it matters: Cloud readiness builds on familiar design boundaries instead of requiring a wholly new application architecture.
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.
- Cloud compute control tradeoff: Explain how choosing where to run code in the cloud trades control over the environment for convenience and reduced maintenance work.
Why it matters: This tradeoff gives you a way to reason about cloud services before comparing specific offerings.
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.
- IaaS responsibility boundary: Explain what the cloud provider manages for a virtual machine and what the customer must manage.
Why it matters: A cloud VM does not transfer responsibility for running the software stack to the provider. - VM control and operating costs: Describe the control a VM provides and the maintenance and billing costs that accompany it.
Why it matters: The freedom to customize a VM comes with work and charges that continue after deployment. - Appropriate virtual machine use cases: Justify when a VM is appropriate despite the advice against starting most new projects on raw IaaS.
Why it matters: A VM can solve a real migration or compatibility constraint without being mistaken for architectural modernization.
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.
- Container images and responsibilities: Explain what goes into a container image and how responsibilities are divided in CaaS. Describe why containers started from one image are identical.
Why it matters: This division of responsibility explains what you actually deliver to a container service. - Portability and orchestration tradeoff: Explain why containers are presented as a compromise between control and convenience, including their portability benefit and the costs of operating a fleet.
Why it matters: Portability does not eliminate the work or cost of running containers at scale. - Suitable container deployment scenarios: Describe the situations this section gives as good fits for CaaS and relate them to standardized container deployment.
Why it matters: These examples show when container standardization provides a practical architectural benefit.
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.
- PaaS responsibility boundary: Explain what a team provides to a PaaS provider, what the provider handles, and how this differs from managing virtual machines or containers.
Why it matters: The division of responsibility tells you what work PaaS removes from your team. - PaaS convenience tradeoff: Explain why PaaS can speed up deployment and why its hidden infrastructure can become a constraint.
Why it matters: Fast deployment is valuable only if the platform's restrictions fit the application and the team's plans. - PaaS fit and prerequisites: Describe the applications and teams this section presents as good PaaS candidates, and state the application properties it calls for.
Why it matters: These conditions help you recognize when PaaS's speed is a good match rather than a costly restriction.
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.
- On-Demand Function Execution: Explain what serverless FaaS abstracts away and trace what happens when a function is triggered.
Why it matters: This distinguishes giving the cloud a function to run from managing a permanent host yourself. - Scaling Cost and Cold Starts: Explain how scaling to zero and running temporary copies affect serverless cost, burst handling, and response time.
Why it matters: The same scale-to-zero behavior that avoids idle-server costs can make the first request slower. - Serverless Code Constraints: Describe why adopting serverless changes application code rather than only its hosting.
Why it matters: A workload cannot be judged suitable for FaaS by hosting cost alone; its code must fit the execution model. - Suitable Serverless Workloads: Describe the workloads the section identifies as good serverless candidates and why they fit.
Why it matters: These examples connect serverless’s pricing and startup tradeoffs to practical workload choices.
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.
- AIaaS abstraction and request: Explain how AIaaS goes beyond serverless by abstracting the problem-solving logic as well as the hardware, and describe what an application sends to the managed model.
Why it matters: It clarifies what work your application hands to the provider—and what you no longer have to code yourself. - AIaaS suitability and tradeoffs: Justify when AIaaS is a good architectural choice and when it is not, using its capabilities, response variability, and cost.
Why it matters: Choosing AIaaS for the right tasks avoids relying on variable, costly answers where exact results are required. - AI model versus database: Distinguish an AI model’s probabilistic answers from a database’s retrieval of stored data, and explain the resulting risk for factual questions.
Why it matters: Treating generated text as retrieved fact can make a confident-sounding error look trustworthy. - RAG factual grounding flow: Trace how Retrieval-Augmented Generation combines database retrieval with AI generation to reduce hallucinations.
Why it matters: RAG gives the model evidence to work from instead of asking it to remember facts unaided.
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.
- Control and convenience tradeoff: Explain why no cloud deployment model is universally best and how a project's needs and constraints shape the choice.
Why it matters: It keeps you from treating a popular deployment model as the right choice for every project. - Compute model decision cues: Apply the section's quick-decision guide to match four stated needs with IaaS, CaaS, PaaS, or FaaS.
Why it matters: These cues give you a fast starting point for comparing deployment options against a project's needs.
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.
- Serverless as an architectural shift: Explain why moving an application to serverless requires more than the infrastructure change of moving it to a cloud VM or container.
Why it matters: It explains why serverless cannot be treated as merely a new place to run unchanged code.
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.
- Event-Triggered Serverless Code: Distinguish a serverless function from an application on a virtual machine or in a container: the cloud provider listens for events, while the function remains dormant until triggered.
Why it matters: This distinction explains why serverless code is written as a reaction to an event rather than as a continuously running listener. - Short-Lived Function Execution: Trace what happens when an event triggers a serverless function, including the temporary execution environment, its destruction afterward, and billing for active running time.
Why it matters: The function’s temporary lifetime explains the section’s statelessness requirement and active-time billing.
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.
- Stateless Function Data Handling: Explain why serverless code cannot rely on local files or global variables to retain important data between runs, and where it should save that data instead.
Why it matters: Treating each run as independent prevents the application from depending on data that may disappear. - Function Execution Time Limits: Explain how a hard execution limit affects the choice and design of serverless workloads.
Why it matters: A task that exceeds the limit can stop before it finishes. - Cold Start Dependency Costs: Explain what causes a serverless cold start and how the section says to reduce its delay.
Why it matters: Startup work can delay a request before the function does its useful work.
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.
- Burst and Schedule Economics: Explain why serverless suits an API with sharp traffic spikes and a short nightly job: capacity is available when needed without paying to keep a virtual machine running through idle periods.
Why it matters: Matching compute costs to when work actually happens can make irregular workloads a strong serverless fit. - Event Reactions and Queue Consumers: Describe how a serverless function can react to a trigger, such as a new user being added, or consume queued requests; explain how functions process a surge in parallel and disappear when the queue empties.
Why it matters: This makes serverless useful for reactions between services and for temporary surges of queued work. - One Shared Serverless Utility: Explain how several applications can call one serverless function for shared functionality instead of each deploying its own copy, using the sales-tax or shared UI-component example.
Why it matters: A shared function can keep common functionality in one deployable place. - Background Compute Offload: Explain why a heavy task can be moved to a background serverless function rather than run synchronously on a mobile device or the primary web server.
Why it matters: Moving costly work away from the interactive path helps prevent a frozen app or a slowed website.
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.
- Serverless usability and affordability: Explain how offloading work to ephemeral cloud functions can keep the user's device responsive while avoiding the cost of servers running continuously for occasional heavy tasks.
Why it matters: It connects a compute choice to both the user's experience and the business's idle costs. - Serverless portability tradeoff: Explain why the section treats serverless convenience as a portability tradeoff, including what makes a move to another cloud provider or backend language difficult.
Why it matters: The convenience and cost gains are harder to judge without accounting for the cost of changing platforms later.
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.
- Cloud Provisioning at Scale: Explain why manually creating cloud resources through a provider’s website becomes a poor approach as an architecture grows, and state the section’s recommended shift.
Why it matters: The way you create cloud resources must remain manageable as the number and variety of those resources grow.
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.
- Manual provisioning and ClickOps: Describe ClickOps as creating cloud resources through a provider’s web portal by clicking through setup screens, and state that the section warns against this approach.
Why it matters: It gives you a name for the manual setup approach the chapter cautions against.
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.
- Snowflake servers from ClickOps: Explain how configuring infrastructure through a web interface can create a Snowflake Server and why that makes rebuilding or scaling unreliable.
Why it matters: If you cannot reproduce a server reliably, a failure or traffic spike becomes much harder to handle. - Configuration drift across environments: Describe how forgotten manual settings and changing cloud interfaces lead to configuration drift between intended, staging, and production setups.
Why it matters: Configuration drift makes it difficult to trust that staging matches production or that production matches the intended setup.
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.
- Infrastructure as Code workflow: Explain that Infrastructure as Code describes desired infrastructure in text, stores it in Git, and uses a deployment engine to build it rather than relying on manual portal clicks.
Why it matters: It gives you a way to describe cloud infrastructure without depending on a sequence of manual clicks. - Imperative and declarative thinking: Distinguish ClickOps’ step-by-step instructions from IaC’s declaration of a desired final state, and explain what the IaC engine does with that declaration.
Why it matters: This distinction changes what you write: the target infrastructure, not instructions for every cloud operation. - Terraform and HCL distinction: Distinguish Terraform, the executable engine that talks to a cloud provider’s API, from HCL, the syntax used to write blueprints that Terraform reads.
Why it matters: Keeping the tool separate from its configuration syntax makes discussions of IaC more precise.
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.
- Peer Review for Infrastructure: Explain how storing infrastructure definitions as code lets developers review proposed cloud changes before they go live, reducing configuration mistakes and self-inflicted outages.
Why it matters: Reviewing infrastructure changes can prevent an avoidable production outage. - Repeatable Staging Environments: Describe how an IaC definition can be used to create a staging environment matching production, avoiding manual setup and configuration drift.
Why it matters: A quickly reproduced test environment lets teams test and ship without waiting for manual infrastructure setup. - Infrastructure Disaster Recovery: Explain how an IaC definition helps rebuild infrastructure after a catastrophic deletion and why that improves recovery compared with manual ClickOps.
Why it matters: The ability to rebuild infrastructure quickly can make a catastrophic failure survivable.
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.
- Declarative Terraform blueprints: Explain how Terraform lets an architect describe desired cloud infrastructure in HCL rather than write provider-specific API calls or imperative setup logic. Compare this to declaring the desired result in SQL and letting an engine work out how to achieve it.
Why it matters: Reading the desired infrastructure is more useful to an architect than memorizing cloud-provider commands. - State file synchronization role: Describe why Terraform keeps a State File and how it uses that record when bringing real infrastructure into line with the code.
Why it matters: The state file explains how Terraform can update existing infrastructure instead of treating every blueprint as a fresh build.
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.
- Infrastructure Review Responsibility: Explain why an architect must be able to read infrastructure configuration, whether writing it or reviewing a teammate’s change.
Why it matters: A design is only useful if the infrastructure that gets deployed reflects it. - Cloud Cost as Constraint: Explain why cloud cost must be considered from the start of an architectural decision, using the section’s examples of provisioned capacity and runaway activity.
Why it matters: An otherwise effective cloud design can produce an unsustainable bill. - Identity and Access Boundaries: Distinguish authentication from authorization and describe how least privilege should shape a cloud service’s credentials and permissions.
Why it matters: Narrow access limits how far an attacker can reach if one service is compromised. - Execution Plan Safety Check: Describe how to inspect an IaC execution plan before applying a change and what to do if it proposes destroying a critical resource.
Why it matters: Reading the plan can reveal a destructive change before it reaches production.
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.
- State File Reconciliation: Explain how Terraform uses a state file alongside the code and the real cloud to decide what, if anything, to change when infrastructure code runs again.
Why it matters: This explains why rerunning an infrastructure file does not automatically create duplicate resources.
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.
- State File Failure Risk: Explain why losing a local Terraform state file can cause Terraform to create duplicate resources and leave existing ones unmanaged, and how remote state reduces that risk.
Why it matters: A lost state file can put real infrastructure outside the automated pipeline's control. - Concurrent Deployment Protection: Explain why simultaneous deployments using local state can conflict and how remote state locking coordinates them.
Why it matters: Locking keeps teammates' infrastructure changes from colliding. - Modular Infrastructure Risk Boundaries: Describe how splitting infrastructure code into modules contains the effects of a mistaken change while allowing modules to exchange needed information.
Why it matters: Module boundaries help keep a change to one part of the infrastructure from affecting another. - Sensitive State File Handling: Explain why Terraform state needs protection and state the handling precautions given for sharing it with a team.
Why it matters: Protecting state helps prevent infrastructure credentials from being exposed.
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.
- Immutable Servers as Objects: Explain the parallel between mutable and immutable code objects and server states: mutable objects can be changed after creation, while an immutable object's update means creating a new one. Apply that parallel to the old practice of patching a live server and the cloud-era rule against it.
Why it matters: The object analogy makes clear why a routine-looking live server patch conflicts with immutable infrastructure. - Freedom from Unpredictable Server States: Explain why the section says immutable servers also free an architect's mind: preventing quiet, undocumented production changes removes a source of later surprises and worry.
Why it matters: Predictable server state helps people focus on building and shipping instead of worrying about hidden changes.
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.
- Immutable servers and configuration drift: Explain why immutable infrastructure forbids modifying a deployed server or container, and how live patches create configuration drift.
Why it matters: Replacing rather than hand-editing servers keeps their configurations reproducible. - Replacement deployment sequence: Trace how an immutable deployment updates a server without changing the live instance.
Why it matters: A replacement can be built from its source rather than depending on undocumented changes to a running machine. - Blue-green traffic switch and rollback: Describe the Blue and Green environments and explain how switching traffic between them makes a release safer.
Why it matters: Keeping the previous version untouched gives a release a quick way back if the replacement fails.
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.
- Predictability Without Configuration Drift: Explain how preventing manual server changes keeps staging and production built from the same blueprint, even when their environment settings or instance sizes differ.
Why it matters: A shared blueprint makes differences between environments more predictable instead of leaving them to undocumented server tweaks. - Rollback and Security Benefits: Describe how keeping an old server available simplifies rollback, and how automatically replacing servers removes malicious changes on a breached server.
Why it matters: Replacing servers makes both recovery from a bad release and removal of a server-level backdoor less dependent on manually undoing changes. - Stateful Database Exception: Distinguish the immutable, stateless application layer from the persistent data layer, explaining why a live production database cannot simply be destroyed and rebuilt.
Why it matters: Applying server replacement indiscriminately to a production database could destroy customer data. - Staging Server Immutability Plan: Outline the section's first-step plan for making one QA or staging server immutable: block direct manual logins, put updates in a fresh image or container, and deploy only through an automated pipeline.
Why it matters: Starting with one non-production server turns the immutable-infrastructure principle into a manageable change.
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.
- Production Typo and Cloud Outage: Trace how a mistyped command during a live production change caused a widespread S3 outage, and explain why the section favors Infrastructure as Code over typing directly in production.
Why it matters: A small manual error can have a large blast radius when other cloud services depend on the affected infrastructure. - Destructive Change Review Checkpoint: Describe the question the section recommends asking before approving an infrastructure change and why that pause is useful.
Why it matters: An explicit deletion check gives reviewers a chance to spot a dangerous change before approving it.
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.
- Recommendation Service Resource Blueprint: Describe the three kinds of resources the Shop-Zilla Recommendation Engine needs and how they would be represented in a Terraform blueprint, without needing exact HCL syntax.
Why it matters: Naming the required resources turns the service idea into a blueprint the DevOps team can act on. - Shared Cloud Unpredictability: Explain what predictability the service gives up by moving to shared cloud infrastructure and name the kinds of disruption the section highlights.
Why it matters: Recognizing these risks gives a reason to design for resilience rather than assuming cloud infrastructure will always behave predictably.
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.
- Replaceable and stateless servers: Explain why cloud-ready servers should be replaceable and applications stateless: session data and files belong in external storage so any server can handle a request.
Why it matters: This is what lets an application replace servers and spread requests across them. - Compute control and cost tradeoffs: Describe how cloud compute choices trade control for convenience, and explain why the ongoing cloud bill must be treated as an architectural constraint.
Why it matters: Choosing a managed service changes both the team's operational work and its ongoing costs. - Reproducible and immutable infrastructure: Explain how Infrastructure as Code replaces manual configuration with declarative, version-controlled blueprints, and describe why state management and replacement images matter.
Why it matters: Automated, recorded changes make environments easier to reproduce and safer for teams to change.
Key terms: Pets, Cattle, Statelessness, Compute Spectrum, IaaS, CaaS, PaaS, FaaS, AIaaS, ClickOps
Where this is used later
- Introduction (chapter 10) · The move from a local application to a cloud environment.
- Introduction (chapter 11) · Introduces the cloud's shared-infrastructure reality.
- Designing for Failure & Resilience Patterns (chapter 10) · Expands on designing systems to withstand failures.
- The Architectural Retrospective: What Went Wrong and How to Prevent It (chapter 13) · treating infrastructure as replaceable cattle rather than individually maintained pets
- Scaling Out (Horizontal Scaling) (chapter 10) · Horizontal scaling builds on the ability to add interchangeable application instances.
- Why The Resilient Way Keeps Production Safe (chapter 10) · Application code can run within cloud-managed infrastructure.
- Designing for Deployability: Why Architecture Dictates Your Release Pipeline (chapter 13) · Provides the single-server VM infrastructure example.
- Scalability (chapter 10) · Provides an example of choosing compute that responds to changing demand.
Concepts explained in this chapter
- infrastructure as codeInfrastructure as Code is the practice of defining and managing infrastructure through machine-readable configuration files rather than manual procedures.
- stateless systemAn architectural approach in which application servers avoid retaining state locally between requests, typically storing necessary state elsewhere.
- TerraformTerraform is an infrastructure-as-code tool that declaratively provisions and manages resources across multiple cloud and infrastructure providers.
- serverless computingA cloud execution model in which the provider manages server infrastructure and allocates resources on demand.
- cloud computingThe on-demand delivery of computing resources and services over a network, typically with scalable provisioning and usage-based billing.
- immutable infrastructureAn operational approach in which deployed infrastructure is changed by rebuilding and replacing instances rather than modifying them in place.
- Terraform state fileA Terraform state file records the resources Terraform manages and maps its configuration to real infrastructure.
- ClickOpsClickOps is the practice of managing infrastructure through manual interactions with graphical or web-based interfaces instead of reproducible automation.
- configuration driftConfiguration drift is the gradual divergence of a system's actual settings from its intended configuration or from the configuration of equivalent environments.
- cold start problemA cold start is the startup latency incurred when a serverless runtime must initialize an execution environment and load function code before handling an invocation.
- platform as a serviceA cloud computing model that provides a managed platform for developing and deploying applications without managing the underlying infrastructure.
- iaasInfrastructure as a service (IaaS) is a cloud model that provides virtualized computing, storage, and networking resources for customers to manage and use.
- ai serviceAI as a service (AIaaS) provides access to AI capabilities through managed cloud services or APIs.
- execution planAn execution plan is the database engine's strategy for executing a query, including the operations and access methods it will perform.
- principle of least privilegeA security principle that grants users, processes, and systems only the permissions necessary for their required functions.
- containerAn isolated, portable execution environment that packages an application with its dependencies while sharing the host operating system kernel.
- object storeAn object store is a persistent storage system that manages data as individually addressable objects with associated metadata.
- lockingA database mechanism that restricts concurrent access to data to protect consistency during operations.
- remote stateRemote state is infrastructure-as-code state stored in shared external storage rather than on an individual operator's local machine.
- virtual machineA virtual machine is a software-defined computer that emulates a physical machine and runs an operating system with allocated virtual resources.
- containers as a serviceContainers as a service (CaaS) is a cloud model that provides managed infrastructure and facilities for deploying and operating containers.
- immutabilityImmutability is a system property in which deployed infrastructure is not modified in place but replaced with a new version when changes are required.
- cloud architectureCloud architecture is an approach to designing software systems to run on elastic, on-demand cloud infrastructure.
- declarative programmingA programming approach that specifies the desired result or state rather than the steps to produce it.
- retrieval-augmented generationRetrieval-augmented generation is an architecture that retrieves relevant external information and supplies it as context to a generative AI model before response generation.
- multitenancyMulti-tenancy is an architecture in which a shared software system serves multiple customers or tenant organizations while maintaining separation of their data and workloads.
- noisy neighbor problemPerformance or availability degradation caused when one tenant consumes resources shared with other tenants.
- container imageA container image is an immutable packaged artifact containing an application and the dependencies needed to run it in a container.
- data layerA data layer isolates data access and persistence operations from other application responsibilities.
- service layerThe architectural layer that coordinates application use cases and orchestrates interactions with domain and infrastructure components.
- blue-green deploymentBlue-green deployment is a release pattern that maintains separate current and replacement environments and switches traffic between them after verification.
- serverA server is a software component that receives client requests, performs the requested processing, and returns responses.
- cloud-native architectureCloud-native architecture is an architectural approach that treats infrastructure as replaceable and designs explicitly for distributed operation, automated management, and failure.
- finopsA collaborative practice for managing and optimizing cloud spending across engineering, finance, and business teams.
- authorizationThe process of determining whether an identity has permission to perform an action or access a resource.
- dry runA dry run previews the effects of an operation without applying its changes.
- deployment pipelineAn automated sequence of stages that builds, tests, and moves software changes toward deployment.
- versioningVersion control is the systematic management of changing files and their history so changes can be reviewed, reproduced, and restored.
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.
