Why this lab exists
Every shared mutable state problem in a distributed system has the same root cause: two nodes update the same thing at the same time, with no coordinator to serialize the writes. The standard answer is a lock or a leader election. Both work. Both have a cost: the coordinator is a single point of failure and a scalability bottleneck.
CRDTs (Conflict-free Replicated Data Types) take a different route. Instead of preventing conflicts, they design data structures where conflicts are mathematically impossible. The merge function is defined such that no matter which order you apply updates, you always get the same result. There is nothing to resolve — the math resolves it for you.
This is not a theoretical curiosity. Amazon’s shopping cart uses a CRDT so that items added in parallel on different devices always end up merged, never lost. Apple’s Notes app uses a CRDT for offline edits. Redis Enterprise uses CRDTs for active-active geo-replication across regions. Figma’s multiplayer canvas is built on CRDTs.
After this lab you will understand why merge = max is correct for counters, why 2P-Set’s “no re-add” rule is the price you pay for simplicity, why OR-Set’s unique tags solve that problem, and why delta-state CRDTs are 100x more bandwidth-efficient than shipping full state. All of it comes down to three algebraic laws: commutativity, associativity, idempotency.
What we’re building
A CRDT library in Go across three stages, from trivial to production-relevant.
We build:
GCounterandPNCounter: the two canonical counter CRDTsGSetandTwoPhaseSet: grow-only and tombstone-based setsORSet: observed-remove set with unique tags — solves the 2P-Set re-add problemLWWRegister: last-write-wins register with timestamp tie-breakingCausalContext: vector clock tracking which operations each node has seenDeltaGCounterandCrdtNode: delta-state protocol for bandwidth-efficient sync
We explicitly skip:
- Op-based CRDTs (CmRDTs) — require reliable delivery, which is a transport problem
- RGA for collaborative text editing — requires a separate lab; it is the hardest CRDT
- Production serialization — we use Go types; Automerge uses WASM-compatible binary
- Network transport — merge is a pure function; gossip is the separate Gossip Protocol lab
Mental model
A CRDT must satisfy three laws. If your data structure satisfies these, concurrent updates always converge.
Commutativity: Merge(a, b) == Merge(b, a)
Associativity: Merge(Merge(a, b), c) == Merge(a, Merge(b, c))
Idempotency: Merge(a, a) == a
For GCounter, merge = max per node satisfies all three. Taking the max is commutative (max(2, 5) == max(5, 2)), associative (max(max(2, 5), 3) == max(2, max(5, 3))), and idempotent (max(5, 5) == 5). No coordinator required.
The key design principle: make the state space monotone. A CRDT’s state only ever moves in one direction — values only increase (GCounter), elements are only ever added to tombstone sets (2P-Set), tag sets only grow (OR-Set). Monotone functions cannot create divergence because there is no “going back” that could conflict with an earlier state.
State progression (monotone, never reverses):
GCounter: 0 → 1 → 2 → 3 → ...
GSet: {} → {a} → {a,b} → {a,b,c} → ...
OR-Set tags: {} → {tag1} → {tag1,tag2} → ... (remove clears tags, new adds add new ones)
Full state vs. delta state: In v0/v1, merging requires shipping the entire state — a 100-node GCounter ships 100 entries. In v2 (delta-state), you ship only the entries that changed since the receiver last synced — typically 1 entry for a single increment. This is the 97% bandwidth reduction the benchmarks show.
Prerequisites
Go generics (type parameters — [T comparable]) are used extensively in v0 and v1. Basic distributed systems familiarity helps: understanding CAP theorem makes the motivation clear. Vector clocks (causal context in v2) are covered in the Logical Clocks lab if you need background.
Stage-by-stage build
Stage 0 State-Based CRDTs
- Implement GCounter with map[string]int64 — one entry per node ID
- Implement PNCounter as two GCounters (positive, negative)
- Implement GSet[T comparable] with map[T]struct{}
- Implement TwoPhaseSet[T] with add-set and tombstone-set
- Write 12 tests covering concurrent increments, CRDT laws (commutativity, idempotency, associativity)
The simplest CRDTs establish the pattern that everything else follows: the merge function defines the data structure.
GCounter is the canonical example. Each node in your cluster gets one slot in a map[string]int64. A node can only increment its own slot. The global value is the sum. Merge takes the max per slot.
type GCounter struct {
counts map[string]int64
}
func (g *GCounter) Increment(nodeID string) {
g.counts[nodeID]++
}
func (g *GCounter) Value() int64 {
var total int64
for _, v := range g.counts {
total += v
}
return total
}
// Merge = max per node. This is the core invariant.
func (g *GCounter) Merge(other GCounter) {
for nodeID, count := range other.counts {
if count > g.counts[nodeID] {
g.counts[nodeID] = count
}
}
}Why “max per node” is correct: Suppose nodeA has seen 5 increments and nodeB has seen 3 from nodeA (an older snapshot). If you sum them, you double-count. If you take the max, you get 5 — exactly right, because the higher count subsumes the lower one. Convergence is guaranteed because max is monotone: it never decreases.
PNCounter extends GCounter to support decrements by using two GCounters. The observable value is positive.Value() - negative.Value(). Both counters can only grow (GCounters are grow-only), so the subtract is computed at read time, not stored.
type PNCounter struct {
positive GCounter
negative GCounter
}
func (p *PNCounter) Decrement(nodeID string) {
p.negative.Increment(nodeID)
}
func (p *PNCounter) Value() int64 {
return p.positive.Value() - p.negative.Value()
}GSet is trivially a CRDT: add-only sets merge by union, and union is commutative, associative, and idempotent. The implementation is a map[T]struct{} and Merge just copies every key.
TwoPhaseSet (2P-Set) adds remove support via a tombstone set. An element is “in” the 2P-Set if it is in the add-set and NOT in the tombstone set. Remove puts the element in the tombstone set. Merge does union on both underlying GSets independently.
The crucial limitation: once an element is tombstoned, it can never be re-added. The tombstone is in the add-set forever. Adding it again puts it back in the add-set but it is still in the tombstone — so the lookup still returns false. This is the problem ORSet solves in v1.
func (s *TwoPhaseSet[T]) Contains(elem T) bool {
return s.added.Contains(elem) && !s.tombstone.Contains(elem)
}The 12 tests cover: GCounter concurrent increments converge, PNCounter goes negative, GSet union, 2P-Set add-then-remove, 2P-Set cannot re-add, commutativity for all four types, idempotency for GCounter and GSet, associativity for GCounter.
Stage 1 OR-Set and LWW-Register
- Implement ORSet[T] with unique (nodeID, counter) tags per add operation
- Remove deletes all observed tags; re-add creates a new tag
- Implement LWWRegister[T] with timestamp ordering and lexicographic nodeID tie-break
- Write 8 tests: ORSet re-add, concurrent add+remove convergence, LWW ordering, tie-break, merge commutativity
2P-Set has one fundamental problem: you cannot re-add an element after it has been removed. This seems like a minor issue until you model a shopping cart (add item, remove item, add again) or a collaborative to-do list. ORSet solves this with unique tags.
ORSet: the key insight. Each call to Add(nodeID, elem) attaches a unique tag to the element. The tag is a (nodeID, counter) pair — no UUID library needed. Remove(elem) deletes all currently observed tags for that element. Merge takes the union of all tag sets. An element is “in” the ORSet if its tag set is non-empty.
type tag struct {
NodeID string
Counter uint64
}
type ORSet[T comparable] struct {
tags map[T]map[tag]struct{}
}
func (s *ORSet[T]) Add(nodeID string, elem T) {
// Generate a unique tag for this specific add operation.
t := tag{NodeID: nodeID, Counter: globalCounter.Add(1)}
if s.tags[elem] == nil {
s.tags[elem] = make(map[tag]struct{})
}
s.tags[elem][t] = struct{}{}
}
func (s *ORSet[T]) Remove(elem T) {
// Remove all currently observed tags — any tags added AFTER this point
// by concurrent nodes will not be affected.
delete(s.tags, elem)
}
func (s *ORSet[T]) Contains(elem T) bool {
return len(s.tags[elem]) > 0
}
// Merge = union of tag sets. Tags only ever appear, never disappear.
func (s *ORSet[T]) Merge(other ORSet[T]) {
for elem, otherTags := range other.tags {
if s.tags[elem] == nil {
s.tags[elem] = make(map[tag]struct{})
}
for t := range otherTags {
s.tags[elem][t] = struct{}{}
}
}
}Why concurrent add+remove converges to “present”: Suppose nodeA removes "x" (deleting its old tags) while nodeB concurrently re-adds "x" (generating a new tag). NodeB’s new tag was not in nodeA’s observation at remove time, so it is not deleted. After merge, nodeB’s tag survives, so "x" is present. This is “add-wins” semantics for concurrent operations — the expected behavior for a shopping cart.
LWWRegister is the simplest register CRDT. It holds one value and resolves concurrent writes by keeping whichever has the higher timestamp. Ties are broken by the node ID (lexicographic order), which ensures determinism even with synchronized clocks.
type LWWRegister[T any] struct {
value T
timestamp int64
nodeID string
}
func (r *LWWRegister[T]) Set(nodeID string, value T, timestamp int64) {
if timestamp > r.timestamp {
r.value, r.timestamp, r.nodeID = value, timestamp, nodeID
return
}
if timestamp == r.timestamp && nodeID > r.nodeID {
r.value, r.nodeID = value, nodeID
}
}
func (r *LWWRegister[T]) Merge(other LWWRegister[T]) {
r.Set(other.nodeID, other.value, other.timestamp)
}The tie-break rule (nodeID > r.nodeID) is arbitrary but must be consistent. Both replicas apply the same rule and converge to the same winner. In production, Cassandra uses nodeID tie-breaking in exactly this way when timestamps collide.
The 8 tests cover: ORSet re-add after remove, concurrent add+remove converges to present, ORSet merge commutativity, LWW timestamp ordering (higher wins), LWW tie-break (larger nodeID wins), LWW merge idempotency, LWW empty register has no value, ORSet self-merge idempotency.
Stage 2 Delta-State CRDTs
- Implement CausalContext (vector clock) tracking what each node has seen
- Implement DeltaGCounter: Increment() returns a 1-entry delta instead of full state
- Implement CrdtNode: GenerateDeltaFor(peerID) returns only entries the peer has not seen
- Write 5 tests: delta smaller than full state, delta application idempotent, causal context detects duplicates, two nodes converge, per-peer delta tracking
v0 and v1 solve correctness. v2 solves efficiency. Shipping full state on every sync is fine for 2 nodes. For 100 nodes exchanging state every second, each node sends 100 entries × 10 gossip partners = 1,000 entries/second. Delta-state reduces this to 1 entry × 10 partners = 10 entries/second — 100x less bandwidth.
CausalContext is a vector clock: map[string]uint64 where each entry is nodeID -> highest seqno seen from that node. This captures exactly what a replica has applied, and allows computing the difference with another replica.
type CausalContext struct {
clock map[string]uint64
}
func (c *CausalContext) IsNew(nodeID string, seqno uint64) bool {
return seqno > c.clock[nodeID]
}
func (c *CausalContext) Merge(other CausalContext) {
for nodeID, seqno := range other.clock {
if seqno > c.clock[nodeID] {
c.clock[nodeID] = seqno
}
}
}DeltaGCounter wraps GCounter with delta-state protocol. Increment() returns a delta — a GCounter containing only the changed entry:
func (d *DeltaGCounter) Increment() GCounter {
d.seqno++
d.state.Increment(d.nodeID)
d.context.Observe(d.nodeID, d.seqno)
// Delta = just this node's updated entry. Not the full N-entry state.
delta := NewGCounter()
delta.counts[d.nodeID] = d.state.counts[d.nodeID]
return delta
}GenerateDelta(peerContext) computes what a peer is missing. For each entry in our full state, if the peer’s causal context shows a smaller value, include it in the delta:
func (d *DeltaGCounter) GenerateDelta(peerContext CausalContext) GCounter {
delta := NewGCounter()
for nodeID, count := range d.state.counts {
if uint64(count) > peerContext.SeenFrom(nodeID) {
delta.counts[nodeID] = count
}
}
return delta
}CrdtNode orchestrates the per-peer delta tracking. It maintains a peerContexts map[string]CausalContext so it knows exactly what each peer has seen. GenerateDeltaFor(peerID) uses the stored peer context to return only what that specific peer needs.
type CrdtNode struct {
nodeID string
counter DeltaGCounter
peerContexts map[string]CausalContext
}
func (n *CrdtNode) GenerateDeltaFor(peerID string) GCounter {
peerCtx := n.peerContexts[peerID]
return n.counter.GenerateDelta(peerCtx)
}
func (n *CrdtNode) AcknowledgeDelta(peerID string, delta GCounter) {
ctx := n.peerContexts[peerID]
for nodeID, count := range delta.counts {
ctx.Observe(nodeID, uint64(count))
}
n.peerContexts[peerID] = ctx
}Delta application is idempotent. The delta is a GCounter; applying it uses max per entry, which is idempotent. If the network delivers the same delta twice, the second application changes nothing.
The causal context prevents wasted work. Before applying a received delta, check context.IsNew(nodeID, seqno). If not new, skip it — this entry was already applied. In a gossip network with multiple paths, the same delta may arrive from two different peers. Without the causal context check, you would apply it twice (harmlessly, due to idempotency, but wastefully).
The bandwidth proof is in the tests: TestDeltaGCounter_DeltaSmallerThanFullState creates a 100-node system, increments one node, and checks that the resulting delta has 1 entry while the full state has ~100 entries.
Run it yourself
labs/crdt ↗
Go 1.23+ - 1 Clone and build
git clone https://github.com/pushkarkumar-dev/system-design-labs cd system-design-labs/labs/crdt go build ./... - 2 Run all tests (25 tests across v0, v1, v2)
go test ./... -v -timeout 60s - 3 Run benchmarks
go test -bench=. -benchmem -benchtime=3s ./... - 4 Run the interactive demo (starts HTTP server on :8090)
go run ./cmd/demo - 5 Read the GCounter value from the demo server
curl http://localhost:8090/counter | jq . - 6 Increment the counter from two different nodes
curl -X POST http://localhost:8090/counter/inc -d 'node=nodeA' curl -X POST http://localhost:8090/counter/inc -d 'node=nodeB' - 7 Demo the ORSet re-add property
curl -X POST http://localhost:8090/orset/add -d 'node=nodeA&elem=alice' curl -X POST http://localhost:8090/orset/remove -d 'elem=alice' curl -X POST http://localhost:8090/orset/add -d 'node=nodeB&elem=alice' curl http://localhost:8090/orset | jq .
{
"value": 3,
"entries": {
"nodeA": 1,
"nodeB": 1,
"default": 1
}
} Benchmarks
M2 MacBook Pro, 16GB RAM | Metric | Result | Notes |
|---|---|---|
| GCounter.Merge (2 nodes) | 45,000,000 merges/sec | estimated — map iteration, 2 entries |
| GCounter.Merge (100 nodes) | ~900,000 merges/sec | estimated — O(N) merge cost |
| ORSet.Add (100-element set) | 2,500,000 adds/sec | estimated — atomic counter + map write |
| ORSet.Merge (two 100-element sets) | 800,000 merges/sec | estimated — tag set union |
| DeltaGCounter delta size vs full state | 97 % smaller | single-node increment: delta = 1 entry, full state = all N entries |
Stress tests
What breaks at 100 nodes? The full-state GCounter merge is O(N) in the number of nodes. At 100 nodes, each merge processes 100 entries. For a gossip cluster where every node syncs with 10 peers every second, that is 100 entries × 10 merges × 100 nodes = 100,000 entries processed per second cluster-wide — manageable. At 10,000 nodes it becomes 1,000,000 entries/second. Delta-state reduces this to 1 entry × 10 × 10,000 = 100,000 entries/second regardless of cluster size: the delta size does not grow with N.
OR-Set tag accumulation: Over time, an ORSet accumulates tags from many add operations. If a node adds and removes an element 1000 times, the tombstoned tags are deleted on each remove, but the new tags grow. In our implementation, each Add call clears old tags for that element before adding the new one — so tag sets stay small (at most one tag per add site per element). Production implementations like Automerge track tombstones separately in the causal context, not in the element’s tag set.
LWW clock skew: LWWRegister depends on timestamp being meaningful. If two nodes have their clocks skewed by more than the write rate, one node’s writes will always lose. Test this by setting timestamp = 0 on one node and observing that the other node’s writes always win. The fix in production is a Hybrid Logical Clock (HLC): max(wallClock, lastSeenHLC) + 1. HLC gives monotone timestamps even with NTP adjustments.
Delta idempotency under network retries: The delta application test (TestDeltaGCounter_DeltaApplicationIdempotent) applies the same delta twice and verifies the value does not change. This is the property that makes delta-state CRDTs safe over unreliable networks: duplicate deliveries are harmless. Run this test with -count=100 to verify it never fails.
What the toy misses
- Op-based CRDTs (CmRDTs) Our library uses state-based merge. Operation-based CRDTs ship operations instead of state — they require reliable exactly-once delivery, which in practice needs a sequence number and acknowledgement protocol.
- RGA (Replicated Growable Array) for text RGA is the CRDT behind Google Docs-style collaborative editing. Each character gets a unique timestamp (Lamport clock + node ID). Insertion ordering and tombstone compaction require careful implementation.
- Garbage collection for tombstones 2P-Set and OR-Set tombstones grow forever. Production implementations use causal garbage collection: a tombstone can be deleted once all replicas have seen the remove operation (via causal context).
- Network transport and anti-entropy Our merge is a pure function — it does not know how to find peers. Production CRDTs run a gossip-based anti-entropy protocol to periodically sync with random peers and detect divergence.
- JSON serialization for cross-language use Our types are Go-specific. Production CRDT libraries like Automerge use binary encoding (WASM-compilable) so the same CRDT state is shared between browser, server, and mobile clients.
- CRDT composition Composing CRDTs (e.g., a map of OR-Sets) requires that the map's merge operation correctly delegates to each value's merge. Getting the algebraic laws right across compositions is the hard part.
Wiring it into a Java/Spring service
Wiring it into a Java/Spring service
org.springframework.boot:spring-boot-starter-web:3.3.0 org.springframework.boot:spring-boot-starter-actuator:3.3.0 labs/crdt/java-integration Clone and run: cd labs/crdt/java-integration && mvn spring-boot:run Why this integration matters
CRDTs appear in the Java/JVM ecosystem in several places. Apache Cassandra uses LWW registers for column values in its TIMESTAMP resolution. Hazelcast IMDG’s CPMap uses Raft-backed linearizable semantics, but its IMap with merge policies uses CRDT-inspired merge functions. Akka Distributed Data is an explicit CRDT library for Scala/Java — it ships GCounter, PNCounter, ORSet, and LWWRegister as production-ready cluster primitives.
This integration shows two things: first, that the GCounter merge algorithm is identical in Go and Java (it is a map operation, not a framework). Second, how a Java service can consume a Go CRDT server over HTTP using Spring’s RestClient.
Part A — Java GCounter: the algorithm is language-agnostic
The Go GCounter is 40 lines of map operations. The Java port is the same 40 lines using HashMap and Math.max. CRDTs are algorithms, not runtime features.
public final class GCounter {
private final Map<String, Long> counts = new HashMap<>();
public void increment(String nodeId) {
counts.merge(nodeId, 1L, Long::sum);
}
public long value() {
return counts.values().stream().mapToLong(Long::longValue).sum();
}
// Merge = max per node. Identical to the Go implementation.
public void merge(GCounter other) {
other.counts.forEach((nodeId, count) ->
counts.merge(nodeId, count, Math::max)
);
}
}Map.merge(key, value, remappingFunction) is Java 8+. It inserts value if the key is absent, or applies remappingFunction(existingValue, value) if present. Using Math::max as the remapping function is exactly the GCounter merge rule: take the max, one line.
The demo simulates two Java nodes each incrementing a shared GCounter and then merging — the same scenario as the Go demo, but running entirely in the JVM with no network:
GCounter nodeA = new GCounter();
GCounter nodeB = new GCounter();
for (int i = 0; i < 5; i++) nodeA.increment("java-nodeA");
for (int i = 0; i < 3; i++) nodeB.increment("java-nodeB");
GCounter merged = nodeA.copy();
merged.merge(nodeB);
// merged.value() == 8 — same result regardless of merge orderPart B — CrdtClient: REST bridge to the Go demo server
CrdtClient wraps the Go demo server’s five HTTP routes using Spring Framework 6.1’s RestClient. Java 17 records make the response DTOs zero-boilerplate.
public class CrdtClient {
private final RestClient http;
public CrdtClient(String baseUrl) {
this.http = RestClient.builder().baseUrl(baseUrl).build();
}
public CounterResponse getCounter() {
return http.get().uri("/counter").retrieve().body(CounterResponse.class);
}
public CounterResponse incrementCounter(String node) {
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.add("node", node);
return http.post().uri("/counter/inc")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.body(form).retrieve().body(CounterResponse.class);
}
public ORSetResponse addToORSet(String node, String elem) {
// ... same pattern — form POST to /orset/add
}
// Java 17 records — immutable DTOs with no boilerplate
public record CounterResponse(long value, Map<String, Long> entries) {}
public record ORSetResponse(List<String> elements, int size) {}
}Part C — CrdtAutoConfiguration: Spring wiring
@Configuration
@EnableConfigurationProperties(CrdtProperties.class)
public class CrdtAutoConfiguration {
@Bean
public CrdtClient crdtClient(CrdtProperties props) {
return new CrdtClient(props.baseUrl());
}
}
@ConfigurationProperties(prefix = "crdt")
public record CrdtProperties(String baseUrl, String nodeId) {
public CrdtProperties {
if (baseUrl == null || baseUrl.isBlank()) baseUrl = "http://localhost:8090";
if (nodeId == null || nodeId.isBlank()) nodeId = "java-node";
}
}application.yml
crdt:
base-url: http://localhost:8090
node-id: java-node
management:
endpoints:
web:
exposure:
include: health, info, metrics
endpoint:
health:
show-details: alwaysRun it
# Terminal 1: start the Go CRDT demo server
cd labs/crdt
go run ./cmd/demo
# Terminal 2: run the Spring Boot demo
cd labs/crdt/java-integration
mvn spring-boot:runExpected output (Part A always runs; Part B requires the Go server):
=== CRDT Library — Java/Spring Integration Demo ===
Part A: Pure Java GCounter (no server needed)
nodeA local value: 3
nodeB local value: 2
merged value: 5 (expected 5)
entries: {java-nodeA=3, java-nodeB=2}
Commutativity holds: true (Merge(a,b)=5 == Merge(b,a)=5)
Part B: CrdtClient — connecting to Go demo server at http://localhost:8090
Go server status: up
Simulating two Java nodes incrementing shared counter...
Shared counter value: 5
Per-node breakdown: {java-nodeA=2, java-nodeB=3}
ORSet demo — re-add after remove:
After adding alice, bob: [alice, bob]
After removing alice: [bob]
After re-adding alice: [alice, bob] (ORSet allows re-add!)
Demo complete. Actuator available at /actuator/healthRun the tests
cd labs/crdt/java-integration
mvn testThe six unit tests cover: increment accumulates, merge takes max per node, merge is commutative, merge is idempotent, merge is associative, two nodes converge after mutual merge. All tests use the pure Java GCounter — no live Go server required.
Comparing to Akka Distributed Data
Akka’s GCounter has identical semantics: increment(node, delta), value(), and a merge function that takes max per node. The implementation is in Scala, not Go, but the algorithm is the same. The difference is that Akka’s CRDT ships with a production cluster membership layer (using gossip, similar to our Gossip Protocol lab), automatic anti-entropy, and Protobuf serialization for cross-node sync. Our implementation is the core algorithm without the cluster scaffolding — which makes the merge semantics visible without the noise.
What surprised me
Where to go deeper
- Shapiro et al. (2011) — the canonical CRDT survey paper: inria.hal.science/inria-00555588. Dense but short; the algebra section (Section 2) is the foundation everything else builds on.
- Automerge — production CRDT library with WASM support: automerge.org. Best reference for how OR-Set and sequence CRDTs are implemented in a real collaborative editor.
- Akka Distributed Data — production Scala/Java CRDT library: doc.akka.io/distributed-data. Shows how GCounter, ORSet, and LWWRegister look in a production cluster framework.
- Redis Enterprise active-active — Redis’s CRDT implementation for geo-replication: redis.com/active-active. Shows CRDTs at commercial scale.
- Martin Kleppmann’s “Designing Data-Intensive Applications” — Chapter 9 covers consistency models that CRDTs operate within; Chapter 5 covers replication lag that CRDTs are designed to tolerate.
Related labs and questions
- Prerequisite understanding: Logical Clocks — the causal context (v2) is a vector clock; the Logical Clocks lab builds Lamport clocks and vector clocks from scratch
- Next in distributed: Gossip Protocol — the anti-entropy layer that CRDTs need to actually sync across a cluster; without gossip, CRDTs are pure functions with no transport
- System design companion: designing a collaborative document editor — why Figma chose CRDTs over OT (operational transformation), and what they gave up
- Follow-up question: can you build a map CRDT (where keys map to OR-Set values) that satisfies all three CRDT laws? What happens when two nodes concurrently delete the same key and add a value to it?