← Lab

CRDTs

Conflict-free replicated data types. Increment, write, add, remove — partition the network and watch them converge.

Counter: 0
connected connected connected
Select a CRDT type and interact with the nodes. Click an edge to partition or heal.

How G-Counters Work

A G-Counter (grow-only counter) is one of the simplest CRDTs — conflict-free replicated data types. Each node in the system maintains a vector of counts, one slot per node. When a node wants to increment, it only bumps its own slot. To read the counter value, you sum all slots.

The merge operation takes the pointwise maximum of two vectors. This is what makes it conflict-free: no matter what order merges happen in, or how many times you merge, you always converge to the same result. Mathematically, merge forms a join-semilattice — it's commutative, associative, and idempotent.

Try partitioning edges to split the network. Each side keeps incrementing independently. When you heal the partition, the nodes sync back up — no conflicts, no lost increments. That's the whole point of CRDTs.