How do you design a URL Shortener like TinyURL?
Core Requirements:
- Generate a unique short alias for a given URL.
- Redirect users when they access the short URL.
Architecture Components:
- API Servers: To handle incoming read/write requests.
- Database: A NoSQL database (like Cassandra or MongoDB) to store the mapping of
short_url -> long_url. - Key Generation Service (KGS): A standalone service that pre-generates random 6-character strings and stores them in a DB. When a new request comes in, KGS provides a pre-generated key.
- Caching: Redis or Memcached to store frequently accessed URLs.
Note: For more insights, explore the Brightness Slider.