Cloud patterns

Patterns for distributed systems in the cloud: staying up when parts fail, moving messages, scaling data and shaping the edge.

Resilience

Keep working when a dependency is slow, down or overloaded.

Bulkhead

Give each dependency or workload its own limited pool of resources, so one slow part can't use up everything and sink the whole service.

Circuit Breaker

Stop calling a dependency that keeps failing, fail fast with a fallback, and probe now and then to see if it has recovered.

Health Endpoint Monitoring

Expose an endpoint that reports whether an instance can do its job, so load balancers, orchestrators and monitors can route around problems.

Retry with backoff

Automatically try a failed call again after a growing, randomised delay, because many cloud failures are brief and fix themselves.

Throttling

Cap how many requests each client can make in a time window, and reject the excess politely, to protect your service and keep it fair.

Messaging

Connect services with queues and events, and keep data consistent across them.

Anti-Corruption Layer

Put a translation layer between a new system and a legacy or external one, so the old system's model and quirks don't leak into the new design.

Competing Consumers

Let several identical workers read from the same queue, each message going to exactly one of them, so processing scales out simply by adding workers.

Publisher–Subscriber

Publish an event once to a topic and let any number of independent services subscribe to it, without the publisher knowing who they are.

Queue-Based Load Leveling

Put a queue between a spiky source of work and the service that does it, so bursts are absorbed and processed at a steady, safe rate.

Saga

Run a business transaction across several services as a series of local steps, each with a compensating action that undoes it if a later step fails.

Transactional Outbox

Save a change and the event announcing it in the same database transaction, then publish the event separately, so you never lose or invent events.

Data

Read fast, write safely and grow beyond one database.

Cache-Aside

Check a fast cache first, load from the database only on a miss, and store the result in the cache for next time.

CQRS

Use one model to change data and a separate, read-optimised model to query it, so each side can be designed and scaled for its own job.

Event Sourcing

Store every change as an immutable event in an append-only log, and derive the current state by replaying them, instead of overwriting rows.

Materialized View

Precompute the data a screen or report needs into a ready-made table, and keep it updated, instead of joining and aggregating on every request.

Sharding

Split one big data set across several databases by a key, such as customer or region, so data and load can grow beyond what one server can handle.

Edge & deployment

Shape what clients see, and change systems without big-bang rewrites.

Ambassador

Put a local helper between an app and the remote services it calls, to handle retries, timeouts, routing and credentials on the app's behalf.

API Gateway

Give clients one entry point that routes requests to the right backend service and handles shared concerns like authentication and rate limits.

Backends for Frontends

Give each kind of client, such as web, mobile or partners, its own thin backend that shapes data exactly for that client.

Leader Election

Let a group of identical instances pick one leader to do work that must happen exactly once, and automatically pick a new one if it fails.

Sidecar

Run supporting features such as proxying, logging or config sync in a separate container next to the app, sharing its lifecycle but not its code.

Static Content Hosting

Serve files that are the same for everyone, such as scripts, styles, images and prerendered pages, from object storage behind a CDN instead of from app servers.

Strangler Fig

Replace a legacy system piece by piece behind a routing layer, sending more features to the new system over time until the old one can be switched off.

Valet Key

Hand clients a short-lived, narrowly scoped token so they can upload or download files directly from storage, without streaming through your servers.