PROVIDER - Distributed SQL database

CockroachDB

CockroachDB is a distributed SQL database founded around 2015 by former Google Bigtable engineers, Postgres compatible with multi-region strong consistency and automatic failure recovery.

Backend & Database United States 2026.11.15
4.3pts

Service Overview

CockroachDB was founded around 2015 by former Google Bigtable engineers in the United States, aiming for distributed SQL that never loses data, scales horizontally, and speaks the Postgres protocol. Data is split into ranges, replicated across nodes, and rebalanced automatically when nodes fail.

For Backend & Database work it addresses cross-region reads and disaster tolerance, spreading replicas across zones or regions so a zone failure still serves requests, and it suits order or ledger workloads that cannot accept eventual consistency.

The limits are complexity and cost, since multi-region latency and write amplification require understanding, operations and tuning are harder than single-node Postgres, and node or request-based cloud plans need real load testing. It fits mid-to-large systems with hard availability requirements.

Key Strengths

  • Postgres protocol and syntax compatibility keeps ORMs and drivers working
  • Automatic replication and rebalancing recover from node or zone failures
  • Multi-region deployment supports nearby reads through locality settings
  • Both serverless and dedicated cluster forms are available

Product Ecosystem

Multi-region topology

Replicas spread by region with table locality deciding placement. Decide where data lives and where reads come from first, or cross-region round trips slow every query.

Transactions and consistency

Serializable transactions stay consistent across shards, and ledger workloads need retry logic and conflict handling.

Backup and disaster recovery

Scheduled full backups and point-in-time recovery can span regions, with recovery drills advisable in production.

Limitations

  • Cross-region latency, write amplification, and locality tuning demand specific expertise
  • Operations and tuning are more complex than single-node Postgres
  • Node or request billing can be pushed up significantly by cross-region traffic
  • Third-party tooling trails mainstream MySQL and Postgres ecosystems

Use Cases

  • Cross-region high availability (★★★★★) - Zone failures still serve traffic
  • Order and ledger consistency (★★★★☆) - Serializable transactions stay consistent across shards
  • Lightweight single-node apps (★★) - Complexity and cost favour Postgres
  • Teams wanting minimal operations (★★☆) - Managed Postgres fits better

Pricing

Plan Price Scope
Serverless Per request and storage For variable traffic and validation
Dedicated clusters Per node size and count Steady high load
Enterprise Custom quote Compliance, support, and SLA

Billing is per request or per node with cross-region traffic priced separately. Treat the cross-region read and write ratio as the key variable, since architectures that hit remote regions pay in both cost and latency.

FAQ

  • How is it different from Postgres? It is protocol compatible but built on distributed storage and consensus with multi-region recovery and horizontal scale, while single-node Postgres is simpler with a richer ecosystem but no built-in cross-region recovery.

  • Is data really never lost? Replication and consensus target durability assuming sensible replica placement and configuration. Still configure backups and drills rather than treating high availability as backups.

  • Does it suit small projects? Usually not. Single-node or serverless Postgres costs less and operates more simply, and distributed SQL pays off only with multi-region, high-concurrency needs.

Code Examples

Start a local single node and create a table

# Single-node mode suits development; production needs a real cluster
cockroach start-single-node --insecure --store=./data \
  --listen-addr=localhost:26257 &

cockroach sql --insecure --host=localhost:26257 -e "
  CREATE DATABASE IF NOT EXISTS shop;
  USE shop;
  CREATE TABLE orders (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    customer_id INT NOT NULL,
    amount DECIMAL(12,2) NOT NULL,
    created_at TIMESTAMPTZ DEFAULT now()
  );
  INSERT INTO orders (customer_id, amount) VALUES (1001, 99.50);"

--insecure is local-only; once TLS is enabled, nodes need the certificate directory via --certs-dir to handshake.

Convert a table into a multi-region, row-local table

-- Declare the primary and additional regions, then localise rows
ALTER DATABASE shop SET PRIMARY REGION "us-east1";
ALTER DATABASE shop ADD REGION "eu-west1";

ALTER TABLE shop.orders SET LOCALITY REGIONAL BY ROW;

-- Inspect where rows actually live
SELECT crdb_region, count(*) FROM shop.orders GROUP BY crdb_region;

After REGIONAL BY ROW, writes need crdb_region from the app or a sensible default, so switching tables without changing write paths adds cross-region latency.

Community & Resources

Communities and official channels

Learning resources and tools

Visit CockroachDB Website → https://www.cockroachlabs.com/
Visit Website ↗