Distributed ID generation for short codes: leased ID ranges, Snowflake-style 64-bit IDs and UUIDv7, with their length, coordination, ordering and failure trade-offs.
Three options. Leased ID ranges: each instance reserves a block (say 10,000 IDs) from an allocator table in one call and hands them out from memory — shortest codes, one database call per block, gaps on crash. Snowflake-style IDs: 64-bit timestamp + worker id + sequence, no per-ID coordination and time-ordered, but each worker id must be unique and a node whose clock jumps backwards must stop issuing. UUIDv7 / random: zero coordination, but 128 bits is ~22 Base62 characters — too long for short links. Then Base62-encode. The trade-off is length versus coordination versus ordering: for a URL shortener I pick leased ranges; for internal event ids, UUIDv7.
Checks knowledge of leased ID ranges, Snowflake-style IDs and their trade-offs
Last updated 23 Nov 2026.