Requirements
Functional Requirements:
- Create a short URL for a given long URL.
- Return the long URL associated with a given short URL.
Non-Functional Requirements:
- Low latency
- Low storage requirements
API Design
Require a creation api and a retrieval api
High-Level Design
Client's connect to a load balancer and then an api gateway that routes the request to one of two services, creation and redirect services which both reads from a database
Detailed Component Design
To get low latency, more frequently used urls are stored in a Redis cache for faster lookups. A read replica is also used to achieve scalability for reads and supporting a growing user base.
To achieve low storage requirements, each url are only stored with a hash value and the shortened url.