This article introduces the fundamental concept of database replication as a critical step to scale beyond a single database instance. It explores how replication improves system performance by distributing read loads and enhances fault tolerance, ensuring higher availability and data durability in distributed systems.
Read original on Medium #system-designAs systems grow, a single database server often becomes a bottleneck for both read and write operations, as well as a single point of failure. Database replication addresses these challenges by creating and maintaining multiple copies of data across different servers. This not only distributes the read workload but also provides redundancy, making the system more resilient to failures.
The most common replication architecture is primary-secondary (also known as master-replica). In this setup, one database server acts as the primary, handling all write operations. All other servers are secondaries, which receive copies of the data changes from the primary and handle read operations. This model simplifies conflict resolution since writes only occur in one place.
Trade-offs of Primary-Secondary Replication
While primary-secondary replication offers simplicity and strong consistency (at least on the primary), it introduces potential latency for read-after-write consistency if reads are directed to secondaries. Additionally, the primary remains a single point of failure for writes, requiring careful consideration for failover mechanisms.