Distributed Identity Architecture: RFC 4122 UUID vs Sortable ULID
Distributed Systems Engineering • Collision Risk Analysis
1. Collision Probability of UUID v4
A version-4 UUID contains 122 bits of random entropy. To achieve a 50% probability of a single collision (the Birthday Paradox), an application would need to generate over \(2.71 \times 10^{18}\) IDs, rendering duplicates practically impossible across distributed cluster nodes.
2. The Indexing Advantage of ULIDs in Modern Databases
Because UUIDs are purely random, inserting them as primary keys into B-Tree database indexes (such as PostgreSQL or MySQL InnoDB) leads to severe index page fragmentation. Universally Unique Lexicographically Sortable Identifiers (ULIDs) prepend a 48-bit millisecond timestamp to 80 bits of cryptographic randomness, preserving monotonic sortability while maintaining global uniqueness.