Many developers build a URL shortener as a toy project. However, scaling it to handle millions of redirects per second requires serious consideration of cache layers, database indexes, and database choice. I built **Linky** to demonstrate production-grade system design.
Technical Choices
- **Base62 Encoding**: To convert auto-incrementing integer IDs into short, URL-friendly strings (e.g., `https://linky.ajinkyadhotre.com/3B7x`).
- **Redis Cache**: Serving redirections directly from memory with a sub-millisecond response time.
- **Spring Boot**: For building the lightweight HTTP redirection service and handling incoming analytics.
- **Click Analytics**: Tracking referrers, locations, and user agent strings asynchronously to prevent adding latency to the redirect flow.
The Redirection Flow
When a user visits a shortened link: 1. The request hits the Spring Boot API. 2. Spring Boot queries Redis. If the key exists, it issues a `302 Found` immediately. 3. If it's a cache miss, it queries PostgreSQL, populates Redis, and redirects. 4. An asynchronous worker registers the analytics event to avoid blocking the user.
Linky demonstrates that even simple ideas can be engineered for high scale. Visit it at [linky.ajinkyadhotre.com](https://linky.ajinkyadhotre.com).