Design of a Unique ID Generator

Lesson 47 of 25610 min readPremium lesson preview
In this lesson1 sections

Design of a Unique ID Generator

The previous lesson discussed use cases for unique identifiers, such as labeling tweets or tracking execution flow. This lesson explores system designs for generating these IDs. We will compare UUIDs, databases, and range handlers against the requirements defined below.

Requirements for unique identifiers

Our proposed system must meet the following requirements:

  • Uniqueness: Assign distinct IDs within the system’s defined lifetime and namespace.

  • Throughput: Support at least one billion IDs per day. That is about 11,574 IDs per second on average; peak rate and per-worker bursts need separate targets.

  • Availability: Specify which worker, allocator, and network failures must still allow ID generation, and for how long. Clock resolution is a separate concern.

  • 64-bit numeric ID: Fit the value in 64 bits. The calculation below counts the full unsigned space; reserving a sign bit or dividing the ID into fields changes the usable limits.

The rest of this lesson is for Premium members

Premium opens every lesson in this course, along with all questions and solutions on PracHub.