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:
- List the key non-functional requirements (eg low latency, scalability, reliability, etc.)...
- The short url to long URL mapping should always be consistent across nodes. we will prioritise consistency over availability
- the url generation can be low latency but not very low latency can take 500ms, not needed to be very fast
Capacity Estimation
Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
API Design
POST /v1/convert/{url}
GET /v1/{url}
POST {
url
timestamp
}
High-Level Design
- Client who connects to the web-server via a web-browser
- API Gateway to do SSL termination and load balancing of the traffic
- server where the app is running
- a database to store the url mappings
Database Design
Database can be a TTL based NoSQL database
Justification:
- a single write and multiple reads needed.
- complex schema not needed, no joins, foreign keys etc.
- TTL based deletion of URLs can be done, so not persistent storage needed.
Detailed Component Design
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.