Strong Consistency
Implementation Costs of Strong Consistency
Read aloud is unavailable in this browser.
The Price of Strong Guarantees
Linearizability sounds like the perfect consistency model—it makes distributed systems behave like a single machine. So why doesn't every system use it?
The answer lies in the costs. Achieving linearizability requires coordination among distributed nodes, and coordination is expensive. Every read and write operation must be validated against the global state, ensuring no concurrent operation has changed the data. This coordination introduces latency, limits throughput, and creates availability trade-offs that many systems cannot accept.
Understanding these costs is essential for making informed architectural decisions. Some systems genuinely require linearizability and must pay the price. Others can achieve their goals with weaker consistency models at a fraction of the cost. The art of distributed systems design lies in knowing which is which.
By the end of this page, you will understand the fundamental costs of implementing linearizability: coordination overhead (consensus rounds), latency implications (speed of light), availability trade-offs (CAP theorem in practice), and infrastructure complexity. You'll learn to quantify these costs and make informed decisions about when they're justified.
Coordination Overhead: The Consensus Tax
Linearizability requires nodes to agree on the order of operations. This agreement—called consensus—is inherently expensive because it requires communication between multiple nodes before any operation can complete.
The Cost of Consensus
Consensus protocols like Raft and Paxos provide linearizability but introduce significant overhead:
1. Round-Trip Requirements
A typical Raft write requires:
- Client → Leader: 1 message
- Leader → Followers: N-1 messages
- Followers → Leader: N-1 acknowledgments (wait for majority)
- Leader → Client: 1 message
For a 5-node cluster, this is at minimum 2 round-trips before the client gets a response. Each round-trip adds network latency.
| Protocol | Messages per Write | Round Trips | Notes |
|---|---|---|---|
| Multi-Paxos | 2N (propose + accept) | 2 | Classic consensus, leader-based |
| Raft | N (AppendEntries + Acks) | 1-2 | Batched log replication, simpler |
| EPaxos | Varies (N to 2N) | 1+ | Leaderless, higher throughput, complex |
| PBFT | O(N²) | 3 | Byzantine fault tolerant, expensive |
2. Serialization at the Leader
In leader-based protocols, all operations must flow through the leader. This creates:
- Throughput bottleneck: Leader CPU becomes the limiting factor
- Head-of-line blocking: One slow operation delays all subsequent operations
- Increased latency variance: Queuing at the leader adds unpredictable delays
3. Disk I/O on the Critical Path
Most consensus protocols require durable writes before acknowledging:
time = network_rtt + disk_fsync + processing
Each follower must write the log entry to disk before responding. This ensures operations survive crashes but adds 0.5-10ms per operation depending on storage.
4. Quorum Waiting
Operations block until a quorum (typically majority) responds. The latency is determined by the slowest member of the fastest quorum:
12345678910111213141516
// In a 5-node cluster, we need 3 acknowledgments (majority)// Latencies to each node: [2ms, 5ms, 8ms, 50ms, 200ms] // Best case: fastest 3 = [2ms, 5ms, 8ms] → wait for 8ms// Having slow replicas doesn't hurt much IF you have enough fast ones // BUT in a 3-node cluster: need 2 acknowledgments// Latencies: [2ms, 50ms, 200ms]// Must wait for 50ms for every operation! // Geographic distribution makes this worse:// New York: 2ms (local)// London: 80ms// Tokyo: 150ms// // Every write must wait for London or Tokyo to respondWhen replicas are distributed globally for disaster recovery, consensus latency becomes dominated by the speed of light. You cannot have a linearizable write complete in less time than it takes for light to travel to the slowest quorum member and back. For a US-Europe quorum, this is ~100ms minimum, regardless of optimizations.
Latency Analysis: Breaking Down the Delays
Let's perform a detailed latency analysis for a linearizable operation in a real-world distributed system.
Components of Linearizable Write Latency
For a Raft-based system with 5 nodes in a single region:
| Component | Time (P50) | Time (P99) | Description |
|---|---|---|---|
| Client → Leader | 0.5ms | 2ms | Network hop within datacenter |
| Leader Processing | 0.1ms | 1ms | Parse, validate, assign log index |
| Leader Disk Write | 0.5ms | 5ms | fsync to durable storage (SSD) |
| Leader → Followers | 0.5ms | 2ms | Parallel network messages |
| Follower Disk Write | 0.5ms | 5ms | Each follower persists entry |
| Followers → Leader | 0.5ms | 2ms | Acknowledgment messages |
| Wait for Quorum | 0.5ms | 5ms | 3rd-fastest of 5 followers |
| Leader Apply | 0.1ms | 0.5ms | Apply to state machine |
| Leader → Client | 0.5ms | 2ms | Return response |
| Total | ~4ms | ~25ms | End-to-end latency |
Multi-Region Scenario
Now consider the same operation with global distribution (replicas in US-East, US-West, Europe):
Minimum physical latencies:
- US-East to US-West: ~60ms RTT
- US-East to Europe: ~80ms RTT
- US-West to Europe: ~140ms RTT
With a 5-node cluster (2 US-East, 2 US-West, 1 Europe), a write from US-East must wait for at least one US-West acknowledgment:
| Component | Time | Notes |
|---|---|---|
| Local operations | ~5ms | Same as single-region |
| Network to US-West | 30ms | One-way latency |
| Disk write at US-West | 5ms | Follower persistence |
| Network back from US-West | 30ms | Acknowledgment |
| Total Minimum | ~70ms | For every write! |
Linearizable Read Latency
Reads in a linearizable system are also expensive. There are several strategies:
Option 1: Route reads through consensus (safest)
- Same latency as writes (~70ms multi-region)
- Guarantees you see the latest committed value
- Often impractical due to performance
Option 2: Leader leases (optimized)
- Leader holds a time-limited lease
- Reads served locally while lease is valid
- Latency: ~1-2ms (local read)
- Risk: Clock skew can violate linearizability
Option 3: Read-after-write (hybrid)
- Reads wait until their causal dependency is committed
- Latency varies based on concurrent writes
Google Spanner uses TrueTime (GPS + atomic clocks) to bound clock uncertainty. Writes wait for a 'commit wait' period (typically 5-10ms) to ensure ordering. This adds latency but enables linearizable reads with bounded uncertainty. Most systems without specialized hardware cannot replicate this approach.
Throughput Limitations: The Serialization Bottleneck
Beyond latency, linearizability limits throughput in ways that can surprise engineers accustomed to eventually consistent systems.
The Single-Leader Bottleneck
In leader-based consensus:
Max throughput = 1 / (consensus_latency + processing_time)
If consensus takes 70ms and processing takes 1ms:
- Maximum: ~14 operations/second per consensus group
- With batching: Maybe 1,000-2,000 ops/second
Compare to an eventually consistent system:
- Each replica can accept writes independently
- 5 replicas × 10,000 ops/second = 50,000 ops/second
- Eventually converge asynchronously
Batching and Pipelining
Real systems use several techniques to improve throughput:
1. Log Batching Group multiple operations into a single consensus round:
// Instead of:
consensus(op1) // 70ms
consensus(op2) // 70ms
consensus(op3) // 70ms
// Total: 210ms for 3 ops
// Batching:
consensus([op1, op2, op3]) // 70ms
// Total: 70ms for 3 ops
2. Pipelining Start new consensus rounds before previous ones complete:
T=0ms: propose(batch1)
T=10ms: propose(batch2)
T=20ms: propose(batch3)
T=70ms: batch1 committed
T=80ms: batch2 committed
...
This increases throughput but doesn't reduce individual operation latency.
| Metric | Linearizable (Raft) | Eventually Consistent | Factor |
|---|---|---|---|
| Single-key writes | ~1,000/sec | ~50,000/sec | 50x |
| Multi-key transactions | ~500/sec | N/A (no transactions) | |
| Reads (leader-only) | ~10,000/sec | ~100,000/sec per replica | 10-50x |
| Reads (lease-based) | ~50,000/sec | ~100,000/sec | 2x |
| Geographic distribution | Severe penalty | Local latency | 10-100x |
Partitioning for Scale
The only way to scale linearizable write throughput is to partition the data:
- Each partition has its own consensus group
- Operations on different partitions are independent
- Cross-partition operations require expensive protocols (2PC, Saga)
Total throughput = partitions × throughput_per_partition
// With 100 partitions:
100 × 1,000 ops/sec = 100,000 ops/sec
// But cross-partition operations are 10x more expensive
This is how systems like CockroachDB and Spanner achieve reasonable throughput while maintaining linearizability—by sharding data into many independent Raft groups.
Batching improves throughput at the cost of latency. A batch must wait to accumulate enough operations before consensus runs. If you prioritize low latency, you get lower throughput. If you prioritize throughput, each operation waits longer. There's no free lunch.
Availability Implications: The CAP Reality
The CAP theorem states that during a network partition, a distributed system must choose between Consistency and Availability. Linearizable systems choose consistency—meaning they become unavailable when partitions occur.
What Happens During Partitions
Consider a 5-node Raft cluster that gets split by a network partition:
Scenario: 3-2 Split
[Node A, Node B, Node C] | [Node D, Node E]
(majority) | (minority)
- Majority partition: Can form quorum, continues operating
- Minority partition: Cannot form quorum, must reject all writes
Clients connected to the minority partition experience complete unavailability for writes until the partition heals.
Scenario: 2-2-1 Split
[Node A, Node B] | [Node C, Node D] | [Node E]
- No partition has a majority
- Entire system becomes unavailable
- All clients experience outage
Availability Calculations
Let's compute availability for a linearizable system:
Single-node failure tolerance (5 nodes)
- Can tolerate 2 node failures
- Availability = 1 - P(3+ failures)
If each node has 99.9% availability (8.76 hours downtime/year):
P(single node down) = 0.001
P(3+ down) = C(5,3) × 0.001³ + C(5,4) × 0.001⁴ + C(5,5) × 0.001⁵
≈ 10 × 10⁻⁹
Cluster availability ≈ 99.999999%
But this ignores network partitions!
Network partitions are more frequent than node failures:
- Major cloud providers: 1-10 significant partitions/year
- Each might last minutes to hours
- Minority partitions: clients in minority are unavailable
Realistic availability accounting for partitions: 99.9% to 99.99%, not "five nines."
Many teams underestimate partition frequency because they conflate 'partition' with 'complete network failure.' Partitions are often subtle: elevated latency, packet loss, asymmetric reachability. Consensus protocols may become unstable or unavailable during these gray failures even without complete isolation.
Leader Election Delays
Even without partitions, leader failures cause availability gaps:
Leader dies
→ Detection timeout: 1-10 seconds (heartbeat intervals)
→ Election: 1-5 seconds (depending on protocol)
→ New leader stabilizes: 0.5-2 seconds
Total unavailability: 2-17 seconds per leader failure
In a 5-node cluster with aggressive timeouts:
- Leader elections might occur 10-50 times/year
- Each causes 2-5 seconds of write unavailability
- Total: 20-250 seconds/year of outage from elections alone
This doesn't count partial availability during the instability period when requests timeout or are rejected.
Infrastructure Complexity: Operational Costs
Beyond the algorithmic costs, linearizable systems require significant infrastructure investment and operational expertise.
Hardware Requirements
1. Low-Latency Networking
- Consensus is latency-sensitive
- Need high-bandwidth, low-jitter networks
- Consider dedicated interconnects within regions
- RDMA or InfiniBand for extreme performance
2. High-Performance Storage
- SSDs or persistent memory required
- fsync latency directly impacts consensus
- Consider battery-backed write cache
- Plan for storage failover
3. Clock Synchronization
- Some protocols require bounded clock skew
- NTP may not be sufficient (100ms+ drift possible)
- Consider PTP (Precision Time Protocol): μs accuracy
- Spanner uses GPS + atomic clocks: ns accuracy
4. Odd Number of Nodes
- Quorum = (N/2) + 1
- Example: 4 nodes still only tolerates 1 failure
- Example: 5 nodes tolerates 2 failures
- 5 nodes preferred over 4 for same budget
| Requirement | Linearizable System | Eventually Consistent | Cost Impact |
|---|---|---|---|
| Minimum nodes | 3 (production: 5) | 2+ | 60% more servers |
| Network quality | Low-latency critical | Best-effort OK | Premium bandwidth |
| Storage | Fast SSD + fsync | Any persistent store | 2-3x storage cost |
| Clock sync | Bounded skew required | Not critical | Infrastructure cost |
| Monitoring | Detailed lag metrics | Basic health checks | Ops complexity |
| Failover | Automated + tested | Manual acceptable | Engineering time |
Operational Complexity
1. Monitoring and Alerting
Linearizable systems require vigilant monitoring:
Critical metrics to track:
- Replication lag per follower
- Leader election events
- Quorum health (nodes reachable)
- Consensus round latency (P50, P99, P99.9)
- Disk sync latency
- Write queue depth
- Client timeout rates
2. Failure Testing
Regular failure testing is essential:
- Simulate leader failures
- Induce network partitions
- Test clock skew scenarios
- Verify behavior during rolling upgrades
3. Upgrade Complexity
Rolling upgrades require careful orchestration:
- Cannot take down a quorum simultaneously
- Leader step-down before upgrade
- Verify replication health between each node
- Rollback plan if issues arise
When evaluating linearizability, consider the total cost: hardware (2-3x), networking (premium), storage (fast + replicated), operations (specialized expertise), and development (more complex client handling). For many workloads, this cost isn't justified when eventual consistency would suffice.
Cost Comparison with Alternatives
Let's quantify the costs of linearizability compared to alternative consistency models:
Scenario: Global User Profile Service
Requirements:
- 100 million users
- 50,000 reads/second
- 5,000 writes/second
- 99.99% availability target
- Global distribution (US, Europe, Asia)
| Factor | Linearizable (Spanner-like) | Eventually Consistent | Difference |
|---|---|---|---|
| Write latency | 100-200ms | 5-20ms | 10-20x worse |
| Read latency | 50-100ms (consensus) or 5ms (lease) | 5ms (local replica) | 10x or 0x |
| Minimum servers | 15 (5 per region × 3 regions) | 6 (2 per region) | 2.5x more |
| Storage | $5,000/month (fast SSD) | $1,500/month | 3.3x more |
| Network | $3,000/month (premium) | $1,000/month | 3x more |
| Ops complexity | High (specialized team) | Low (standard infra) | Significant |
| Dev complexity | Moderate (timeouts, retries) | Higher (conflict resolution) | Trade-off |
| Monthly cost | ~$15,000 | ~$5,000 | 3x more |
When the Cost Is Justified
Linearizability's costs are justified when:
- Coordination correctness is critical: Lock services, leader election, unique constraints
- Financial transactions: Cannot afford lost or duplicate transactions
- Strong consistency is a product requirement: Users expect real-time accuracy
- The workload is naturally low-volume: Configuration management, metadata
- Cross-region latency is acceptable: Batch processing, non-interactive systems
When the Cost Is Not Justified
Linearizability is overkill for:
- Social media feeds: Eventual consistency with read-your-writes is sufficient
- Analytics and reporting: Data is already timestamped; stale reads acceptable
- Session storage: Session affinity provides effective consistency
- Caching layers: Eventual consistency with TTL is the norm
- Event logging: Append-only, naturally ordered by time
In most systems, less than 20% of operations actually require strong consistency. The art is identifying which 20% and applying linearizability only there. Use weaker consistency for the rest. Hybrid approaches—like CRDTs for high-volume data with linearizable coordination—often provide the best balance.
Summary: Understanding Implementation Costs
We've performed a detailed analysis of what it costs to implement linearizability. These costs are inherent, not accidental—they stem from the fundamental requirements of distributed coordination.
- •Consensus requires multiple network round-trips — Each operation involves coordination, adding 2-5ms locally or 70-200ms globally.
- •Leader-based protocols create throughput bottlenecks — All operations flow through one node, limiting scalability without partitioning.
- •Disk I/O is on the critical path — Durability requires fsync, adding milliseconds to every operation.
- •Availability suffers during partitions — This is the CAP theorem in action: linearizable systems choose consistency over availability.
- •Leader elections cause outage windows — Seconds of unavailability during failure detection and election.
- •Infrastructure costs are 2-3x higher — More nodes, faster storage, premium networking, specialized monitoring.
- •Operational complexity is significant — Requires expertise in distributed systems, failure testing, and careful orchestration.
What's Next:
Understanding the costs, we'll now explore the performance implications in more depth—specifically, how latency affects user experience and throughput affects business operations, and what optimization strategies exist.
You now understand the real costs of implementing linearizability: coordination overhead, latency penalties, throughput limitations, availability trade-offs, and infrastructure complexity. This knowledge enables you to make informed decisions about when strong consistency is worth its price.
KEEP LEARNING
There’s more to understand.
You’re reading the introduction. Create a free account to read the complete lesson, save notes and keep track of your progress.