Design URL Shortener Flashcards

1
Q

What are some functional requirements for URL Shortener?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some non-functional requirements?

A
  • Highly available
  • URL redirection should happen in real-time with minimal latency.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the traffic ratio between new URL shortenings and URL redirections in our system?

A

The traffic ratio is 100:1, with 100 times more redirection requests compared to new URL shortenings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How many new URL shortenings can we expect per second in our system?

A

We can expect approximately 200 new URLs per second.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the estimated Queries Per Second (QPS) for URL redirections in our system?

A

The estimated QPS for URL redirections is 20,000 requests per second.
(100 * 200) = 20000

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How many objects do we expect to store in our system for 5 years, given 500 million new URLs every month?

A

We expect to store a total of 30 billion objects over 5 years.

(500 million * 5 years * 12 months = 30 billion )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How much total storage capacity will we need to store these objects for 5 years?

A

We will need 15 terabytes (TB) of total storage capacity to store 30 billion objects for 5 years.
30 billion * 500 bytes = 15 TB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the estimated incoming data rate for our service’s write requests?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the ‘createURL’ API return on successful insertion?

A

A successful insertion of a URL using the ‘createURL’ API returns the shortened URL as a string; otherwise, it returns an error code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the key parameters for the ‘createURL’ API function?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you prevent abuse by users of the URL shortening service?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why choose a NoSQL database like DynamoDB, Cassandra, or Riak for this use case?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A

D. To prevent duplicate shortened URLs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A. Append an increasing sequence number to each input URL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

A. Sequence number overflow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

To ensure uniqueness, what alternative solution is proposed in case users have not signed in?
A. Ask the user to choose a uniqueness key
B. Automatically append the user’s IP address
C. Generate a random sequence number
D. Extend the length of the short key

A

A. Ask the user to choose a uniqueness key

17
Q

In the context of URL encoding, what is the main concern with URLs that contain URL-encoded characters?
A. Increased key length
B. Duplicate URLs
C. Compatibility issues
D. Inefficient hashing

A

C. Compatibility issues

Different web servers, browsers, and systems may handle URL encoding and decoding differently. Inconsistent handling of encoded characters can lead to unexpected behavior.

18
Q

What is the primary goal of data partitioning in a scalable database system?
A. Improved data security
B. Efficient data retrieval
C. Load balancing
D. Data compression

A

Answer: C. Load balancing

19
Q

Which type of data partitioning divides data into partitions based on the first letter of the data or a specific hash key?
A. Range-Based Partitioning
B. Hash-Based Partitioning
C. Dynamic Partitioning
D. Adaptive Partitioning

A

Answer: A. Range-Based Partitioning

20
Q
A