Design a unique ID generator at scale at scale — requirements, capacity, and trade-offs.
Skip to solution
KEEP THE
hardSystem Design
How would you design a unique ID generator at scale?
0 views
01
Understand the problem
system-designcase-study
02
Attempt it yourself
Sketch your approach before reading the solution — that's what interviews test.
Nudge consolestandby
Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.
03
Study the solution
Design a Unique ID Generator
Need 64-bit k-sorted 10K/s without coordination per ID.
| Approach | How | Trade |
|---|---|---|
| Snowflake | 41b timestamp + 10b shard + 12b seq | clock skew needs NTP + sequence reset |
| Ticket server | MySQL AUTO_INCREMENT | SPOF, 2K/s |
| UUID v4 | random 122b | n |
Solution ready — 2 min read
Classified // press E to declassify
04
Read the code
Snowflake
Run Playgroundimport time
EPOCH = 1609459200000
def snowflake(shard_id, seq):
ts = int(time.time()*1000) - EPOCH
return (ts << 22) | (shard_id << 12) | seq05
Join the discussion
Discussion (0)
Sign in to join the discussion.
No responses yet. Be the first to share what you think.
Transmission complete // awaiting log
KEEP THE
STREAK ALIVE.
Dossier 90 of 99 decoded in the System Design track. One more won't hurt.