Designing a URL shortener sounds trivial until you're tasked with...

- generate 100K short URLs per second
- guarantee uniqueness
- ensure sub-100ms latency
- be fault-tolerant, horizontally scalable, and tenant-aware
Not so "Tiny" anymore?
- short URLs are generated and returned instantly
- writes are pushed to DynamoDB later via SQS + Lambda
Fast! Yes, but risk of collisions lies with no uniqueness guarantee at generation time.
A great example of trading correctness for speed.
- check if short URL exists
- if not, insert and return to user
- guarantees correctness
But, doesn’t scale. It adds ~10ms latency per write, leads to bottlenecks under concurrent load. Thus, not feasible for 100K/sec.
To achieve correctness at scale, shift guarantees to the infra level.
That’s what the third architecture gets right.
- Cloud-native building blocks (Lambda, SQS, ECS, DynamoDB)
- Batched writes with transactional guarantees
- Fault-tolerant caching using Redis
- Concurrency-safe design choices
Really helped me understand how "simple" features evolve at scale.
Would love to hear thoughts on:
- PostgreSQL + advisory locks
- Redis Streams + Lua
- Kafka with idempotent writes & deduplication
Open to perspectives, still learning my way through these ideas.

