CockroachDB is a cloud-native distributed SQL database built for horizontal scalability, strong consistency, and automatic fault tolerance. It combines PostgreSQL wire protocol compatibility with a distributed architecture based on Raft consensus and range-based sharding, enabling applications to survive availability zone and region failures while maintaining ACID transactions at global scale. One key insight: CockroachDB separates leaseholder (handles reads/writes) from Raft leader (drives consensus) roles per range, optimizing both read performance and write durability, though in practice they're co-located via the leader leases mechanism.
What This Cheat Sheet Covers
This topic spans 19 focused tables and 92 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Distributed Architecture Core Concepts
Everything else in CockroachDB rests on the handful of primitives here. Data is carved into ranges, each range is kept consistent by its own Raft group, and a leaseholder fronts reads and writes — once those three ideas click, splitting, rebalancing, and distributed query execution all follow naturally.
| Concept | Example | Description |
|---|---|---|
512 MiB default max size | • Contiguous keyspace chunk replicated across nodes • CockroachDB's fundamental unit of data distribution and rebalancing | |
3-replica default with quorum writes | • Protocol ensuring strong consistency by requiring majority approval for writes • each range maintains its own Raft group | |
Handles all reads/writes for a range | • Replica serving traffic for a specific range • always co-located with Raft leader via leader leases for write consistency |