List functional requirements for the system (Ask the chat bot for hints if stuck.)...
1) URL shorting
2) URL Redirects
List non-functional requirements for the system...
1) low latency
2) Scalable
3) Consistency
Estimate the scale of the system you are going to design...
200 write qps
20000 read qps
the ratio is 1:5
Data storage
long url :100 byte
short url: 8 byte
created_at time : 8 byte
user_id: 20 byte
expiration_time 8 byte
144 byte per entry for simplicity it could be around 256 byte
Daily Data Generation
if you assume you handle 200 requests per second to create new short URLs, and considering that there are 86,400 seconds in a day, the total data generated daily would be:
Define what APIs are expected from the system...
There are two api
1) shorten url
method post
end point :/tinyurl/shorten
request :
{
"user_id":"",
"long_url":""
}
response :
{
"short_url:"",
"expiry_time:""
}
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
We only need one time table for this that url_mapping
user_id : varchar
long_url : varchar
created_at : timestamp
expiry : timestamp
short_url : varchar
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
To illustrate the interactions between these components, here’s a high-level flowchart representing the typical request flow:
Enter long URL
Forward to create short URL
Generate and store mapping
Store result
Return short URL
Respond with short URL
Request short URL redirect
Forward redirect request
Check Cache
If cache hit
If cache miss
Fetch from DB
Return long URL
Return long URL
Redirect to long URL
Client Application
API Gateway
Shortening Service
Database
Mapping Service
Cache
Return long URL
This high-level design forms the backbone of a robust, scalable, and user-friendly URL shortening service. If you need further explanations or details about any specific component, feel free to ask!
![]()
request flow diagram
![]()
Let's create a request flow diagram that visually represents the interaction between different components in the URL shortening service. This diagram will illustrate how requests pass through the system for both shortening a URL and redirecting to a long URL.
Enter long URL
Request to create short URL
Generate short URL
Store mapping
Return short URL
Respond with short URL
Request to redirect short URL
Forward redirect request
Check Cache
Cache hit
Cache miss
Fetch from DB
Return long URL
Return long URL
Redirect to long URL
Client Application
API Gateway
Shortening Service
Database
Mapping Service
Cache
Return long URL
This diagram visually and logically lays out how requests are processed within the URL shortening service. Would you like to explore any specific part of this flow further?
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
To illustrate the interactions between these components, here’s a high-level flowchart representing the typical request flow:
Enter long URL
Forward to create short URL
Generate and store mapping
Store result
Return short URL
Respond with short URL
Request short URL redirect
Forward redirect request
Check Cache
If cache hit
If cache miss
Fetch from DB
Return long URL
Return long URL
Redirect to long URL
Client Application
API Gateway
Shortening Service
Database
Mapping Service
Cache
Return long URL
This high-level design forms the backbone of a robust, scalable, and user-friendly URL shortening service. If you need further explanations or details about any specific component, feel free to ask!
![]()
request flow diagram
![]()
Let's create a request flow diagram that visually represents the interaction between different components in the URL shortening service. This diagram will illustrate how requests pass through the system for both shortening a URL and redirecting to a long URL.
Enter long URL
Request to create short URL
Generate short URL
Store mapping
Return short URL
Respond with short URL
Request to redirect short URL
Forward redirect request
Check Cache
Cache hit
Cache miss
Fetch from DB
Return long URL
Return long URL
Redirect to long URL
Client Application
API Gateway
Shortening Service
Database
Mapping Service
Cache
Return long URL
This diagram visually and logically lays out how requests are processed within the URL shortening service. Would you like to explore any specific part of this flow further?
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
To illustrate the interactions between these components, here’s a high-level flowchart representing the typical request flow:
Enter long URL
Forward to create short URL
Generate and store mapping
Store result
Return short URL
Respond with short URL
Request short URL redirect
Forward redirect request
Check Cache
If cache hit
If cache miss
Fetch from DB
Return long URL
Return long URL
Redirect to long URL
Client Application
API Gateway
Shortening Service
Database
Mapping Service
Cache
Return long URL
This high-level design forms the backbone of a robust, scalable, and user-friendly URL shortening service. If you need further explanations or details about any specific component, feel free to ask!
![]()
request flow diagram
![]()
Let's create a request flow diagram that visually represents the interaction between different components in the URL shortening service. This diagram will illustrate how requests pass through the system for both shortening a URL and redirecting to a long URL.
Enter long URL
Request to create short URL
Generate short URL
Store mapping
Return short URL
Respond with short URL
Request to redirect short URL
Forward redirect request
Check Cache
Cache hit
Cache miss
Fetch from DB
Return long URL
Return long URL
Redirect to long URL
Client Application
API Gateway
Shortening Service
Database
Mapping Service
Cache
Return long URL
This diagram visually and logically lays out how requests are processed within the URL shortening service. Would you like to explore any specific part of this flow further?
prioritizing read over write .
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?