How it works
Track generated IDs per second, sequence exhaustion, clock rollback, skew, lease failures, generator latency, and allocation failures. Test millions of concurrent generations across many workers, but do not treat a finite no-collision test as a mathematical proof. Uniqueness rests on unique live worker identities and a non-repeating timestamp and sequence state machine under defined fault assumptions.
So test the faults directly, because a clean load test never triggers them. In a staging run, step one worker’s clock back 5 seconds, kill another mid-millisecond and restart it under the same ID, block a third from the registry until its lease expires, and push a fourth past 4,096 IDs in a millisecond. Load every issued ID into a table with a unique index and look for rejected rows. A run that skipped those events could issue a billion IDs with no duplicates and still say nothing about them.
A migration to a new epoch or layout needs versioning or a separate namespace and a clear decoder. Moving the epoch forward makes every new timestamp value smaller, so new IDs sort below old ones and can repeat them. Check database signedness, API serialization, and browser precision end to end; Discord’s API returns its 64-bit IDs as strings for this reason. If the generator becomes unavailable, an API that needs a durable record should fail clearly or use an approved fallback namespace; it must not silently reuse IDs. Document what can be inferred from public IDs and use authorization independently.
Tests show no collisions, but a browser displays two large IDs as the same number. What failed?
The browser likely parsed 64-bit IDs as JavaScript Number, which cannot represent all such integers exactly. Serialize IDs as strings or use BigInt where supported.
Use this as a guide for self review; written answers are not graded.Keep in mind
- Validate the invariants behind uniqueness, not only sample outputs.
- Serialization and future layout migration are part of the system design.