What is Unique ID

Unique IDs are numerical values that represent an action or event across the whole system. Much like the primary key that increments automatically in a database, a unique ID has the same role in distributed systems.

Generally, unique IDs are referred to by the name of Universally Unique Identifiers (UUID) or Globally Unique Identifiers (GUID).

The need for unique IDs

Unique IDs are a requirement of every company that handles a large amount of unique data. Companies need to assign a unique ID to every event or action that occurs in the system. Be it the signup of a new user, a new post on social media, or a new banking transaction, every system needs a unique ID for each of such events.

Without unique IDs, it will not be possible to keep track of all the events happening at the same time. Not only that, but information retrieval of old events will also become a challenge.

Requirements and goals

The unique ID generating system should meet the following requirements:

  • Since events in a system happen in a specific order, it is a requirement for a unique ID generator to be able to create IDs that are both unique and sortable.
  • Each unique ID should be a numerical value.
  • The IDs should be represented in 32, 64, or 128 bits. Hence, support a large number of events depending upon the use case.
  • The system should be able to generate thousands of unique IDs per second.

Working of unique ID system

Intuitively, the unique ID system will serve the application servers in a system. For any request by the client, the application server will request the ID generation system for a unique ID as shown below.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy