UUIDs (Universally Unique Identifiers) provide a standardized way to ensure unique identification across distributed systems.
With multiple versions defined by standards like the OSF DCE, let’s briefly outline each version’s purpose and characteristics.
Version 1: Date-Time and MAC Address
Version 1 UUIDs combine a node’s MAC address with a 60-bit timestamp, accurate to 100-nanosecond intervals since October 15, 1582.
This approach minimizes collision risk by using both time and node-specific information. However, exposing MAC addresses can be a privacy concern.
Version 2: DCE Security
Version 2 modifies version 1 by using a custom local domain number and an identifier, rather than just timestamps, to replace parts of the UUID.
It’s less common due to limited clock resolution and constrained sequence space.
Version 3 and 5: Namespace Name-Based
Both versions generate UUIDs by hashing a namespace identifier with a name. Version 3 uses MD5, while version 5 prefers the more secure SHA-1.
They ensure that the same input results in the same UUID, which is ideal for consistent identifiers across systems.
Version 4: Random
Version 4 UUIDs are purely random with specific bits reserved for the version and variant identifiers.
They boast high scalability and minimal collision probability due to large entropy.
Version 6: Lexical Time-Ordered
Version 6 retains the data from version 1 but reorganizes the timestamp for easier sorting by creation time.
Useful in systems where creation order is significant.
Version 7: Timestamp and Random
Designed for systems with high load, version 7 begins with a timestamp, followed by a random element with optional counter assistance for additional uniqueness.
This facilitates database key generation and distributed system efficiency.
Version 8: Custom
Version 8 is essentially a custom UUID, leaving 122 bits for vendor-specific use, following only minimal restrictions.
It’s adaptable for unique business requirements while maintaining UUID structure.
Conclusion
UUIDs provide a robust way to generate unique identifiers.
Each version fits particular use cases, varying from precise time and space uniqueness to high-volume random generation.
Understanding and applying the correct UUID version ensures optimal performance and minimal collision risk across systems.