Strong Consistency

CockroachDB replicates your data multiple times and guarantees consistency between replicas.

Key properties:

  • CockroachDB guarantees serializable SQL transactionsas long as system clocks are synchronized with NTP
  • No downtime for server restarts, machine failures, or datacenter outages
  • Local or wide-area replication with no stale reads on failover
  • Employs Raft, a popular successor to Paxos
    How does this work?

  • Stored data is versioned with MVCC, so reads simply limittheir scope to the data visible at the time the read transaction started.

  • Writes are serviced using theRaft consensus algorithm, a popularalternative toPaxos.A consensus algorithm guarantees that any majority of replicastogether always agree on whether an update was committedsuccessfully. Updates (writes) must reach a majority of replicas (2out of 3 by default) before they are considered committed.

To ensure that a write transaction does not interfere with read transactions that start after it, CockroachDB also uses a timestamp cache which remembers when data was last read by ongoing transactions.

This ensures that clients always observe serializable consistency with regards to other concurrent transactions.

Strong consistency in CockroachDB

See also

Was this page helpful?
YesNo