Estimate the scale of the system you are going to design...
Define what APIs are expected from the system...
only two apis for now
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 are going to use nosql database for this, as our main goal is availability over consistency, also we dont require the complex quries so sql has no major advantage here.
schema:
{
uniqueId: string, (primary key)
shortUrl: string,
longUrl: string,
ttl: timestamp
}
the client request first goes to the dns, then it goes to the load balancer, it then goes to the server, which maintains a cache, and a database as the source of truth.
For the write flow: for the write we will use write around cache strategy, firstly the request goes to the web server to generate the short url, the server will generate the short url and then puts into the db.
For read flow: we will use read through strategy, the web will ask for the long url, the request will go to the cache, it will check in the cache, if not found, it will check in the db and then populate the cache and return the response.
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?