SysPad › Examples › Unique ID generator
Unique ID generator
A stateless Snowflake-style ID generator - no per-request coordination, just a one-time machine-ID lease at cold start, with clock-drift monitoring so timestamps never move backwards.
A purely computational service: near-zero latency, no database on the hot path, and the one piece of shared state (the machine-ID lease) kept off it.
- Throughput: 20,000 req/sec
- First to saturate: Nothing at this load
- Estimated cost: $15k/mo
How it works
- Snowflake ID Generator
- ID = timestamp | datacenter id | machine id | sequence. Assembled in-process with no network call, so throughput is bound by compute, not by any store.
- Machine-ID Registry
- Leased once per worker at cold start (hence the near-zero edge multiplier), guaranteeing no two live workers share a machine id. Not touched on the request path.
- Clock-Drift Monitor
- NFR: watches per-worker clock skew. Snowflake ids embed a timestamp, so a worker whose clock jumps backwards must pause rather than mint a smaller id.
Request flows
Generate ID
- Calling Services
- DNS
- Load Balancer
- Snowflake ID Generator
Cold-start machine-ID lease
- Snowflake ID Generator
- Machine-ID Registry