This chapter covers
- Understanding the latency of strong and eventual consistency
- Replicating with single-leader, multi-leader, or leaderless approaches
- Replicating synchronously or asynchronously
- Applying replicated state machines for replication
In the previous chapter, we explored colocation as a technique to reduce latency by bringing data close to computation. However, colocation to a single location creates a fundamental problem: What happens when that location fails or becomes unavailable? And what if you want to colocate in multiple locations?
Replication is a technique that maintains multiple copies of the same data across various locations while ensuring consistency between the copies, and it is another way to reduce latency. For example, content delivery networks (CDNs) replicate content across multiple geographic locations, ensuring both availability and low latency. Instead of requiring users to access data from a distant geographical area, a CDN typically maintains a copy of the data nearby. Of course, keeping the copies in sync is a fundamental tradeoff between consistency, availability, and latency. Stricter consistency guarantees typically require more coordination overhead, resulting in increased latency. We’ll explore this tradeoff in this chapter to help you make informed decisions about optimizing your system.