gitmyhub

cockroach

Go ★ 32k updated 5d ago

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.

CockroachDB is a distributed SQL database that spreads your data across multiple machines automatically, so your app keeps running even if a server goes down, while still speaking standard PostgreSQL so your existing code works.

GoPostgreSQL protocolRaftsetup: hardcomplexity 4/5

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.

Where it fits