Skip to main content
Common Designschapter 7 of 8 · 3 lessons

Distributed ID Generator

Generate globally unique, roughly-sortable IDs across many machines without coordination.

Every design in this course quietly assumed it. The chat system needed time-sortable message identifiers, the feed needed pagination cursors, the shortener needed unique numbers to encode.

Generating unique identifiers on one machine is a sequence. Generating them on a hundred machines, millions a second, without those machines talking to each other, is a real design problem with a famous solution and several sharp edges. It is also the piece nobody designs deliberately, because it gets chosen in an afternoon by whoever sets up the first table, and everything built afterwards inherits it.

Lessons

3 in this chapter
  1. Requirements and the Obvious CandidatesUnique, sortable, compact, coordination-free: pick any three and you get a familiar failure.3 min
  2. The Snowflake Layout64 bits split three ways: when, where, and how many this millisecond.3 min
  3. Clock Skew and the AlternativesSnowflake's only external dependency is the clock, and clocks go backward.3 min