List functional requirements for the system (Ask the chat bot for hints if stuck.)...
short url
get original url
redirecting url
List non-functional requirements for the system...
high availablity
large amount of users
Estimate the scale of the system you are going to design...
each user shorts 5 urls
200,000 users will be 1 million urls
each url is 5kb
total storage will be 5GB
Define what APIs are expected from the system...
String shortUrl(String originalUrl, String userId, Date expireDate)
String getOriUrl(String shortUrl)
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...
will use NOSQL to store shorten url and original url
original url {
short url,
urlid
}
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...
loadBalance is used to distribute traffic to the right server
API Service is used to manage user login or profile update
shorten service is used to generate shorten service and return to user and store to database, it will pregenerate some shorten url and store to cache in case of high volumn requests
DynamoDB is used to store the shorten url data
cache is used to keep the pregenerate url, it will keep update with database to keep data consistent.
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...
shorten url: user send request to loadbalancer, after API service valid user identity it will send request to shorten service. shorten service will first check cache if there is any pregenerate url can use. If not it will generate a shorten url. Finally it will store the shorten url and original url and user information into DynamoDB
redirect url: user send request to loadbalancer, loadbalancer send request to redirect service, it will check in database of the original url and return it back to client.
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...
There will be replic of database in case of single point failure. we can set master-slave, master db will only for write and slave for read.
The url can generate by random string to avoid duplication.
redirect service, shorten service and api service also have replic to avoid failure.
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?