Unique ID generation in distributed systems is crucial for ensuring consistency, ordering, and avoiding collisions when multiple services or nodes generate IDs independently. An ID generator is a mission-critical system, it must be highly available.

Approach Decentralized Ordered Portable ID Size
Ticket server ❌
(Low availability,
No horizontal scaling) ✅ (sequence) ❌ 64 bit
Partitioned ID space (Multi-master) ✅ ❌ ⚠️ (careful setup) 64 bit
UUID ✅ v1: ✅ (timestamp)
v4, v5: ❌ ✅ 128 bit
Twitter Snowflake ✅ ✅ (timestamp) ⚠️ (careful setup) 64 bit

Ticket Server (No Replication)

A centralized server is responsible for issuing unique IDs.

The server maintains an atomic counter (e.g., auto_increment)

Pros

Cons

Partitioned ID space (Replication Required)

Each node in a distributed system generates IDs independently, but is assigned a unique range, prefix, or node ID to avoid collisions.

We are only talking about the the generator in a distributed system, not the whole system, after the ID is generated, the ID may be send to another environment which needs it.

Each region generates unique IDs like:

Pros