Choosing CockroachDB
CockroachDB is a distributed SQL database built on a transactional and strongly-consistent key-value store. It scales horizontally; survives disk, machine, rack, and even datacenter failures with minimal latency disruption and no manual intervention; supports strongly-consistent ACID transactions; and provides a familiar SQL API for structuring, manipulating, and querying data. CockroachDB is inspired by Google’s Spanner and F1 technologies. CockroachDB is well suited for applications that require reliable, available, and correct data, and millisecond response times, regardless of scale. It is built to automatically replicate, rebalance, and recover with minimal configuration and operational overhead. Specific use cases include:- Distributed or replicated OLTP
- Multi-datacenter deployments
- Multi-region deployments
- Cloud migrations
- Infrastructure initiatives built for the cloud
- CockroachDB Basic: A multi-tenant CockroachDB deployment, managed by Cockroach Labs. CockroachDB Basic provides highly available database clusters that scale instantly and automatically for small production and dev/test workloads.
- CockroachDB Standard: A multi-tenant CockroachDB deployment, managed by Cockroach Labs. CockroachDB Standard allows you to consolidate a variety of production workloads while optimizing cost.
- CockroachDB Advanced: A single tenant CockroachDB deployment, managed by Cockroach Labs. CockroachDB Advanced provides dedicated hardware to support stringent regulatory requirements and enhanced compliance, targeting production workloads with advanced Enterprise requirements.
- CockroachDB self-hosted: A self-managed CockroachDB deployment, backed by Cockroach Labs Support, for multiple clouds and regions. This deployment option is good if you require complete control over the database environment.
About the database
CockroachDB scales horizontally with minimal operator overhead. At the key-value level, CockroachDB starts off with a single, empty range. As you put data in, this single range eventually reaches . When that happens, the data , each covering a contiguous segment of the entire key-value space. This process continues indefinitely; as new data flows in, existing ranges continue to split into new ranges, aiming to keep a relatively small and consistent range size. When your cluster spans multiple nodes (physical machines, virtual machines, or containers), newly split ranges are automatically rebalanced to nodes with more capacity. CockroachDB communicates opportunities for rebalancing using a peer-to-peer gossip protocol by which nodes exchange network addresses, store capacity, and other information. For more information about scaling a CockroachDB cluster, see the following docs:- Different servers within a rack to tolerate server failures
- Different servers on different racks within a datacenter to tolerate rack power/network failures
- Different servers in different datacenters to tolerate large scale network or power outages
- Writes are serviced using the Raft consensus algorithm, a popular alternative to Paxos. A consensus algorithm guarantees that any majority of replicas together always agree on whether an update was committed successfully. Updates (writes) must reach a majority of replicas (2 out of 3 by default) before they are considered committed.
- Stored data is versioned with , so under
SERIALIZABLEisolation, .
SERIALIZABLE consistency while issuing multiple concurrent transactions.
The CAP theorem states that it is impossible for a distributed system to simultaneously provide more than two out of the following three guarantees:
- Consistency
- Availability
- Partition Tolerance
- Atomicity: Transactions in CockroachDB are “all or nothing.” If any part of a transaction fails, the entire transaction is aborted, and the database is left unchanged. If a transaction succeeds, all mutations are applied together with virtual simultaneity. For a detailed discussion of atomicity in CockroachDB transactions, see How CockroachDB Distributes Atomic Transactions.
- Consistency: SQL operations never see any intermediate states and move the database from one valid state to another, keeping indexes up to date. Operations always see the results of previously completed statements on overlapping data and maintain specified constraints such as unique columns. For a detailed look at how we’ve tested CockroachDB for correctness and consistency, see CockroachDB Beta Passes Jepsen Testing.
- Isolation: By default, transactions in CockroachDB implement the strongest ANSI isolation level: serializable (
SERIALIZABLE). This means that transactions will never result in anomalies. For more information about transaction isolation in CockroachDB, see . - Durability: In CockroachDB, every acknowledged write has been persisted consistently on a majority of replicas (by default, at least 2) via the Raft consensus algorithm. Power or disk failures that affect only a minority of replicas (typically 1) do not prevent the cluster from operating and do not lose any data.
- JavaScript/TypeScript
- Python
- Go
- Java
- Ruby
- C
- C#(.NET)
- Rust
root user has privileges for all databases, while unique users can be granted privileges for specific statements at the database and table-levels.
For more details, see our .

