UUID: History, Motivation, Versions and Usage

A practical introduction to globally unique identifiers, their structure, and their trade-offs.

GuideDistributed SystemsIdentifiers

Where UUIDs came from

UUID stands for Universally Unique Identifier.

The same 128-bit format is often called a GUID.

The problem UUIDs solve

An auto-incrementing database key works well inside one database.

That property is useful for event messages.

Format and versions

A canonical UUID is 16 bytes.

550e8400-e29b-41d4-a716-446655440000

v1 · time-based

Combines a timestamp.

v4 · random

Uses secure random bytes.

v7 · time-ordered

Places a timestamp first.

Choosing and using a UUID

Use the version that follows the requirements:

  1. Choose v4 for general-purpose opaque identifiers.
  2. Choose v7 when records are sorted by creation time.
  3. Avoid v1 for public identifiers.
  4. Store UUIDs efficiently.

A UUID is an identifier, not a secret.