InterviewDryRun
System design interview · Asked at mid and senior level

Design a Unique ID Generator

How the interviewer asks it

“Design a service that hands out unique, roughly time-ordered 64-bit IDs across many data centres.”

Want the full answer? Watch lesson 3 of the free system design course: a 22-minute video walkthrough of this question.

Typed drills are free and unlimited: the AI scores your answer against the outline below.

What the interviewer is looking for

  • You compare options: UUIDs (128 bits, unordered), a central database sequence (bottleneck), ticket servers, and timestamp-based IDs.
  • A clear bit layout: timestamp, data centre, worker, sequence, and how long it lasts.
  • Clock problems: what happens when the clock moves backwards.
  • How worker ids are assigned without collisions.

How to structure your answer

  1. 01

    Requirements

    64-bit, unique, sortable by time, tens of thousands per second per node, no single point of failure.

  2. 02

    Options

    Walk through UUID, database auto-increment with step, and a ticket server, and why each falls short.

  3. 03

    Bit layout

    1 sign bit, 41 bits of milliseconds since a custom epoch (about 69 years), 5 bits data centre, 5 bits worker, 12 bits sequence (4,096 per millisecond).

  4. 04

    Generation

    Same millisecond: increment the sequence; overflow: wait for the next millisecond.

  5. 05

    Clock and workers

    Refuse to issue IDs if the clock goes backwards; assign worker ids through a coordination service or config.

Best answers from candidates

No candidate answers yet. Type yours, and if it scores 6 or more you can show it here without your name.

Answers are shared by candidates, without names, after a privacy check. Add yours

Common mistakes

  • Using random numbers and hoping for no collisions.
  • Forgetting to explain sequence overflow within one millisecond.
  • Ignoring clock skew between machines.

Follow-up questions to expect

  • IDs must not reveal how many orders you take a day.
  • You need 1 million IDs a second from one data centre.

Now answer it out loud

Max will ask you this exact question, listen to your answer, push on the weak spots with follow-ups like the ones above, and score you when you finish.

Practice with Max

Free: a 5-minute voice round and unlimited typed drills, with scored feedback. No card, and your camera is never recorded.

More system design interview questions

Preparing for this round? Read how to practice for a system design interview.