From "Designing Data-Intensive Applications"
🎧 Listen to Summary
Free 10-min PreviewSingle-Leader Replication Principles
Key Insight
Single-leader replication, also known as active/passive or master-slave, is a prevalent solution for ensuring data consistency across multiple database replicas. In this model, one designated replica serves as the leader, or primary, responsible for processing all client write requests. Upon receiving a write, the leader first commits the new data to its local storage, establishing the authoritative state of the database.
Subsequent to its local write, the leader transmits the data change to all other replicas, termed followers, or secondaries, through a replication log or change stream. Each follower receives this log and meticulously updates its local database copy by applying all writes in the exact sequence in which they were processed by the leader. From a client's perspective, followers are strictly read-only, accepting no direct write requests.
Clients wishing to retrieve data can direct their read queries to either the leader or any of the available followers. This architecture is widely adopted across various database systems, including relational databases such as PostgreSQL, MySQL, and Oracle Data Guard, as well as nonrelational databases like MongoDB and RethinkDB. Beyond traditional databases, it is also a core mechanism in distributed message brokers like Kafka and RabbitMQ.
📚 Continue Your Learning Journey — No Payment Required
Access the complete Designing Data-Intensive Applications summary with audio narration, key takeaways, and actionable insights from Martin Kleppmann.