traffic estimation:
storage estimation:
Bandwidth estimate:
Cache Memory estimates (per day):
API methods :
createURL(api_dev_key, original_url, custom_alias=None, user_name=None, expire_date=None) => returns shortened URL or error
deleteURL(api_dev_key, url_key) => url_key is key representing shortened URL => return success/unsuccess deletion of url
To prevent abuse by user, each api_dev_key has limit on url creation and redirections per some time period
Key observations:
Tables:
DB : NoSQL (dynamoDB, Cassandra) -> easier to scale
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...
flowchart TD
B[client] --> C{server}
C --> E[Key generation service]
E --> D[Database]
D --> C
C --> B
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...
sequenceDiagram
Client->>+Server: shorten a url
Server->>+Encoding: encode the url
Encoding->>+Database: store encoded url
Database->>Server: url stored/failed
Server->>Client: Return shortened url
Summary : We need to generate last 8 (or 6, 10?) chars in the shortened URL, for example: “https://tinyurl.com/vzet59pa”.
Here are possible ways -
Option 1 - Encoding actual URL:
Option 2 - Generating Keys offline :
separate key generation service (KGS) to generate the 6 letter unique keys offline and store them into a separate DB (key-DB).
KGS:
Database key lookup:
Custom alias:
Data Partitioning:
Caching:
Load balancing:
Removing expired links :
Full components diagram:
flowchart TD
C[client] --> LB1{load balancer}
LB1 --> S[Server]
S --> LB2{load balancer}
LB2 --> Ca[cache]
LB2 --> D[database]
S --> KGS[key generation service]
KGS --> kdb[Key dB]
Cleanup --> kdb
Cleanup[cleaup service] --> D
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?