Skip to content

CockroachDB

Distributed SQL database with global consistency — PostgreSQL-compatible, survive anything, scale horizontally.

Overview

CockroachDB is a distributed SQL database that provides serializable ACID transactions, horizontal scaling, and multi-region survivability — all behind a PostgreSQL-compatible wire protocol. Data is automatically sharded into ranges, replicated via Raft consensus, and rebalanced across nodes. It survives disk, node, rack, and even datacenter failures without manual intervention.

Key Facts

Attribute Detail
Website cockroachlabs.com
Stars ~31k+ ⭐
Latest Version v26.1 (2026)
Language Go
License BSL 1.1 (core) / CCL (enterprise features)
Company Cockroach Labs
Wire Protocol PostgreSQL-compatible

Evaluation

Pros Cons
Survive datacenter failures automatically BSL 1.1 license
PostgreSQL wire protocol compatible Higher latency than single-node PG
Serializable isolation (strongest ACID) Complex to tune for specific workloads
Horizontal scaling, automatic rebalancing Expensive (especially managed CockroachDB Cloud)
Data locality / geo-partitioning Single-row writes slower than PG
Built-in vector search (v26.1)
AI/agent-ready governance

Architecture

flowchart TB
    subgraph Cluster["CockroachDB Cluster"]
        subgraph Node1["Node 1"]
            SQL1["SQL Layer\n(PG wire protocol)"]
            KV1["Distributed KV"]
            Ranges1["Ranges\n(R1, R4, R7)"]
        end
        subgraph Node2["Node 2"]
            SQL2["SQL Layer"]
            KV2["Distributed KV"]
            Ranges2["Ranges\n(R2, R5, R8)"]
        end
        subgraph Node3["Node 3"]
            SQL3["SQL Layer"]
            KV3["Distributed KV"]
            Ranges3["Ranges\n(R3, R6, R9)"]
        end
    end

    Client["App (PG driver)"] --> SQL1
    Ranges1 <-->|"Raft replication"| Ranges2
    Ranges2 <-->|"Raft replication"| Ranges3

    style Cluster fill:#6933ff,color:#fff

Key Features (v26.1)

Feature Detail
Raft consensus Strong consistency, automatic leader election
Range-based sharding Automatic split/merge at 64MB boundaries
Geo-partitioning Pin data to regions for sovereignty/latency
Vector search Built-in similarity search (no separate vector DB)
CDC Streaming to Kafka, cloud storage
Zero-downtime DDL Online schema changes, no maintenance windows
AI agent governance Zero-trust access for AI workloads
Multi-region Active-active across datacenters

Sources