List functional requirements for the system (Ask the chat bot for hints if stuck.)...
Shorten URL with size limit
Redirect to original URL on click
Metrics related to clicks and shortened URLs
API to shorten a URL or batch of URLs together
Store short and original URL, click history
Allow custom short domains
Caching
Expire/Active time
List non-functional requirements for the system...
Scalability
High throughput
Low latency
Consistent
Highly available
Estimate the scale of the system you are going to design...
500 URLs per second = per month 30*24*60*60*500 = 1.3 billion requests
Storage size
200 bytes per row * 1 billion * 12 * 5 = 931 gb
Define what APIs are expected from the system...
Post API to shorten the URL
/shorten/url/
URL = longURL
client= id
customdomain = domain
activeDuration
returns
shortUrl
Get API for metrics
getcounts/?URL= shortURL
returns
number of clicks
number of unique clicks
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...
As its a high traffic system, horizontal scaling would be better, we should use nosql even if data is structured
but on click we need to quickly to get query based on short_id to get original long URL to redirect
id shortURL longURL create time expired time
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...
flowchart LR
A[Client Web or REST] --> B[Load Balancer]
B --> C[API Gateway]
C --> D[Short URL Service]
c --> J[Redirect URL Service]
D --> E[Database NoSQL]
D --> F[Redis Cache]
D --> G[Monitoring and Observability]
G --> H[Alerts]
G --> I[Metrics]
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Client > URL Service > stored in db > return short url
Client > click short URL > redirect > add metrics
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...
Short URL Service
Redirect SERvice
Explain any trade offs you have made and why you made certain tech choices...
Database SQL vs noSQL
Microservices vs monolith
Try to discuss as many failure scenarios/bottlenecks as possible.
Single URL sent to many
Many clicks pointing to same long URL
Db failure
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?
Analytics