UUIDs (Universally Unique Identifiers) are 128-bit identifiers designed to be unique across space and time without central coordination. This makes them ideal for distributed systems, where multiple servers or clients need to generate IDs independently without risking collision. Unlike auto-incrementing database integers, UUIDs do not reveal the total count of records, cannot be trivially guessed by incrementing, and can be generated client-side before the record is saved to the database.
UUID v4, based on cryptographically secure random numbers, is the most widely used version today. With 122 bits of randomness, the probability of a collision between two randomly generated v4 UUIDs is astronomically low โ you would need to generate 1 billion UUIDs per second for 100 years before expecting the first collision. UUID v1 is time-ordered, making it index-friendly for databases, but it reveals the MAC address of the generating machine โ a privacy concern for public-facing APIs.