Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...
Key API's :
POST : /createURL
Once the shortURL is created , the server responds with a 204 response.
GET: /getURL
getURL response will also go through the similar caching strategy as redirect URL.
DELETE: /deleteURL
Once deleted, the cache needs to be invalidated so that we dont serve stale data to users. Either we can do it in the delete session or can drop an event to clean up the cache. This will result in eventual consistency.
POST: /redirectURL
redirect URL will take the shortUrl as endpoint. This will be the high volume API. We are introducing caching at CDN, application server and DB level. When a request comes from client, the CDN is checked first and if the redirect url is already cached the request is serverd from the web server layer. If not the request comes to the application layer and if the redirect url is present in the application layer or DB layer cache it is served from there. If not the redirect URL is served from DB. While addressing the client request, the redirect URL is wrote back into the different cache layers so that the subsequent requests are served faster.
Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.