url shortener

sep 25 - oct 25 • link shortening service
description

url shortener is a high-throughput, low-latency microservice-based link shortening system. It focuses on lightning-fast redirections and reliable visit count analytics.

key features
Low-latency Redirects — Achieves sub-millisecond redirections using optimized Redis caches.
Distributed Counter — Aggregates visit counts in memory before flushing to the primary database.
Rate Limiting — Token-bucket rate limiter built directly on top of Redis to prevent abuse.
Analytics Dashboard — Lightweight metrics view showing visitor geographic distributions and user agents.
thought process

URL shorteners look simple, but they are read-heavy systems where database lookups can quickly become a bottleneck. I wanted to build a service that scales reads horizontally. The core concept was simple: write to database, invalidate or write-through to cache, and read strictly from memory (Redis). If Redis fails, fall back to MongoDB. This taught me a lot about multi-tier caching architectures and cache synchronization strategies.

challenges faced

The primary challenge was managing "hot keys"—short URLs that suddenly get viral traffic. This could lead to a cache stampede or overload the Redis node hosting that key. I solved this by implementing a localized micro-cache on the API server instance for extremely hot keys, and utilizing locking mechanisms to ensure only one request repopulated the cache upon expiry.

future roadmap
Geographic routing DNS to serve redirects from nodes physically closest to the visitor.
Support for customizable link aliases and expiry limits.
Advanced reporting with exported PDF summaries.