Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
POST /api/v1/shorten
Request
{
"url":"https://google.com/maps/..."
}
Response
{
"shortUrl":"https://tiny.ly/aB3Xyz"
}
+------------------+
| 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 |
+----------------+
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...
abc123
Pros
Cons