Database Replication Explained
Copy data across multiple servers for high availability, read scalability, and geographic distribution — the foundation of reliable databases.
Database Replication
Database replication is the process of copying data from one database server (primary) to one or more replica servers, providing redundancy for disaster recovery, read scalability, and geographic distribution.
Explanation
A single database server is a single point of failure — if it crashes, the application goes down. Replication creates copies of the database on additional servers, providing both high availability (if the primary fails, a replica can take over) and read scalability (read queries can be distributed across replicas). Synchronous replication waits for all replicas to confirm writes before acknowledging to the client — guaranteeing consistency but adding latency. Asynchronous replication acknowledges writes immediately and propagates to replicas in the background — faster but replicas may lag behind the primary (replication lag). Semi-synchronous replication waits for at least one replica to confirm, balancing consistency and performance. Common replication topologies include primary-replica (one writer, multiple readers), primary-primary (multiple writers with conflict resolution), and cascading replication (replicas replicate from other replicas). Cloud managed databases (RDS, Cloud SQL, Atlas) handle replication automatically, making it accessible without deep operational expertise.
Bookuvai Implementation
Bookuvai configures database replication for all production deployments. Our standard setup uses a primary instance with at least one read replica, automated failover, and application-level read/write splitting. For globally distributed applications, we configure cross-region replicas to minimize read latency for distant users.
Key Facts
- Read replicas distribute read traffic across multiple database instances
- Synchronous replication guarantees consistency but adds write latency
- Asynchronous replication is faster but replicas may lag behind the primary
- Automated failover promotes a replica to primary if the primary fails
- Managed databases (RDS, Cloud SQL) handle replication automatically
Related Terms
Frequently Asked Questions
- What is replication lag?
- Replication lag is the delay between a write on the primary and its appearance on replicas. In async replication, lag can be milliseconds to seconds. Applications must handle this — a user who writes data and immediately reads from a replica may not see their own write.
- What is automated failover?
- Automated failover detects when the primary database is unreachable and promotes a replica to become the new primary, typically within 30-60 seconds. Managed databases handle this automatically with minimal configuration.
- Is replication the same as backup?
- No. Replication provides real-time redundancy — if a replica is corrupted (e.g., accidental DELETE), the corruption is replicated. Backups are point-in-time snapshots that protect against data corruption, accidental deletion, and logical errors.