Course contentsShow
← Cloud and Infrastructure
Lesson 2473 of 2,98953. High Availability PatternsFree lesson

State Replication and Consistency Models

Learn about synchronous and asynchronous replication strategies and their consistency guarantees.

State Replication and Consistency Models

What you'll learn: How synchronous and asynchronous replication strategies differ and what consistency guarantees each provides for stateful systems.

When you replicate state across multiple nodes for high availability, you face a fundamental trade-off: how quickly do all replicas agree on the current state? This question defines your consistency model.

Synchronous Replication

In synchronous replication, a write operation doesn't complete until all replicas (or a quorum) acknowledge they've received and committed the data.

Analogy: Like a group chat where you wait for everyone's "read receipt" before considering your message delivered.

Consistency guarantee: Strong consistency—all replicas show the same data at the same time. A read immediately following a write will always return the updated value.

Trade-off: Higher latency per write operation and reduced availability if a replica is unreachable (the write may block or fail).

Asynchronous Replication

In asynchronous replication, the primary node acknowledges a write immediately, then replicates to secondaries in the background.

Analogy: Like sending a text message—you get a "sent" confirmation immediately, but the recipient might not see it for seconds (or minutes if they're offline).

Consistency guarantee: Eventual consistency—replicas will converge to the same state given enough time, but may temporarily show stale data.

Trade-off: Lower write latency and better availability, but risk of data loss during primary failure and temporary inconsistencies during reads from secondaries.

Choosing Your Model

Your choice depends on your application's tolerance for inconsistency versus its performance and availability requirements. Financial transactions typically demand synchronous replication, while social media feeds often accept eventual consistency for better responsiveness.

Key Takeaway: Synchronous replication guarantees strong consistency at the cost of latency and availability, while asynchronous replication provides better performance and availability with eventual consistency—choose based on your application's data integrity requirements.