we will need to handle scalability and reliability as the throughput is relatively considered as high, no matter medium or large scale. Also, under this high visiting volumn, we will need to consider data replication, server replication, to increase the availability
From ta user experience point of view, low latancy is a MUST as well.
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...
Here are my endpoints:
So for error handling, we have the following key aspects to consider.
As for Rate Limiting, yes, a rate limiting is useful, considering this is a shortenURL tool, so my preferrenced design would be setting this rate limiter to be allow for GET a maximum two visit per ip per device, and for POST, one visit per ip per device. What do you think? (To the coach: this is something I really do NOT know what is the interviewer expecting)
State Code: We can do 200 for success, with HTTP response. 400 for GET as a non-existing URL. 302 for a redirect to the original URL
Now the real question is, should we validate whether the URL is live or not, my guess is YES. We should be validating the URL beforehand, as we are targeting a large scale system, so if the URL itself is a dead link, that's something affecting our reliability. So later I will add such a component to verify the URL's status
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.
There will be two main entries:
Graph Design as drawn, additionally for Components:
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
Let's deep dive into these: