1. 200 users per min hitting api
2.API takes 1 sec to shorten url
3.Atleast 100 request to shorten url every min
POST API to shorten url and save it in database.
Request - url Body -actual url as json Response status code
GET API to fetch details on shortened url.
Request -url/shortened url or can use id stored in db for uniqueness
Response - actual url /shortened url / id / user created
GET API to redirect users to actual url
just hit short url
GET API to fetch all mappings created by user based on device id or user id
url/user-id
Resonse give details as a list actual url /shortened url / id / user created
Database can be unstructured to avoid complication as we dont need any complex queries its required to persist data
Mongo or dynamo db would work
User table - id |user id|user name| user email
shortened_url - id| user id| actual url | shortned url
access_control - id | user id | access | actual url
KAFKA to trigger event in case url got changed after expiration and to generate new url as well
Dynamo db
Redis cache to cache url as they wont change frequently eventual consistency
sharding range based for faster access
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...
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...
Explain any trade offs you have made and why you made certain tech choices...
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?