Primary-Replica Architecture
What you'll learn: How the primary-replica pattern distributes database workloads for high availability and read scalability.
The Core Pattern
Primary-replica architecture (also called master-slave) designates one database instance as the primary (or master) that handles all write operations, while one or more replica (or slave) instances receive copies of the data and handle read operations. Changes written to the primary automatically propagate to replicas through replication mechanisms you learned about in the previous lesson.
Think of it like a restaurant kitchen: the head chef (primary) creates all new dishes and updates recipes (writes), while sous chefs (replicas) plate and serve those dishes to customers (reads). The sous chefs can't modify recipes—they only execute what the head chef designed.
Read Replicas for Scale
Read replicas excel at horizontal read scaling. When your application performs 90% reads and 10% writes (common in many workloads), you can add multiple replicas to distribute read traffic across them using load balancing patterns you've already learned. Each replica reduces load on the primary, allowing it to focus on writes.
Write Scalability Limitations
Here's the critical constraint: all writes still funnel through a single primary. This creates a bottleneck—you cannot horizontally scale write capacity simply by adding replicas. If your application becomes write-heavy, the primary becomes overwhelmed, and adding more replicas doesn't help. This is why primary-replica works best for read-heavy workloads.
Additionally, replication lag means replicas may serve slightly stale data (eventual consistency), which you explored in state replication and consistency models.
Key Takeaway: Primary-replica architecture scales reads horizontally through replicas but maintains a single-primary write bottleneck, making it ideal for read-heavy workloads but limited for write-intensive applications.