What is CockroachDB?
CockroachDB is a distributed SQL database built on a transactional and strongly-consistent key-value store. It combines the familiarity of SQL with the scale and resilience of NoSQL systems.Horizontal Scalability
Scales horizontally by adding nodes to the cluster, supporting up to 4 exabytes of logical data
High Availability
Survives disk, machine, rack, and datacenter failures with minimal latency disruption and no manual intervention
Strong Consistency
Provides strongly-consistent ACID transactions using distributed consensus (Raft)
SQL Interface
Familiar SQL API for structuring, manipulating, and querying data with PostgreSQL compatibility
Core Features
Distributed Architecture
CockroachDB implements a layered architecture where:- SQL Layer: Provides familiar relational concepts like schemas, tables, columns, and indexes
- Distributed KV Store: Handles range addressing to provide a single, monolithic key-value store abstraction
- Raft Consensus: Ensures data replication and consistency across nodes
- Storage Engine: Uses RocksDB (a variant of LevelDB) for local storage
How It Works
The database is logically a single, monolithic sorted map from key to value. Internally, this map is divided into ranges (default 64MB each):- Each range is replicated to a configurable number of nodes (default: 3)
- Ranges use the Raft consensus algorithm for synchronous replication
- Ranges automatically split and merge to maintain optimal size
- Data is automatically rebalanced across the cluster
Transaction Guarantees
CockroachDB provides two isolation levels:- Serializable Snapshot Isolation (SSI): The default, provides full serializability with no anomalies
- Snapshot Isolation (SI): Higher performance but allows write skew in rare cases
CockroachDB uses a non-locking distributed commit protocol and hybrid logical clocks (HLC) to maintain consistency without atomic clocks.
Key Design Goals
CockroachDB was built with three primary goals:Use Cases
CockroachDB excels at:- Cloud-native applications requiring global distribution
- Multi-region deployments with data locality requirements
- Mission-critical systems that cannot tolerate downtime
- Applications migrating from PostgreSQL (wire protocol compatible)
- High-scale OLTP workloads with strong consistency needs
Get Started
Quick Start
Get CockroachDB running in minutes with our step-by-step tutorial
Installation
Install CockroachDB on your preferred platform
Architecture Guide
Deep dive into how CockroachDB works internally
SQL Reference
Learn about supported SQL statements and syntax
PostgreSQL Compatibility
CockroachDB supports the PostgreSQL wire protocol, which means:- You can use existing PostgreSQL client drivers
- Most PostgreSQL applications work with minimal changes
- Standard ORMs (Hibernate, Django, ActiveRecord) are supported
- SQL syntax is largely compatible with PostgreSQL
Next Steps
Ready to get started?- Follow the Quick Start Guide to run your first cluster
- Review Installation Options for production deployments
- Explore the official documentation for in-depth guides