Cloud Design Patterns in Plain English

Source: Cloud design patterns, architectures, and implementations (diagrams from that guide).

A monolith is one program, one database. Microservices are many small programs that talk over the network and often each have their own database. These patterns are the usual answers to: “how do they talk, fail, and stay consistent?”

PatternOne line
Anti-corruption layerTranslator so old code need not learn the new API
Hostname / path / header routingHow the front door picks a service
Circuit breakerStop calling a sick neighbor
Event sourcingSave what happened, not only the latest row
HexagonalBusiness rules in the middle; DB and HTTP are plugs
Publish-subscribeShout an event; whoever cares listens
Retry with backoffWait longer each time you retry
Saga choreography / orchestrationMulti-step “transaction” without a shared DB lock
Scatter-gatherAsk many, then combine answers
Strangler figReplace the monolith piece by piece
Transactional outboxWrite DB + “please publish this event” in one commit

Anti-corruption layer (ACL)

You moved User out of the monolith. Cart still speaks the old User shape. ACL is a translator in the middle. Cart does not change.

ACL in the monolith

AWS: ACL class in the monolith → API Gateway → Lambda (new service).

ACL on AWS

Delete the ACL when every caller has moved. Pair with retry and circuit breaker. Guide · sample


API routing

Same idea: one front door, different ways to choose the kitchen.

Hostname

Each service owns a name: orders.api.example.com, billing.api.example.com. Teams do not share a gateway config. Clients must remember many hosts (or you give them an SDK).

Hostname routing

Path

One host: api.example.com/orders, api.example.com/billing. Easier for humans. One bad config can hit everyone. On AWS: API Gateway proxy /billing/*, CloudFront origin by path, or NGINX.

Path routing

HTTP header

Path still names the resource. A header picks version, A/B, or action (x-service-a-action: get-thing). You need control of the client. Often combined with hostname or path.

Header routing

Hostname · path · header


Circuit breaker

If Payment is down, do not keep waiting. After too many failures, the breaker opens: fail fast. After a wait, half-open: one test call. Success → closed again.

Closed

Open

AWS: Step Functions, app libraries, or API Gateway + Lambda with stored state (e.g. DynamoDB). Guide


Event sourcing

Do not only store “balance = 40”. Store events: deposited 50, withdrew 10. Rebuild state by replaying. Good audit trail; reads often use a projection (a table built from events).

Event sourcing

AWS: EventBridge, Kinesis, DynamoDB Streams, EventStore-style tables. Guide


Hexagonal architecture (ports and adapters)

The hexagon is business rules. Ports are sockets. Adapters are plugs: HTTP in, DynamoDB out. Swap DynamoDB for Postgres by changing the adapter, not the rules. Easy unit tests with fake adapters.

Ports and adapters

AWS: Lambda handler = adapter; domain classes have no boto3.

Lambda

Guide · sample


Publish-subscribe

Producer publishes “OrderPlaced”. It does not know who listens. Inventory and email subscribe. Add a new listener without changing the producer.

Pub/sub

AWS: SNS + SQS, EventBridge. Guide


Retry with backoff

Network blips happen. Retry, but wait longer each time (1s, 2s, 4s…) plus jitter so everyone does not retry together. Do not retry forever. Do not retry non-idempotent POSTs without care.

Retry

AWS: SDK retry modes, Step Functions retries, SQS redrive. Guide


Saga (no 2-phase commit across databases)

Order + inventory + payment are three databases. You cannot lock them as one SQL transaction. A saga is a chain of local steps. If payment fails, run compensations (release stock, cancel order).

Choreography

No boss. Order publishes an event; Inventory reacts; Payment reacts. Simple with few services; hard to see the whole story later.

Choreography

Orchestration

A conductor (often Step Functions) calls T1, T2, T3. On T3 fail, it runs C2 then C1. One place to read the flow; the conductor is a dependency.

Orchestration

Step Functions

Overview · choreography · orchestration


Scatter-gather

Scatter: send the same question to many workers. Gather: merge results (fastest quote, all answers, or first N).

Scatter-gather

AWS: Step Functions parallel, SQS + aggregator Lambda, Map state. Guide


Strangler fig

Do not rewrite the whole tree. Put a proxy in front. Route one URL to a new service; the rest still hits the monolith. Grow the new until the old is gone.

Strangler

AWS: API Gateway, ALB, CloudFront - path or host to Lambda/ECS vs the old app. Use with ACL. Guide


Transactional outbox

You saved the order in SQL and you must publish OrderPlaced. Two systems: if the publish fails after commit, listeners never hear. Outbox: same DB transaction writes the row and an outbox row. A relay reads the outbox and publishes (SNS/EventBridge). At-least-once: consumers must be idempotent.

Outbox

AWS: DynamoDB Streams / RDS + poller Lambda, or CDC.

AWS outbox

Guide


How they fit

Strangler + ACL     → leave the monolith without a big-bang rewrite
Hexagonal           → keep rules testable while you swap AWS pieces
Pub/sub + outbox    → notify others without dual-write bugs
Saga                → multi-service business flow
Circuit + retry     → survive the other team’s outage
Routing             → one URL or many, on purpose