Input long url and return a new shortened url like short.io/JFjdj1
Store short url and long url in database.
When short url is called the API get the long url form the database
DAU = 100,000
QPS = (100,000 * 5) / (24 * 3600)= 500K/86K = 500/100 = 5 QPS
CRUD
Create -
POST /shorten/{longurl}
response: {short url: long url}
Read -
GET /expand/{short url}
response : {longurl}
{
}
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
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...
flowchart TD
B["client"];
E["API Gateway"];
C{"server"};
D["Url Database"];
F["Cache"];
B -->|"submit long url"| E;
B -->|"request short url"| E;
E -->|"return long url"| B;
E -->|"routes request"| C;
C -->|"writes"| D;
C -->|"chaches"| F;
D -->|"reads"| C;
F -->|"reads"| C;
C -->|"returns response"| E;
Decided to add a load balancer to have multiple url services,
Decided to add a rate limiter service using leaky bucket to avoid burts.
Adding Authentication: Oauth2 with tokens.
short url method: base 62
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?