Creating short-url
Redirecting
Estimate the scale of the system you are going to design...
Creation of short URL's:
Redirection of Short URL's:
Storage requirements
226 bytes roughly 256 bytes / request
DB Storage
POST short-url/
- input: a long url
- Output: a short url
GET short-url/?id=hash
- input: a short url
- output: redirects to original user url.
Short-url Service:
- User will provide long-url through api.
- The system will generate consistent hashing. This will id for long-url
- Along with id will store in Database.
- Return to user short-URL including parameter with id.
Redirecting Service
- when user clicks short URL.
- retrieves the the long URL with search of id.
- if id retrieves success then redirects to original URL
For Database SQL Database.
Storage requirements
Create Short-URL:
When client request to create short URL request. API Gateway will routes to short-URL service. Here in server short-URL created using consistent hashing and sent to store DB. Once DB success saves to cache for time limit. Then redirects to client with short-URL.
Redirect Service:
When client enter short-URL then API-Gateway routes to redirect service. Redirect service try to find cache if found redirects to original link. Otherwise try to find on DB if found then set to cache then redirects to original link.
Create short-url:
Redirect:
API-GATEWAY
- load balancer
Load balancer will be used send request apporiate to serves
- servers
These server will handled short-url and redirect services
Storage
- Database
Database responsible for storing records
- cache
Temporary storage
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?