Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 10 · From Scratch · Sharded KV store · about 18 min to read

Play it as a journeyTutor comes with a plan

A CRDT of your own

Replication
Replication · Open board

: copies of data on several machines, and what goes wrong when two of them accept writes at the same time. This lesson builds the data types that make that safe.

Before you start. KV: everything gave the store its repair step: two replicas, which are two machines holding copies of the same key, compare themselves and copy over what is newer. KV: quorum admitted that one version number per key cannot order two writers who write the same key at the same moment. Amazon, the case study told how Amazon put this kind of store under its shopping cart. Everyone edits offline: CRDTs and local-first sync tells the same idea as a story with one short program, and this lesson builds and tests it properly.

Lesson 76 of 117 in From Scratch

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • The cart that grew back
  • Three rules a merge must obey
  • A G-counter: one slot for each replica
  • An OR-set: tag every add
  • Text: give every letter a name that never changes
  • The code
  • Merge tested in any order
  • Break it
  • What it costs
  • Where it plugs into the store

Terms it explains: order does not matter, grouping does not matter, repeats do not matter, G-counter, CRDT, OR-set, tombstones, state-based, operation-based, CDC, eventual consistency, failover, leader/follower, leaderless, LWW, multi-leader, quorum, read repair / anti-entropy, read-your-writes / monotonic / consistent-prefix, replication lag, split brain, sync/async/semi-sync, version vector, write conflict.

Related papers

Review From Scratch