SystemKit

Unique ID Generator

Generate IDs across many machines without a bottleneck. Compare central sequences, leased ranges, UUIDs, and time-ordered layouts, and see what happens when a clock moves backward.

Lessons

  1. 01Define what an ID must guaranteeUniqueness, size, ordering, opacity, and availability are separate properties.
  2. 02Compare the simplest generators firstCentral sequences, allocated ranges, UUIDs, and time-based IDs make different tradeoffs.
  3. 03Budget the 64 bitsA familiar layout divides time, worker identity, and a per-millisecond sequence.
  4. 04Generate safely within one millisecondThe worker increments a sequence for the current millisecond and waits when it exhausts that slot.
  5. 05Handle clocks that move backwardA backward clock can repeat a timestamp and break both uniqueness and time order.
  6. 06Give each live generator a unique identityThe worker field prevents collisions only while worker IDs are leased and fenced correctly.
  7. 07Prove the service remains uniqueTest concurrency, restarts, rollover, lease loss, and clocks as first-class failure cases.