post /shorten/
request body:
longurl (required), shorturl (optional), expiry date(opional)
response body (json):
long urL
The user would use this API to get a shortened URL by providing a long URL
get /getLongURL/
request body:
shortenedURL (required)
response body:
longURL or a redirect.
This user would use this api to get a or redirect to long URL.
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...
ShortenedURL:
primary Key: shortenedURL
Column: LongURL (required)
Column: Expiry Date (optional)
Column: createdAt (required)
Column: user (optional)
I'd like to go with C* nosql database given its scalability, ease to use, native support for TTL
shortenedURL should be unique.
Note that we could horizontally scale both urlShorten server and Database.
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...
What algorithm do we use for generating the shortenedURL.
option1:
option2:
SQL vs NoSQL
go with NoSQL given we opts for high availability
cache:
it could fasten the latency that retrieves commonly accessed shortenedURL, but of course we need to afford the cache
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?