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.)...
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
Create Short URL
POST /api/v1/shorten
Request
{
"url":"https://google.com/maps/..."
}
Response
{
"shortUrl":"https://tiny.ly/aB3Xyz"
}
High-Level Design
+------------------+
| Client |
+--------+---------+
|
|
+--------v---------+
| Load Balancer |
+--------+---------+
|
+----------------+----------------+
| |
+-------v-------+ +-------v-------+
| API Servers | | Redirect APIs |
+-------+-------+ +-------+-------+
| |
| |
+-------v---------------------------------v------+
| Redis Cache |
+----------------------+-------------------------+
|
|
Cache Miss|
|
+--------v--------+
| URL Service |
+--------+--------+
|
+----------------+----------------+
| |
+--------v---------+ +--------v---------+
| URL Generator | | Click Counter |
+--------+---------+ +--------+---------+
| |
+----------------+----------------+
|
+-------v--------+
| Distributed DB |
+----------------+
Database Design
Define the data model. Identify the main entities, their attributes, and relationships. Consider the choice of database type (SQL vs NoSQL) and justify your decision based on access patterns...
Detailed Component Design
abc123
Pros
- Simple
Cons
- Collision checking required
- Performance degrades at scale