How Two Machines Agree on a Number Without Talking
Subtitle: Snowflake IDs replace agreement with bit ownership.
- Panel 1 - The coordinator trap:
- Auto-increment asks one shared counter
- Every insert queues at that one place
- UUIDv4 removes the coordinator
- But random keys lose order and scatter writes
- Panel 2 - Partition the 64 bits:
- 1 unused sign bit
- 41 bits: millisecond timestamp
- 10 bits: machine id
- 12 bits: local sequence
- Disjoint machine bits prevent collisions
- Panel 3 - The ceiling is computable:
- Time in high bits makes IDs k-ordered
- 12 bits = 4,096 IDs per millisecond
- About 4.1 million per second per machine
- 10 bits caps the fleet at 1,024 generators
- Panel 4 - Falsify it at the clock:
- Correctness assumes time moves forward
- A backward step can revisit old ID space
- Refuse generation; never risk a duplicate
- If sequence fills, wait for the next tick
