@@ -4,15 +4,33 @@ summary: CockroachDB implements consistent replication via majority consensus be
4
4
toc : false
5
5
---
6
6
7
- CockroachDB replicates your data multiple times and guarantees consistency between replicas
8
- using the [ Raft consensus algorithm] ( https://raft.github.io/ ) , a popular alternative to
9
- [ Paxos] ( http://research.microsoft.com/en-us/um/people/lamport/pubs/paxos-simple.pdf ) .
10
- A consensus algorithm guarantees that any majority of replicas together can always provide
11
- the most recently written data on reads. Writes must reach a majority of replicas (2 out of
12
- 3 by default) before they are considered committed. If a write does not reach a majority of
13
- replicas, it will fail, not be permanent, and will never be visible to readers. This means
14
- that clients always see serializable consistency when viewing data (i.e., stale reads are
15
- not possible).
7
+ CockroachDB replicates your data multiple times and guarantees consistency between replicas.
8
+
9
+ How does this work?
10
+
11
+ - Stored data is versioned with MVCC, so reads simply limit
12
+ their scope to the data visible at the time the read transaction started.
13
+
14
+ - Writes are serviced using the
15
+ [ Raft consensus algorithm] ( https://raft.github.io/ ) , a popular
16
+ alternative to
17
+ [ Paxos] ( http://research.microsoft.com/en-us/um/people/lamport/pubs/paxos-simple.pdf ) .
18
+ A consensus algorithm guarantees that any majority of replicas
19
+ together always agree on whether an update was committed
20
+ successfully. Updates (writes) must reach a majority of replicas (2
21
+ out of 3 by default) before they are considered committed. If an
22
+ update does not reach a majority of replicas, it will fail, not be
23
+ permanent, and will never be visible to readers.
24
+
25
+ To ensure that a write transaction does not interfere with
26
+ read transactions that start after it, CockroachDB also uses
27
+ a [ timestamp cache] ( https://www.cockroachlabs.com/blog/serializable-lockless-distributed-isolation-cockroachdb/ )
28
+ which remembers when data was last read by ongoing transactions.
29
+
30
+ This ensures that clients always observe serializable consistency
31
+ with regards to other concurrent transactions.
32
+
33
+ Key properties:
16
34
17
35
- No downtime for server restarts, machine failures, or datacenter outages
18
36
- Local or wide-area replication with no stale reads on failover
@@ -24,3 +42,6 @@ not possible).
24
42
25
43
- [ Consensus, Made Thrive] ( https://www.cockroachlabs.com/blog/consensus-made-thrive/ )
26
44
- [ Trust, But Verify: How CockroachDB Checks Replication] ( https://www.cockroachlabs.com/blog/trust-but-verify-cockroachdb-checks-replication/ )
45
+ - [ Serializable, Lockless, Distributed: Isolation in CockroachDB] ( https://www.cockroachlabs.com/blog/serializable-lockless-distributed-isolation-cockroachdb/ )
46
+ - [ Living Without Atomic Clocks] ( https://www.cockroachlabs.com/blog/living-without-atomic-clocks/ )
47
+ - [ The CockroachDB Architecture Document] ( https://github.com/cockroachdb/cockroach/blob/master/docs/design.md )
0 commit comments