SysPadExamples › 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.

Calling Services Users DNS Route 53 Load Balancer ALB Snowflake ID Genera… Lambda Machine-ID Registry DynamoDB Clock-Drift Monitor CloudWatch

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

  1. Calling Services
  2. DNS
  3. Load Balancer
  4. Snowflake ID Generator

Cold-start machine-ID lease

  1. Snowflake ID Generator
  2. Machine-ID Registry

Other interview practice

Open this architecture in SysPad · All examples