Shorten the URL and return to the user,
when user clicks on the shorter url, it can redirect to original website
can handle large amount of visit, and reutrn the shortened url
generating unique tiny url for each url input
assume there is about 200 requests per second, then that's about 17.28 million request per day.
assume there are 20000 request persecond, then are 1.73 billion requests per day
POST/:original_url --> generating short url
GET/:short_url --> redirect to the page
Design a table with a specific uuid, the shorten url as another column, the original url as the other column
A client calls the service to generate url, the server that generates the shorten url and store in the database. When doing redirect, the client send the short url to server and server returns the longer url and client has a function to do redirect itself.
We can also have a cache in between server and database for faster retriver of the result.
When there is no url exist, server will simply give error response and client need to know.
POST request goes from client to server, server generate shorten url, and write to database and cache using write through method. When doing get, client go to server, server retrive from cache first, if not found, go to database to find the mapping between short and long url and return long url.
The server can have multiple instances to handle the reuqests coming from the client. And the server will use some algorithm to genereate the short url. The database will consist of 1 table and have reader and writer server.
Using cache to speed up the retrival. We have more read than writes. So we need to have the cache to support read faster. The server can write through data to db and cache to update things faster.
The cache might fail and result in overlaod of request to the database
Assign more cache instances