Scale & distribution
Unique ID generation
Create unique, often time-sortable IDs across many machines without a central bottleneck.
Auto-increment columns don't work across shards. Snowflake-style IDs combine a timestamp, a machine id and a per-machine sequence into 64 bits, so they're unique and sort by time. Short links use counters from pre-allocated ranges encoded in Base62.
See it in action
Play with the idea, then follow it through a real architecture.
Try it: generate IDs
64 bits: time first (so IDs sort by creation), then which machine made it, then a per-millisecond counter.
Sign · 1
0
Timestamp (ms since epoch) · 41
00111010110000000011000010010101100111111
Worker id · 10
0000000111
Sequence · 12
000000000000
2116718534456274944- Created
- 2026-11-01 02:26:40.000
- Worker
- 7
- Sequence
- 0
Click quickly: within the same millisecond only the sequence changes, so one worker can mint 4,096 IDs per millisecond without asking anyone.
1/3At start-up each server claims a unique worker id — the only coordination needed.
- Server 1 (worker 7)
- — Generates IDs locally
- Server 2 (worker 8)
- — Generates IDs locally
- Worker registry
- — Assigns each server a unique worker id once
- Tweet store
- — IDs sort by time
How it works
- Snowflake: 41 bits time + 10 bits worker + 12 bits sequence.
- Range allocation: each generator claims a block of numbers from a coordination store.
- UUIDv7 offers time-ordered random IDs without coordination.
Trade-offs
- Clock skew can break ordering; sequential IDs can be guessable.