SDE & MLE Prep

Unique ID Generation

ApproachProsCons
DB auto-incrementsimple, orderedsingle point of failure / bottleneck
UUID v4 (128-bit random)no coordinationlarge, unordered → poor index locality
Ticket server / rangessimple, ordered within rangeextra service
Snowflake (64-bit)time-sortable, no coordination, compactneeds clock sync; worker id assignment
Snowflake 64-bit id
| 1 sign | 41 bits: ms since epoch (~69 yrs) | 10 bits: machine id (1024) | 12 bits: sequence (4096/ms) |

Newer: UUIDv7 / ULID — time-ordered 128-bit IDs with random tail.