URIMetadata table
URIMapping table
The system will contain a load balanced set of web servers hosting 2 micro-services one for generating url and another for redirecting. Also a database layer to store the url information.
Given there will be more reads than writes, we will have a read replicas of the database. Writes goto to the Master and reads or redirecting calls goto to read replicas.
Database will be a PostGres database.
A cache layer holding the url mappings with a TTL of an hour can help with look ups before generating urls and for redirection requests.
GenerateURL API flow
Redirect URL
GenerateURL service will
RedirectURL Service will check if mapping exists and redirects user to the long url.
Cache layer will help look up tinyurl for longuri or vice versa for either services
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?