Throughput:
Storage Estimation:
total storage = 127 bytes
total url per year = 127 * 1000000 * 365 = 127,000,000 = 46 GB
Bandwidth:
Assuming HTTPs 301 request is about 500 bytes(including headers and all)
Caching estimation:
we will use REST API.
Endpoint: POST /shorten
This endpoint creates a new short URL for a given long URL.
Endpoint: POST /shorten
This endpoint creates a new short URL for a given long URL.
A NoSQL database like DynamoDB or Cassandra is a better option due to their ability to efficiently handle billions of simple key-value lookups and provide high scalability and availability.
We would need two tables: one for storing url mappings and one for storing user related information.
url_mapping_table features : {url_id , user_id ,short_url ,long_url ,creation_date ,expiration_date ,click_count}
user_table : {user_id ,name ,password ,e_mail}
Load Balancer: Distributes incoming requests across multiple application servers.
Application Servers: Handles incoming requests for shortening URLs and redirecting users.
URL Generation Service: Generates short URLs, handles custom aliases, and manages link expirations.
Redirection Service: Redirects the users to the original URL.
Database: Stores mappings between short URLs and long URLs.
Cache: Stores frequently accessed URL mappings for faster retrieval.
Analytics Service (optional): Tracks usage statistics like the number of clicks, geographic location, etc.
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...
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
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?