Skip to solution
hardSystem Design

How would you design a unique ID generator at scale?

0 views
01

Understand the problem

Design a unique ID generator at scale at scale — requirements, capacity, and trade-offs.

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.

ApproachHowTrade
Snowflake41b timestamp + 10b shard + 12b seqclock skew needs NTP + sequence reset
Ticket serverMySQL AUTO_INCREMENTSPOF, 2K/s
UUID v4random 122bn

Solution ready — 2 min read

Classified // press E to declassify

04

Read the code

import time
EPOCH = 1609459200000
def snowflake(shard_id, seq):
    ts = int(time.time()*1000) - EPOCH
    return (ts << 22) | (shard_id << 12) | seq
05

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.

Back to track