references/design-patterns.md
Cloud Design Patterns
A comprehensive reference of all 44 cloud design patterns from the Azure Architecture Center, organized by concern area and detailed with problem context, usage scenarios, WAF pillar alignment, and related patterns.
Patterns by Concern
Availability / Reliability
Circuit Breaker · Compensating Transaction · Health Endpoint Monitoring · Leader Election · Queue-Based Load Leveling · Retry · Saga · Scheduler Agent Supervisor · Sequential Convoy · Bulkhead · Rate Limiting
Data Management
Cache-Aside · CQRS · Event Sourcing · Index Table · Materialized View · Sharding · Valet Key · Claim Check
Design / Implementation
Ambassador · Anti-Corruption Layer · Backends for Frontends · Compute Resource Consolidation · Deployment Stamps · External Configuration Store · Gateway Aggregation · Gateway Offloading · Gateway Routing · Sidecar · Strangler Fig · Federated Identity
Messaging
Asynchronous Request-Reply · Choreography · Claim Check · Competing Consumers · Messaging Bridge · Pipes and Filters · Priority Queue · Publisher/Subscriber · Queue-Based Load Leveling · Sequential Convoy
Performance / Scalability
Cache-Aside · Geode · Throttling · Deployment Stamps · CQRS
Security
Gatekeeper · Quarantine · Valet Key · Federated Identity · Throttling
Pattern Reference
1. Ambassador
Create helper services that send network requests on behalf of a consumer service or application.
Problem: Applications need common connectivity features such as monitoring, logging, routing, security (TLS), and resiliency patterns. Legacy or difficult-to-modify apps may not support these features natively. Network calls require substantial configuration for concerns such as circuit breaking, routing, metering, and telemetry.
When to use:
- You need a common set of client connectivity features across multiple languages or frameworks
- The connectivity concern is owned by infrastructure teams or another specialized team
- You need to reduce the age or complexity of legacy app networking without modifying source code
- You want to standardize observability and resiliency across polyglot services
WAF Pillars: Reliability, Security
Related patterns: Sidecar, Gateway Routing, Gateway Offloading
2. Anti-Corruption Layer
Implement a façade or adapter layer between a modern application and a legacy system.
Problem: During migration, the new system must often integrate with the legacy system's data model or API, which may use outdated schemas, protocols, or design conventions. Allowing the modern application to depend on legacy contracts contaminates its design and limits future evolution.
When to use:
- A migration is planned over multiple phases and the old and new systems must coexist
- The new system's domain model differs significantly from the legacy system
- You want to prevent legacy coupling from leaking into modern components
- Two bounded contexts (DDD) need to communicate but have incompatible models
WAF Pillars: Operational Excellence
Related patterns: Strangler Fig, Gateway Routing
3. Asynchronous Request-Reply
Decouple backend processing from a frontend host, where backend processing needs to be asynchronous but the frontend still needs a clear response.
Problem: In many architectures, the client expects an immediate acknowledgement while the actual work happens in the background. The client needs a way to learn the result of the background operation without holding a long-lived connection or repeatedly guessing when processing completes.
When to use:
- Backend processing may take seconds to minutes and the client should not block
- Client-side code such as a browser app cannot provide a callback endpoint
- You want to expose an HTTP API where the server initiates long-running work and the client polls for results
- You need an alternative to WebSocket or server-sent events for status updates
WAF Pillars: Performance Efficiency
Related patterns: Competing Consumers, Pipes and Filters, Queue-Based Load Leveling
4. Backends for Frontends
Create separate backend services to be consumed by specific frontend applications or interfaces.
Problem: A general-purpose backend API tends to accumulate conflicting requirements from different frontends (mobile, web, desktop, IoT). Over time the backend becomes bloated and changes for one frontend risk breaking another. Release cadences diverge and the single backend becomes a bottleneck.
When to use:
- A shared backend must be maintained with significant development overhead for multiple frontends
- You want to optimize each backend for the constraints of a specific client (bandwidth, latency, payload shape)
- Different frontend teams need independent release cycles for their backend logic
- A single backend would require complex, client-specific branching logic
WAF Pillars: Reliability, Security, Performance Efficiency
Related patterns: Gateway Aggregation, Gateway Offloading, Gateway Routing
5. Bulkhead
Isolate elements of an application into pools so that if one fails, the others continue to function.
Problem: A cloud-based application may call multiple downstream services. If a single downstream becomes slow or unresponsive, the caller's thread pool or connection pool can be exhausted, causing cascading failure that takes down unrelated functionality.
When to use:
- You need to protect critical consumers from failures in non-critical downstream dependencies
- A single noisy tenant or request type should not degrade service for others
- You want to limit the blast radius of a downstream fault
- The application calls multiple services with differing SLAs
WAF Pillars: Reliability, Security, Performance Efficiency
Related patterns: Circuit Breaker, Retry, Throttling, Queue-Based Load Leveling
6. Cache-Aside
Load data on demand into a cache from a data store.
Problem: Applications frequently read the same data from a data store. Repeated round trips increase latency and reduce throughput. Data stores may throttle or become expensive under high read loads.
When to use:
- The data store is read-heavy and the same data is requested frequently
- The data store does not natively provide caching
- Data can tolerate short periods of staleness
- You want to reduce cost and latency of repeated reads
WAF Pillars: Reliability, Performance Efficiency
Related patterns: Materialized View, Event Sourcing, CQRS
7. Choreography
Have each component of the system participate in the decision-making process about the workflow of a business transaction, instead of relying on a central point of control.
Problem: A central orchestrator can become a single point of failure, a performance bottleneck, or a source of tight coupling. Changes to the workflow require changes to the orchestrator, which may be owned by a different team.
When to use:
- Services are independently deployable and owned by separate teams
- The workflow changes frequently and a central orchestrator would become a maintenance burden
- You want to avoid a single point of failure in workflow coordination
- Services need loose coupling and can react to events
WAF Pillars: Operational Excellence, Performance Efficiency
Related patterns: Publisher/Subscriber, Saga, Competing Consumers
8. Circuit Breaker
Handle faults that might take a variable amount of time to fix when connecting to a remote service or resource.
Problem: Transient faults are handled by the Retry pattern, but when a downstream service is unavailable for an extended period, retries waste resources and block callers. Continuing to send requests to a failing service prevents it from recovering and wastes the caller's threads, connections, and compute.
When to use:
- A remote dependency experiences intermittent prolonged outages
- You need to fail fast rather than make callers wait for a timeout
- You want to give a failing downstream time to recover before sending more requests
- You want to surface degraded functionality instead of hard failures
WAF Pillars: Reliability, Performance Efficiency
Related patterns: Retry, Bulkhead, Health Endpoint Monitoring, Ambassador
9. Claim Check
Split a large message into a claim check and payload to avoid overwhelming the messaging infrastructure.
Problem: Message brokers and queues often have size limits and charge per message. Sending large payloads (images, documents, datasets) through the messaging channel wastes bandwidth, increases cost, and may hit transport limits.
When to use:
- The message payload exceeds the messaging system's size limit
- You want to reduce messaging costs by keeping message bodies small
- Not all consumers need the full payload; some only need metadata
- You need to protect sensitive payload data by separating access control from the messaging channel
WAF Pillars: Reliability, Security, Cost Optimization, Performance Efficiency
Related patterns: Competing Consumers, Pipes and Filters, Publisher/Subscriber
10. Compensating Transaction
Undo the work performed by a series of steps, which together define an eventually consistent operation.
Problem: In distributed systems, multi-step operations cannot rely on traditional ACID transactions. If a later step fails, the previous steps have already committed. The system needs a mechanism to reverse or compensate for the work done by the completed steps.
When to use:
- Multi-step operations span multiple services or data stores that do not share a transaction coordinator
- You need to maintain consistency when a step in a distributed workflow fails
- Rolling back is semantically meaningful (refund a charge, release a reservation)
- The cost of inconsistency outweighs the complexity of compensation logic
WAF Pillars: Reliability
Related patterns: Saga, Retry, Scheduler Agent Supervisor
11. Competing Consumers
Enable multiple concurrent consumers to process messages received on the same messaging channel.
Problem: At peak load, a single consumer cannot keep up with the volume of incoming messages. Messages queue up, latency increases, and the system may breach its SLAs.
When to use:
- The workload varies significantly and you need to scale message processing dynamically
- You require high availability—if one consumer fails, others continue processing
- Multiple messages are independent and can be processed in parallel
- You want to distribute work across multiple instances or nodes
WAF Pillars: Reliability, Cost Optimization, Performance Efficiency
Related patterns: Queue-Based Load Leveling, Priority Queue, Publisher/Subscriber, Pipes and Filters
12. Compute Resource Consolidation
Consolidate multiple tasks or operations into a single computational unit.
Problem: Deploying each small task or component as a separate service introduces operational overhead: more deployments, monitoring endpoints, and infrastructure cost. Many lightweight components are underutilized most of the time, wasting allocated compute.
When to use:
- Several lightweight processes have low CPU or memory usage individually
- You want to reduce deployment and operational overhead
- Processes share the same scaling profile and lifecycle
- Communication between tasks benefits from being in-process rather than over the network
WAF Pillars: Cost Optimization, Operational Excellence, Performance Efficiency
Related patterns: Sidecar, Backends for Frontends
13. CQRS (Command and Query Responsibility Segregation)
Segregate operations that read data from operations that update data by using separate interfaces.
Problem: In traditional CRUD architectures, the same data model is used for reads and writes. This creates tension: read models want denormalized, query-optimized shapes while write models want normalized, consistency-optimized shapes. As the system grows, the shared model becomes a compromise that serves neither concern well.
When to use:
- Read and write workloads are asymmetric (far more reads than writes, or vice versa)
- Read and write models have different schema requirements
- You want to scale read and write sides independently
- The domain benefits from an event-driven or task-based style rather than CRUD
WAF Pillars: Performance Efficiency
Related patterns: Event Sourcing, Materialized View, Cache-Aside
14. Deployment Stamps
Deploy multiple independent copies of application components, including data stores.
Problem: A single shared deployment for all tenants or regions creates coupling. A fault in one tenant's workload can affect all tenants. Regulatory requirements may mandate data residency. Scaling the entire deployment for a single tenant's spike is wasteful.
When to use:
- You need to isolate tenants for compliance, performance, or fault isolation
- Your application must serve multiple geographic regions with data residency requirements
- You need independent scaling per tenant group or region
- You want blue/green or canary deployments at the stamp level
WAF Pillars: Operational Excellence, Performance Efficiency
Related patterns: Geode, Sharding, Throttling
15. Edge Workload Configuration
Centrally configure workloads that run at the edge, managing configuration drift and deployment consistency across heterogeneous edge devices.
Problem: Edge devices are numerous, heterogeneous, and often intermittently connected. Deploying and configuring workloads individually is error-prone. Configuration drift between devices causes inconsistent behavior and difficult debugging.
When to use:
- You manage a fleet of edge devices running the same workload with differing local parameters
- Edge devices have intermittent connectivity and must operate independently
- You need a central source of truth for configuration with local overrides
- Audit and compliance require tracking which configuration each device is running
WAF Pillars: Operational Excellence
Related patterns: External Configuration Store, Sidecar, Ambassador
16. Event Sourcing
Use an append-only store to record the full series of events that describe actions taken on data in a domain.
Problem: Traditional CRUD stores only keep current state—history is lost. Audit, debugging, temporal queries, and replays are impossible without supplementary logging, which is often incomplete or out of sync.
When to use:
- You need a complete, immutable audit trail of all changes
- The business logic benefits from replaying or projecting events into different views
- You want to decouple the write model from the read model (often combined with CQRS)
- You need to reconstruct past states for debugging or regulatory purposes
WAF Pillars: Reliability, Performance Efficiency
Related patterns: CQRS, Materialized View, Compensating Transaction, Saga
17. External Configuration Store
Move configuration information out of the application deployment package to a centralized location.
Problem: Configuration files deployed alongside the application binary require redeployment to change. Different environments (dev, staging, prod) need different values. Sharing configuration across multiple services is difficult when each has its own config file.
When to use:
- Multiple services share common configuration settings
- You need to update configuration without redeploying or restarting services
- You want centralized access control and audit logging for configuration
- Configuration must differ across environments but be managed in a single system
WAF Pillars: Operational Excellence
Related patterns: Edge Workload Configuration, Sidecar
18. Federated Identity
Delegate authentication to an external identity provider.
Problem: Building and maintaining your own identity store introduces security risks (password storage, credential rotation, MFA implementation). Users must manage separate credentials for each application, leading to password fatigue and weaker security posture.
When to use:
- Users already have identities in an enterprise directory or social provider
- You want to enable single sign-on (SSO) across multiple applications
- Business partners need to access your application with their own credentials
- You want to offload identity management (MFA, password policy) to a specialized provider
WAF Pillars: Reliability, Security, Performance Efficiency
Related patterns: Gatekeeper, Valet Key, Gateway Offloading
19. Gatekeeper
Protect applications and services by using a dedicated host instance that acts as a broker between clients and the application or service.
Problem: Services that expose public endpoints are vulnerable to malicious attacks. Placing validation, authentication, and sanitization logic inside the service mixes security concerns with business logic and increases the attack surface if the service is compromised.
When to use:
- Applications handle sensitive data or high-value transactions
- You need a centralized point for request validation and sanitization
- You want to limit the attack surface by isolating security checks from the trusted host
- Compliance requires an explicit security boundary between public and private tiers
WAF Pillars: Security
Related patterns: Valet Key, Gateway Routing, Gateway Offloading, Federated Identity
20. Gateway Aggregation
Use a gateway to aggregate multiple individual requests into a single request.
Problem: A client (especially mobile) may need data from multiple backend microservices to render a single page or view. Making many fine-grained calls from the client increases latency (multiple round trips), battery usage, and complexity. The client must understand the topology of the backend.
When to use:
- A client needs to make multiple calls to different backend services for a single operation
- Network latency between the client and backend is significant (mobile, IoT, remote clients)
- You want to reduce chattiness and simplify client code
- Backend services are fine-grained microservices and the client should not know their topology
WAF Pillars: Reliability, Security, Operational Excellence, Performance Efficiency
Related patterns: Backends for Frontends, Gateway Offloading, Gateway Routing
21. Gateway Offloading
Offload shared or specialized service functionality to a gateway proxy.
Problem: Cross-cutting concerns such as TLS termination, authentication, rate limiting, logging, and compression are duplicated across every service. Each team must implement, configure, and maintain these features independently, leading to inconsistency and wasted effort.
When to use:
- Multiple services share cross-cutting concerns (TLS, auth, rate limiting, logging)
- You want to standardize and centralize these features instead of duplicating them per service
- You need to reduce operational complexity for individual service teams
- The gateway is already in the request path and adding features there avoids extra hops
WAF Pillars: Reliability, Security, Cost Optimization, Operational Excellence, Performance Efficiency
Related patterns: Gateway Aggregation, Gateway Routing, Sidecar, Ambassador
22. Gateway Routing
Route requests to multiple services using a single endpoint.
Problem: Clients must know the addresses of multiple services. Adding, removing, or relocating a service requires client updates. Exposing internal service topology increases coupling and complicates DNS and load balancing.
When to use:
- You want to expose multiple services behind a single URL with path- or header-based routing
- You need to decouple client URLs from the internal service topology
- You want to simplify client configuration and DNS management
- You need to support versioned APIs or blue/green routing at the gateway level
WAF Pillars: Reliability, Operational Excellence, Performance Efficiency
Related patterns: Gateway Aggregation, Gateway Offloading, Backends for Frontends
23. Geode
Deploy backend services into a set of geographical nodes, each of which can service any client request in any region.
Problem: Users across the globe experience high latency when all traffic routes to a single region. A single-region deployment also creates a single point of failure and cannot meet data residency requirements for multiple jurisdictions.
When to use:
- Users are globally distributed and expect low-latency access
- You need active-active multi-region availability
- Data residency or sovereignty requirements mandate regional deployment
- A single-region failure should not take down the service globally
WAF Pillars: Reliability, Performance Efficiency
Related patterns: Deployment Stamps, Sharding, Cache-Aside, Static Content Hosting
24. Health Endpoint Monitoring
Implement functional checks in an application that external tools can access through exposed endpoints at regular intervals.
Problem: Without health checks, failures are detected only when users report them. Load balancers, orchestrators, and monitoring systems need a programmatic way to determine whether an instance is healthy, ready to accept traffic, and functioning correctly.
When to use:
- You use a load balancer or orchestrator (Kubernetes, App Service) that needs liveness and readiness signals
- You want automated alerting when a service degrades
- You need to verify downstream dependencies (database, cache, third-party API) are reachable
- You want to enable self-healing by removing unhealthy instances from rotation
WAF Pillars: Reliability, Operational Excellence, Performance Efficiency
Related patterns: Circuit Breaker, Retry, Ambassador
25. Index Table
Create indexes over the fields in data stores that are frequently referenced by queries.
Problem: Many NoSQL stores support queries efficiently only on the primary or partition key. Queries on non-key fields result in full scans, which are slow and expensive at scale.
When to use:
- Queries frequently filter or sort on non-key attributes
- The data store does not support secondary indexes natively
- You want to trade additional storage and write overhead for faster reads
- Read performance on secondary fields is critical to the user experience
WAF Pillars: Reliability, Performance Efficiency
Related patterns: Materialized View, Sharding, CQRS
26. Leader Election
Coordinate the actions performed by a collection of collaborating instances by electing one instance as the leader that assumes responsibility for managing the others.
Problem: Multiple identical instances need to coordinate shared work (aggregation, scheduling, rebalancing). Without coordination, instances may duplicate effort, conflict, or corrupt shared state.
When to use:
- A group of peer instances needs exactly one to perform coordination tasks
- The leader must be automatically re-elected if it fails
- You want to avoid a statically assigned coordinator that becomes a single point of failure
- Distributed locks or consensus are needed for coordination
WAF Pillars: Reliability
Related patterns: Scheduler Agent Supervisor, Competing Consumers
27. Materialized View
Generate prepopulated views over the data in one or more data stores when the data isn't ideally formatted for required query operations.
Problem: The normalized storage schema that is optimal for writes is often suboptimal for complex read queries. Joins across