chapter four

4 Replication

 

This chapter covers

  • Understanding latency of strong and eventual consistency
  • Replicating with single-leader, multi-leader, or leaderless approach
  • Replicating synchronously or asynchronously
  • Applying replicated state machines for replication

The previous chapter explored colocation as a technique to reduce latency in distributed and multicore systems. However, in many use cases, you want to colocate data to multiple locations, so you’ll turn to another technique to reduce latency: replication. Replication is a technique that lets you keep multiple copies of your data across different locations while ensuring some guarantees of consistency. For example, content delivery networks (CDNs) colocate data close to the user. But because the data needs to be across multiple locations, CDNs also use replication to synchronize multiple copies of the data.

Although we are most interested in using replication to provide low latency, replication can also provide high availability and fault tolerance, which are essential properties for many use cases. For example, replication can ensure that multiple copies of data are available in case of a failure or outage. Therefore, we also discuss the trade-off between latency, high availability, and fault tolerance point of view so that you can make informed decisions about optimizing your system.

4.1 Why replicate data?

4.2 Availability and scalability

4.3 Consistency model

4.3.1 Strong consistency

4.3.2 Eventual consistency

4.3.3 Other consistency models

4.4 Replication strategies

4.4.1 Single-leader replication

4.4.2 Multi-leader replication

4.4.3 Leaderless replication

4.4.4 Read your writes property

4.4.5 Local-first approach

4.5 Asynchronous vs. synchronous replication

4.6 State machine replication

4.7 Viewstamped replication

4.8 Putting it together: Replicating SQLite

4.9 Summary