Continue where you left off ×
Everyone edits offline: CRDTs and local-first sync
Neither OT nor CRDT · Open board
The two classic ways to merge edits from many people, and why Figma chose neither. This lesson builds the second one, the CRDT, from the smallest piece up.
Before you start. You need The log is the truth (event sourcing and CQRS) : a log is a list of events that only grows, and replaying it rebuilds the state. You need The copy clerks (database replication) : a copy of the data on another machine is a replica, and two places that accept writes can disagree. And Consistency and Consensus gave you the idea that two events can be concurrent, meaning neither one saw the other.
The idea in 30 seconds
A replica is one copy that accepts changes on its own, and convergence means all replicas end equal.
A CRDT is data whose merge ignores order, grouping and repeats, so no coordinator is needed.
A G-counter gives each replica its own slot, merges by taking the larger value per slot, and reads by adding.
An OR-set tags every add, so a remove only deletes the adds it saw.
A sequence CRDT gives each letter a permanent id and says “insert after that letter”, with a fixed tie-break.
The price is extra stored data, and the gain is edits that work with no network.
Read the story
Lesson 36 of 115 in System Design
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 plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson Two people, one note, no signal A replica is one copy that accepts changes by itself Counting likes: each replica owns one slot A shopping list where add and remove can happen at once Typing text: every letter gets a name that never changes What you get, and what it costs The G-counter, the OR-set and the sequence, run Two ways to merge: state and operations Operational transform, and why the two differ What a CRDT cannot do Sync engines and local-first apps Choosing Terms it explains: replica, convergence, G-counter, CRDT, OR-set, sequence CRDT, Common mistakes, state-based, operation-based, deltas, interleaving, moves, local-first, sync engine.
Review System Design
Mark as read Saved in this browser, and to your account when you sign in.