Reqflow
← All comparisons

Unique ID Generator (Snowflake) vs URL Shortener

Unique ID Generator (Snowflake)

Unique ID Generator (Snowflake)

64-bit, roughly time-sortable IDs minted locally on each node: timestamp + worker id + per-ms sequence, no coordination on the hot path.

Components (4)

  • App Server
  • ID Generator A
  • ID Generator B
  • Coordination Service

Headline numbers

  • Lifespan from epoch~69 years
  • Max worker nodes1,024
  • Max IDs per node per second~4.096M
URL Shortener

URL Shortener

Hashing, key generation, read-heavy caching.

Components (6)

  • Client
  • API Gateway
  • Write Service
  • Read Service
  • Redis
  • Postgres

Headline numbers

  • Write QPS (avg)~1,200/sec
  • Read QPS (avg)~120,000/sec
  • Storage per year~5 TB

Key differences

Only in Unique ID Generator (Snowflake)
None.
In both
  • Service
Only in URL Shortener
  • Client
  • API Gateway
  • Redis
  • Postgres

Flow shape

Unique ID Generator (Snowflake) flows
  • Generator boots and claims a worker id2 steps
  • Generate an ID (bit composition)2 steps
  • Two generators mint in the same millisecond4 steps
  • Sequence overflows within one millisecond3 steps
  • Clock moves backward (NTP correction)3 steps
URL Shortener flows
  • Shorten a URL3 steps
  • Resolve short URL (cache hit)3 steps
  • Resolve short URL (cache miss)4 steps
  • Redis is down4 steps