Two edits to the same profile, and the one that landed second was older
A social graph, multi-petabyte, read against roughly twenty-five times for every write. Rendering one page touches hundreds of entities and the relationships between them, and the graph is dense enough that no way of splitting the users makes cross-partition reads rare.
Two people edited the same profile within a second of each other. Both writes succeeded. The value that survived was the first one, because it took the slower path and arrived last, and nothing on the way had an opinion about which of them was later.
- R1The graph is dense: there is no way to divide the users so that cross-partition reads are rare. Anywhere that serves reads therefore needs the whole dataset available to it locally, and read latency must not depend on a round trip to another continent — including for a user whose data is mastered on the far side of the planet.
- R2Two updates to the same record can be in flight at once, and they must be applied in a definite order. There is no distributed lock service to appeal to and none is being introduced. Stale reads are acceptable; a write that is lost, or two applied in the wrong order, is not.
- R3Adding serving capacity must not add anything that coordinates writes, and the store must not acquire new callers as the product grows. Its shape is the private business of whatever owns it: every extra reader is a column nobody can ever drop.
Outside every boundary: Other regions (told what changed), The product (hundreds a page), Sharded store (one host a shard), an empty slot for the what a region holds, tier 1, an empty slot for the which write is second, tier 1, an empty slot for the who may touch the store, tier 2 Connections: The product calls what a region holds — every read what a region holds calls which write is second — misses, writes which write is second calls who may touch the store — goes through who may touch the store calls Sharded store — reads, writes which write is second publishes to Other regions — what changed