Step 1 - Understand the problem and establish design scope
Characteristics of unique IDs ?
IDs = unique & sortable
Does ID increment by 1 for each new record ?
ID increments by time, but not necessarily by 1.
IDs contain numerical values ?
Contain numerical values.
ID length requirement ?
IDs should fit into 64-bit.
Scale of the system ?
Able to generate 10000 IDs per second.
Step 2 - High-level design
Traditional approach - Non-Distributed System
Approach uses a shared counter, the latter increases at each call.
We can also, generate un ID as a timestamp function.
Shared counter and timestamp function are limited because generate issues :
multiple independent servers can generate the same ID;
the same ID generates for 2 consecutives requests.
Approaches in Distributed system
There are probably 7 options / approaches and here’s below an overall comparison table belowStep 1 - Understand the problem and establish design scope
Characteristics of unique IDs ? | IDs = unique & sortable |
---|---|
Does ID increment by 1 for each new record ? | ID increments by time, but not necessarily by 1. |
IDs contain numerical values ? | Contain numerical values. |
ID length requirement ? | IDs should fit into 64-bit. |
Scale of the system ? | Able to generate 10000 IDs per second. |
Step 2 - High-level design
Traditional approach - Non-Distributed System
Approach uses a shared counter, the latter increases at each call.
We can also, generate un ID as a timestamp function.
Shared counter and timestamp function are limited because generate issues :
multiple independent servers can generate the same ID;
the same ID generates for 2 consecutives requests.
Approaches in Distributed system
There are probably 7 options / approaches and here’s below an overall comparison table below.
UUID
Each Web server could contain an ID Generator & the Web Server is responsible for generating IDs independently.
Pros & Cons for step 1
Pros : generating is simple (no coordination between servers and so, no synchronization issues); easy to scale in each web servers; uniqueness;
Cons : IDs are 128 bits long & we need 64 bits; IDs do not go up with time; IDs could be non-numeric.