Favicon of CockroachDB

CockroachDB

CockroachDB is a distributed SQL database built for horizontal scale, strong consistency, and automatic failure recovery.

Open Source Alternative to:
CockroachDB website screenshot
CockroachDB GitHub repository preview

CockroachDB is a distributed SQL database built on a transactional, strongly-consistent key-value store. It's aimed at teams building data-intensive applications that need to scale horizontally, survive hardware and datacenter failures, and keep using SQL rather than switching to a NoSQL model. If you're running Postgres today and hitting scaling or availability limits, this is the kind of project worth evaluating.

The database speaks the PostgreSQL wire protocol, so existing drivers and ORMs generally work without a rewrite. It's written in Go and developed in the open on GitHub, with a public issue tracker and a "good first issue" label for new contributors.

Key features

  • Horizontal scaling: add nodes to a cluster to increase capacity, without re-architecting the application.
  • Automatic failure recovery: survives disk, machine, rack, and datacenter failures with minimal latency disruption and no manual failover steps.
  • Strong consistency: supports ACID transactions with serializable isolation across the distributed cluster.
  • SQL interface: a familiar SQL API for schema design, queries, and data manipulation, so teams don't need to learn a new query language.
  • PostgreSQL wire protocol compatibility: connect using standard PostgreSQL client drivers and ORMs across many languages.
  • Flexible deployment: run it yourself via manual deployment, on major cloud platforms, under common orchestration systems, or use the managed CockroachCloud offering.
  • Built-in SQL client: a command-line client ships with the database for quick local testing and exploration.

Ideal use cases

CockroachDB fits applications that need a relational data model but also need to survive node or region failures without downtime, such as financial systems, multi-region SaaS platforms, or any service where losing a database node can't mean losing availability. It also suits teams that expect to outgrow a single-node Postgres instance and want to scale by adding nodes instead of re-sharding manually.

It's a reasonable choice if you already rely on PostgreSQL drivers or ORMs and want to keep that tooling while moving to a distributed backend. Teams building multi-region or globally distributed apps that need data locality controls alongside strong consistency are also a good match.

It is not a good fit for simple, single-node applications where the operational overhead of running a distributed cluster outweighs the benefit. Teams with strict low-latency, single-digit-millisecond requirements on every query in a single region may find a traditional single-node database simpler and faster. It's also not the right pick if you need full PostgreSQL feature parity (extensions, stored procedures, specific PostgreSQL-only features) since compatibility is at the wire-protocol and SQL level, not a full drop-in replacement for every PostgreSQL capability.

Installation

There are two main paths to get started: run a managed cluster, or run CockroachDB yourself.

Managed option (CockroachCloud):

Follow the CockroachCloud Quickstart to create a free cluster on your preferred cloud platform, no local install required.

Self-hosted option:

  1. Install CockroachDB using a pre-built executable, or build it from source following the project wiki instructions.
  2. Start a local cluster:
cockroach start-single-node --insecure --listen-addr=localhost
  1. Connect to it with the built-in SQL client:
cockroach sql --insecure --host=localhost
  1. From there, use the SQL client to create databases, tables, and run queries.
  2. Connect from an application using any PostgreSQL-compatible driver or ORM in your language of choice.

For production deployments, the project documents manual multi-machine deployment, cloud-specific deployment guides, and orchestration guides for running CockroachDB under systems like Kubernetes.

Frequently asked questions

Share:

Stars
32.6K
Forks
4.1K
Last commit
4 days ago
Repository age
13 years
Self-hosted
No
Activity score
85/100
View Repository
Ad
Favicon

 

  
 

Similar to CockroachDB

Favicon

 

  
 
Favicon

 

  
 
Favicon