8 Performance and Latency Patterns
This chapter presents patterns that do not necessarily facilitate scalability but solve some specific performance or latency issues introduced by the distribution.
The Circuit Breaker pattern in § 8.1 improves latency in the event of a failing service so that a service can respond appropriately without having to wait for timeouts
The Colocate pattern in § 8.2 names a simple fact: the closer two services are, the faster and more reliably they can communicate, and this needs to be considered when designing a distributed system
The Aggregating Gateway pattern in § 8.3 improves the performance of clients on unreliable or slow networks by doing the heavy lifting for them
The Claim Check pattern in § 8.4 offloads communication by storing large payloads in a shared location so that they do not need to be handled by message brokers or services that do not need them
Under specific circumstances, the Command and Query Responsibility Segregation (CQRS) pattern in § 8.5 can improve performance by separating the read and write sides of a service
Other patterns that could be considered part of this category include [124]:
- Asynchronous Request–Reply can improve concurrency and scheduling of the services by allowing them to respond to requests at their own pace
- Backend for Frontend enables performance optimisation for specific use cases
- Choreography can improve performance by removing the bottleneck of a central coordinator
- Competing Consumers can improve throughput and load distribution
- Event Sourcing can improve throughput by decreasing contention when writing and better performance of replication
- Identity Provider removes the need for individual services to handle authentication
- Health Monitoring can provide resource usage data to load balancers to maximise performance
- Partitioning can decrease contention for resources and reduce data set sizes
Notable omissions in this category due to the methodology described in § 1 include:
Cache-Aside, Index Table, Materialised View by Microsoft [93, 125, 126], as they are not specific to distributed systems
Compute Resource Consolidation and Static Content Hosting by Microsoft [127, 128] and Valet Key by Wilder and Microsoft [14, p. 115, 129] as they are only useful in cloud environments
Content Distribution Network by Fehling et al. [15, p. 300] and the CDN pattern by Wilder [14, p. 125], as they are tied to specific products with global infrastructure