High-Level Design
Flow goes like the following steps
- Client request goes to api gateway
- The api gateway decides which service, and which replica to send the request to, in a load balanced way
- For url creation
- It generates a mapping
- Sends the data to storage layer
- Storage layer confirms saved data
- api returns a response
- For url redirection
- It asks storage layer for an existing mapping
- If there is, it returns info
- The redirect url is put in the header, and response is 302 (maybe), so the browser automatically redirects
- The storage layer
- For creation, it saves the record in database directly
- For read, it queries the cache first, if the data is there, then done
- Otherwise gets from database, saves it in cache, then returns