Unique ID Generation
| Approach | Pros | Cons |
|---|---|---|
| DB auto-increment | simple, ordered | single point of failure / bottleneck |
| UUID v4 (128-bit random) | no coordination | large, unordered → poor index locality |
| Ticket server / ranges | simple, ordered within range | extra service |
| Snowflake (64-bit) | time-sortable, no coordination, compact | needs 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.