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, 93 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
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 | ||
Automatic at 512 MiB or high load | • Divides ranges when size or QPS thresholds exceeded • enables horizontal scalability and hotspot mitigation | ||
Automatic based on replica count | • Moves replicas across nodes to balance load and satisfy zone constraints • happens continuously in background | ||
Parallel query execution | Distributed SQL execution engine that pushes computation to data nodes for parallel processing across ranges. |