Bird
Raised Fist0
HLDsystem_design~20 mins

Design a unique ID generator in HLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Unique ID Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Identify the correct architecture for a distributed unique ID generator

You want to design a system that generates unique IDs across multiple servers without collisions. Which architecture below best ensures uniqueness and scalability?

AA centralized server generates IDs sequentially and all clients request IDs from it.
BClients generate random IDs independently without coordination.
CEach server generates IDs using a timestamp combined with a unique server ID and a sequence number.
DIDs are generated by hashing client IP addresses and timestamps.
Attempts:
2 left
💡 Hint

Think about how to avoid collisions and maintain scalability without a single bottleneck.

scaling
intermediate
2:00remaining
Estimate the capacity of a unique ID generator system

Your unique ID generator uses 41 bits for timestamp (in milliseconds), 10 bits for machine ID, and 12 bits for sequence number per millisecond. How many unique IDs can the system generate per millisecond?

A4096 IDs per second
B4096 IDs per millisecond
C1024 IDs per second
D1024 IDs per millisecond
Attempts:
2 left
💡 Hint

Calculate how many IDs the sequence number allows per millisecond, then convert to per second.

tradeoff
advanced
2:00remaining
Choose the best tradeoff for ID length vs. uniqueness duration

You design a unique ID with 64 bits total. You can allocate bits between timestamp and sequence number. Allocating more bits to timestamp increases the time range IDs remain unique, but reduces IDs per millisecond. Allocating more bits to sequence number increases IDs per millisecond but shortens uniqueness duration. Which allocation is best for a system needing 10,000 IDs per millisecond and uniqueness for 10 years?

A39 bits timestamp, 14 bits sequence number
B41 bits timestamp, 12 bits sequence number
C42 bits timestamp, 11 bits sequence number
D38 bits timestamp, 15 bits sequence number
Attempts:
2 left
💡 Hint

Calculate if the timestamp bits cover 10 years and if sequence bits cover 10,000 IDs per millisecond.

🧠 Conceptual
advanced
2:00remaining
Identify the main challenge in distributed unique ID generation

What is the biggest challenge when designing a distributed unique ID generator that works across many servers?

AEnsuring IDs are cryptographically secure
BMinimizing the size of the ID to 16 bits
CGenerating IDs that are human-readable
DAvoiding collisions without a central coordinator
Attempts:
2 left
💡 Hint

Think about what happens when multiple servers generate IDs independently.

component
expert
3:00remaining
Trace the request flow in a Snowflake-like ID generator system

In a Snowflake-like distributed ID generator, which sequence correctly describes the request flow when a client requests a new ID?

A1,2,3,4,5,6
B1,3,2,4,5,6
C2,1,3,4,5,6
D1,2,4,3,5,6
Attempts:
2 left
💡 Hint

Think about the logical order from request to ID generation and response.