Design URL Shortener Flashcards
What are some functional requirements for URL Shortener?
- Should generate a shorter, unique alias of it.
- When user access the short link, our service should redirect them to the original link.
- Users should optionally be able to pick a custom short link.
- Links should expire after sometimes. User should be able to specify the expiration time.
What are some non-functional requirements?
- Highly available
- URL redirection should happen in real-time with minimal latency.
What is the traffic ratio between new URL shortenings and URL redirections in our system?
The traffic ratio is 100:1, with 100 times more redirection requests compared to new URL shortenings.
How many new URL shortenings can we expect per second in our system?
We can expect approximately 200 new URLs per second.
What is the estimated Queries Per Second (QPS) for URL redirections in our system?
The estimated QPS for URL redirections is 20,000 requests per second.
(100 * 200) = 20000
How many objects do we expect to store in our system for 5 years, given 500 million new URLs every month?
We expect to store a total of 30 billion objects over 5 years.
(500 million * 5 years * 12 months = 30 billion )
How much total storage capacity will we need to store these objects for 5 years?
We will need 15 terabytes (TB) of total storage capacity to store 30 billion objects for 5 years.
30 billion * 500 bytes = 15 TB
What is the estimated incoming data rate for our service’s write requests?
The estimated incoming data rate for write requests is 100 kilobytes per second (KB/s).
200 new URLs every second
200 * 500 bytes = 100 KB/s
What does the ‘createURL’ API return on successful insertion?
A successful insertion of a URL using the ‘createURL’ API returns the shortened URL as a string; otherwise, it returns an error code.
What are the key parameters for the ‘createURL’ API function?
The key parameters for ‘createURL’ are:
- api dev key (string)
- original_url (string)
- custom_alias (string, optional)
- user_name (string, optional)
- expire_date (string, optional)
How do you prevent abuse by users of the URL shortening service?
To prevent abuse, users are limited based on their ‘api dev key.’ Each developer key can be restricted to a certain number of URL creations and redirections within a specific time period, which may vary per developer key. This helps control and throttle user activity to avoid abuse.
Why choose a NoSQL database like DynamoDB, Cassandra, or Riak for this use case?
NoSQL databases are a suitable choice for this use case due to their ability to handle large datasets with billions of rows efficiently. They don’t rely on complex relationships between objects, making them more straightforward for this specific application. Additionally, they are known for their scalability, which is crucial for a service with high usage.
What is the purpose of generating a short and unique key for a URL in the given problem?
A. To make URLs easier to remember
B. To improve the performance of the service
C. To create a compact representation of URLs
D. To prevent duplicate shortened URLs
D. To prevent duplicate shortened URLs
To address the issue of multiple users entering the same URL and getting the same shortened URL, what solution is suggested in the problem statement?
A. Append an increasing sequence number to each input URL
B. Store the sequence number in the databases
C. Ask users to choose unique keys
D. Use a longer hash for encoding
A. Append an increasing sequence number to each input URL
What potential problem is associated with appending an increasing sequence number to URLs?
A. Sequence number overflow
B. URL incompatibility
C. Increased database size
D. Slower URL redirection
A. Sequence number overflow