Distributed Application Architecture Patterns

An unopinionated catalogue of the status quo

Methodology

Scope of this work

Existing resources

Selection process

Pattern construction

Design and implementation

Inspiration

Visual style

Technologies

Visual language

Design process

Overview

Prerequisites

Pattern categories

Conventions used

Example application

Communication Patterns

Gateway Routing

Abstract service locations from the clients

Publisher–Subscriber (Pub–Sub, Topics)

Asynchronous one-to-many communication

Asynchronous Request–Reply

Asynchronous two-way communication

Decomposition Patterns

Sidecar

Language-agnostic, locally-running supporting components

Ambassador

Handle network communication on behalf of a service

Offload to Gateway

Move common functionality to a gateway to offload backend services

Backend for Frontend (BFF)

Reduce backend complexity by specialising for each frontend

Scalability Patterns

Competing Consumers & Load Balancer

Continuous parallel request processing

Partitioning (Sharding)

Scale out by separating tasks or data into logical partitions

Scatter–Gather

Asynchronously distribute workloads and aggregate results

Externalised Configuration

Centralised configuration management

Resilience and Reliability Patterns

Bulkheads

Use logical partitions to isolate failures

Queue-Based Load Leveling

Use a messaging queue to manage and cope with peaks in demand

Retry

Do not fail because of transient errors

Health Monitoring

Proactively check and react to service failures

Rate Limiting

Control the rate of incoming requests to prevent overload or starvation

Leader and Followers

Decentrally appoint a replaceable group leader

Performance and Latency Patterns

Circuit Breaker

Isolate failure with controlled recovery

Colocate

Improve network reliability by decreasing the distance between services with high coupling

Aggregating Gateway

Aggregate multiple service requests into a single client response

Claim Check

Reduce message sizes by storing large payloads externally

Command and Query Responsibility Segregation (CQRS)

Isolate data store reads and writes to prevent contention

Security Patterns

Identity provider & Federated Identity

Centralise authentication to reduce the attack surface

Gatekeeper (Service Firewall)

Protect services by validating and sanitising incoming requests in a limited environment

Consistency Patterns

Transaction-Based Processor

Use transactions to encapsulate atomic processes

Transactional Outbox

Atomically send a message and update the database

Saga

Sacrifice isolation for increased availability during a distributed transaction

Choreography-Based Sagas

Distribute responsibility for a saga across participating services

Orchestration-Based Sagas

Centralise responsibility for a saga in a single service

Event Sourcing

Store data as a sequence of changes to preserve history

Migration and Compatibility Patterns

Anti-Corruption Layer (ACL)

Mediate between modern and legacy systems

Incremental Replacement (Strangler Fig)

Replace a legacy system step-by-step

Messaging Bridge

Connect two services with incompatible messaging middleware

Bibliography