Database DesignDistributed SQL (CockroachDB, Spanner)Medium⏱️ ~2 min

Trade-offs: Distributed SQL vs Single Node and NoSQL

Latency versus Scale Trade off

Choosing distributed SQL means accepting higher write latency in exchange for horizontal scale and automatic failover. A well-tuned single-node database commits transactions in under 1 millisecond because it only needs to flush data to local disk. Distributed SQL adds consensus latency: within a single datacenter region, writes complete in 2 to 5 milliseconds for network round-trips required by the replication protocol. Cross-region writes take 50 to 150 milliseconds due to speed-of-light latency between continents.

The scale benefit is real: distributed SQL handles workloads that would overwhelm any single machine, surviving complete datacenter failures while maintaining consistency. If your workload fits on one server with comfortable headroom, single-node is almost always simpler and faster. Distributed SQL becomes necessary when you need more capacity than one machine provides, or when multi-region availability with strong consistency is required.

Versus Manual Sharding

Compared to manually sharded relational databases, distributed SQL removes application complexity at the cost of operational complexity. With manual sharding, your application code routes queries to correct shards by extracting shard keys, handles cross-shard transactions with application-level coordination (often accepting eventual consistency or giving up on cross-shard atomicity), and manages shard rebalancing when data or traffic patterns change.

Distributed SQL hides all routing and coordination behind standard SQL. You write queries without awareness of shards, and the database handles placement, rebalancing, and cross-range transactions automatically. The trade off is stricter infrastructure requirements: clock synchronization must work reliably, monitoring must track consensus health across thousands of ranges, and debugging distributed failures requires understanding internal mechanisms that application-level sharding avoids.

Versus Eventually Consistent NoSQL

Against NoSQL systems that offer eventual consistency (the guarantee that all replicas will eventually converge to the same value, but reads may see stale data in the meantime), distributed SQL provides strong consistency, joins, and relational schemas. With eventual consistency, a write to one replica may not be visible to reads from another replica for seconds or longer, requiring application code to handle conflicts and stale reads.

Strong consistency eliminates this complexity: a committed write is immediately visible to all subsequent reads across all nodes. You can use foreign keys and transactions, trust that reads reflect all prior writes, and avoid conflict resolution code. The cost is lower write throughput at the same hardware budget because consensus requires majority acknowledgment before commits, and stricter availability: you need a majority of replicas online for each range to accept writes, whereas eventually consistent systems can accept writes in any partition.

Ideal Use Cases

Distributed SQL shines for workloads that need both correctness and scale. Financial ledgers, global user identity systems, order management platforms, and configuration state all benefit from strong consistency across regions. These applications cannot tolerate stale reads, lost updates, or conflicting writes that eventual consistency allows.

For content feeds, analytics pipelines, or caching layers where stale data is acceptable and write throughput is critical, eventually consistent stores remain simpler and cheaper. For workloads that fit on a single server, traditional databases provide sub-millisecond latency without the operational overhead of distributed systems. The key decision factor: does your workload genuinely require both relational semantics and scale beyond one machine? If not, simpler architectures are almost always better.

💡 Key Takeaways
Single node commits in under 1ms but cannot scale; distributed SQL adds 2 to 5ms regional or 50 to 150ms cross-region latency for consensus coordination
Manual sharding requires application code for routing and cross-shard coordination; distributed SQL automates this but adds clock synchronization requirements
Eventual consistency (replicas eventually converge) allows higher write throughput; strong consistency ensures immediate visibility but requires majority acknowledgment
Distributed SQL requires majority of replicas available per range; eventually consistent systems accept writes in any partition during failures
Best fit: financial ledgers, identity systems, order management where correctness matters more than raw throughput or lowest latency
If workload fits on one server with headroom, single-node databases provide simpler operations and sub-millisecond latency
📌 Interview Tips
1Explain the decision framework: does the workload genuinely require both relational semantics and scale beyond one machine?
2Discuss strong consistency benefit: no conflict resolution code, no stale read handling, foreign keys and transactions work as expected
3Mention availability trade off: distributed SQL needs majority online to write, eventually consistent systems keep writing during partitions
← Back to Distributed SQL (CockroachDB, Spanner) Overview