What is a UUID? Architecture & Differences Across Versions (RFC 4122 vs RFC 9562)
A UUID (Universally Unique Identifier), also referenced throughout the Microsoft ecosystem as a GUID (Globally Unique Identifier), is a 128-bit integer standardized under RFC 4122 and expanded in 2024 by RFC 9562. Its canonical text representation consists of 32 hexadecimal digits displayed in 5 hyphen-separated groups: 8-4-4-4-12 (36 characters total).
1. Architectural Comparison of Major Versions
- UUID v4 (Purely Random): The most widely utilized identifier in modern software history. Encodes 122 bits of pseudo-random entropy generated by Cryptographically Secure Pseudo-Random Number Generators (CSPRNG). The probability of generating a duplicate key is practically zero.
- UUID v7 (Time-Ordered): Introduced in modern RFC 9562, UUID v7 encodes a 48-bit UNIX millisecond timestamp followed by 74 bits of random entropy. This resolves the primary drawback of UUID v4: random insertions causing severe B-Tree page splits and index fragmentation in relational databases like PostgreSQL, MySQL, and SQLite.
2. Collision Probability: How Safe is UUID v4?
To have even a one-in-a-billion chance of generating an accidental duplicate UUID v4, an engineering system would need to generate over 1 billion UUIDs per second for 100 consecutive years. Because of this astronomical mathematical guarantee, distributed microservice architectures generate primary keys locally without centralized coordination databases.