🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Data Replication

Data SystemsDistributed DatađŸŸĸ Free Lesson

Advertisement

Data Systems

Data Replication

Replication copies data across multiple nodes to improve availability, reduce latency, and provide fault tolerance. The challenge is keeping replicas consistent as data changes.

  • Availability — Replicas serve reads even if primary fails
  • Latency — Users read from geographically close replicas
  • Durability — Data survives individual node failures

Replication is the foundation of fault-tolerant distributed systems.

Leader-Follower Replication

The most common replication topology: one leader accepts writes, followers replicate the log.

LLeaderAccepts writesFollower 1Read replicaFollower 2Read replicaFollower 3Read replicareadswrites

Synchronous vs Asynchronous Replication

PropertySynchronousAsynchronous
ConsistencyStrongEventual
Write latencyHigh (waits for all replicas)Low (single node)
AvailabilityLower (all replicas must be up)Higher
Data loss riskNone (on commit)Up to replication lag
Use caseFinancial transactionsSocial media feeds

Replication Lag

Multi-Leader Replication

Multiple nodes accept writes, each replicating to all others.

When to Use Multi-Leader

  • Multi-datacenter deployments for low-latency writes
  • Offline clients that sync when reconnected
  • Collaborative editing where multiple users edit simultaneously

Conflict Resolution

When two leaders update the same key concurrently, a conflict occurs.

Replication Topologies

LinearABCStarABCDCircularABCD
TopologyProsCons
LinearSimple, orderedSlow propagation, single point of failure
StarFast propagation from centerHub is bottleneck
CircularNo central bottleneckSlow, fragile if one node fails
All-to-AllFastest propagationConflict resolution complex

Log-Based Replication

Most modern systems replicate via an append-only log.

Practice Exercises

  1. Conceptual: Explain why synchronous replication is rarely used for all replicas in production. What is the alternative?

  2. Design: Design a replication strategy for a global social media app where users write in their local region but must read their own writes immediately. How do you handle replication lag?

  3. Conflict Resolution: Two users edit the same document offline. User A saves at 10:00:01, User B saves at 10:00:02. Both sync at 10:00:05. Design a conflict resolution strategy that preserves both users' intent.

  4. Analysis: Compare linear, star, and all-to-all replication topologies for a 5-datacenter deployment. Which topology minimizes propagation delay? Which is most resilient?


What to Learn Next

-> Data Partitioning Horizontal partitioning, range vs hash partitioning, and rebalancing.

-> CAP Theorem Consistency models, availability, and partition tolerance.

-> Consistent Hashing Hash rings, virtual nodes, and load distribution.

-> Distributed Consensus Raft, Paxos, and leader election algorithms.

-> Databases SQL vs NoSQL, indexing, replication, and sharding.

-> Event-Driven Architecture Event sourcing, CQRS, and saga patterns.

Need Expert System Design Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement