Q55: How would you design a distributed ID generator?
Choose requirements first: uniqueness, ordering, approximate time ordering, generation rate, and operation during network partitions. Options include database sequences, UUIDs, or structured IDs combining timestamp, worker ID, and sequence bits. Structured IDs can be compact and sortable but need unique worker assignment and clock-skew handling. UUIDs reduce coordination but may be larger and not naturally ordered. Never assume a timestamp alone guarantees uniqueness.
Key Takeaways
- ID design depends on ordering, uniqueness, and coordination needs.
- Plan worker identity and clock behavior for structured IDs.