explaingit

cockroachdb/cockroach

📈 Trending32,165GoAudience · developerComplexity · 4/5ActiveLicenseSetup · hard

TLDR

A distributed SQL database that automatically spreads data across multiple machines, survives failures without downtime, and speaks PostgreSQL so existing tools work immediately.

Mindmap

mindmap
  root((CockroachDB))
    What it does
      Distributed SQL database
      Automatic failover
      Horizontal scaling
    Key features
      PostgreSQL compatible
      ACID transactions
      Multi-region support
    Tech stack
      Raft consensus
      Key-value store
      Go runtime
    Use cases
      Financial systems
      E-commerce platforms
      High-availability apps
    Deployment
      Self-hosted cluster
      CockroachCloud managed

Things people build with this

USE CASE 1

Build a financial application that must never lose transactions even if a data center fails.

USE CASE 2

Scale an e-commerce platform horizontally by adding more database nodes as traffic grows.

USE CASE 3

Run a multi-region service where data is automatically replicated across geographies for low latency and disaster recovery.

USE CASE 4

Migrate from PostgreSQL to a highly available database without rewriting application code.

Tech stack

GoPostgreSQL protocolRaftSQL

Getting it running

Difficulty · hard Time to first run · 1h+

Requires running multiple distributed nodes and understanding Raft consensus; non-trivial to set up a working multi-node cluster locally.

CockroachDB is available under the Business Source License (non-commercial use is free; commercial use requires a license) and also offers open-source editions under permissive licenses.

In plain English

CockroachDB is a distributed SQL database designed to be resilient, scalable, and cloud-friendly. Traditional databases like PostgreSQL run on a single server, if that server goes down or gets overloaded, your application breaks. CockroachDB solves this by spreading data across multiple machines automatically. If one machine fails, the others keep serving requests with no manual intervention required. It can also grow horizontally: adding more machines increases both storage capacity and throughput. Despite running across many nodes, CockroachDB behaves like a conventional relational database from the application's perspective. It speaks the PostgreSQL protocol, the standard communication format PostgreSQL uses, so existing PostgreSQL client libraries, ORMs (Object-Relational Mappers, which translate between database tables and programming objects), and tools work with it out of the box. You can run SQL queries, create tables, enforce foreign keys, and perform ACID transactions (operations that are atomic, consistent, isolated, and durable, meaning they either fully succeed or fully fail, with no partial results). Under the hood, CockroachDB stores data in a distributed key-value store and uses a consensus protocol called Raft to ensure all replicas of a piece of data agree on the same value, even when network partitions or machine failures occur. It handles replication, rebalancing, and failover automatically. You would use CockroachDB when building an application that needs strong consistency guarantees, SQL semantics, and the ability to survive regional or multi-datacenter outages without downtime. It is suited for financial applications, e-commerce platforms, and any system where data integrity and availability are both critical. The database is written in Go and available as a self-hosted cluster or as a managed cloud service called CockroachCloud.

Copy-paste prompts

Prompt 1
How do I set up a CockroachDB cluster with 3 nodes and configure replication across regions?
Prompt 2
Show me how to connect a Node.js app to CockroachDB using an existing PostgreSQL driver.
Prompt 3
What are the differences between CockroachDB and PostgreSQL for handling network partitions and node failures?
Prompt 4
How do I perform an ACID transaction in CockroachDB that spans multiple tables across a distributed cluster?
Prompt 5
Walk me through migrating a PostgreSQL schema and data to CockroachDB with minimal downtime.
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.