Homeglossary

Database Replication

Database replication is a software engineering process that copies and synchronizes database data across multiple servers or nodes. It keeps one or more replicas available for read traffic, failover, or recovery when a primary database has trouble. Replication is not a backup, because replicas can also receive accidental changes or corrupted data.

Build resilient database-backed apps with Emergent.

What Is Database Replication?

Database replication copies and synchronizes data across servers or nodes. A primary, or leader, accepts changes, while replicas, or followers, receive them. Replication lag is the delay before a replica reflects an update. Replication improves availability and read capacity, but it is not a backup: deletions or corrupted updates can spread to every replica.

How Database Replication Works

Most systems replicate recorded changes rather than repeatedly copying the full database.

  1. An application sends a write, such as a new order, to the primary.
  2. The primary commits and records the change in a transaction log or change stream.
  3. Replicas receive and apply the change to their copies.
  4. Applications can route suitable reads to replicas, while critical reads use the primary.

Database Replication Types and Topologies

Topology defines where writes go. Synchronization mode defines when a write is confirmed.

ApproachWrites and trade-offsTypical fit
Single-leaderOne leader accepts writes. Replicas serve reads and may lag.Most relational databases and read-heavy apps.
Multi-leaderSeveral nodes accept writes. Conflicts need resolution rules.Distributed editing or regional writes.
LeaderlessMultiple peers accept writes, often with quorum rules for consistency.Some highly available NoSQL systems.
Synchronous or asynchronousSynchronous replication adds write latency for stronger confirmation. Asynchronous replication is faster but can lose recent changes during failover.Choose based on acceptable delay and data-loss risk.

Benefits of Database Replication

Replication helps only when failover and application routing are tested.

  • Higher availability during failures or maintenance.
  • Better read performance by distributing queries.
  • Lower latency with replicas closer to users.
  • Reporting or maintenance work away from the primary.
  • Better disaster-recovery readiness across environments.

Practical Limits and Failure Risks

A replica is infrastructure, not an automatic guarantee of correctness.

  • Lag can produce stale reads.
  • Synchronous acknowledgments can slow writes if a replica is distant or unavailable.
  • Asynchronous failover can discard changes a replica has not received.
  • Multi-writer systems can create conflicting updates.
  • Replication spreads bad writes, so independent backups remain essential.

Database Replication vs. Sharding

Replication copies data. Sharding divides data across servers.

FeatureReplicationSharding
Main goalAvailability and read scaling.Write and storage scaling.
Data placementEach replica holds the same data.Each shard holds a subset of data.
Query routingRoute reads to an appropriate copy.Route requests to the shard holding the record.
Combined useReplicas can protect and scale each shard.Large systems often shard, then replicate each shard.

Choosing and Operating a Replication Strategy

Start with application behavior, not a preferred database feature.

  • Measure read and write patterns and define an acceptable stale-read window.
  • Choose a failover objective and test promotion before an incident.
  • Monitor lag, errors, storage capacity, and health checks.
  • Document features that must read from the primary.
  • Keep tested, independent backups that meet recovery needs.

Database Replication in Apps Built With Emergent

Teams building database-backed products with an AI app builder should define consistency, read routing, failover, and backup needs early. Emergent can help teams build and ship full-stack applications, while database architecture decisions should remain explicit as an app grows. Review its database capabilities and this guide to using Airtable as a backend database when planning data-backed workflows.

Start Building
on Emergent today
Start Building