System Design: URL Shortener

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/32

flashcard set

Earn XP

Description and Tags

Flashcards based on the lecture notes about designing a URL shortening service, covering key concepts and functionalities.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

33 Terms

1
New cards

What is the purpose of a URL shortening service?

To convert long URLs into shorter, more manageable URLs that redirect to the original URL.

2
New cards

What is an example of a URL shortening service?

TinyURL.

3
New cards

What is the maximum number of URLs generated per day according to the lecture?

100 million URLs.

4
New cards

What is the maximum URL length assumption in the lecture?

100 characters.

5
New cards

What ratio was assumed for reads to writes in the URL shortening service?

10:1.

6
New cards

What is the estimated storage requirement for 10 years?

36.5 TB.

7
New cards

What are two critical functional requirements for a URL shortening service?

High availability and scalability.

8
New cards

What endpoints are needed for the URL shortening API?

POST api/v1/data/shorten → accepts long url and returns a short one.

GET api/v1/shortURL → return long URL for HTTP redirection.

9
New cards

how does a url shortener work?

A URL shortener works by taking a long URL and converting it into a shorter, unique identifier that redirects users to the original URL when accessed. It typically involves mapping the long URL to a shortened code stored in a database and serving it through a web API. The status code 301 indicates that the requested URL has been permanently moved to a new location, so all future requests should use the new URL.

<p>A URL shortener works by taking a long URL and converting it into a shorter, unique identifier that redirects users to the original URL when accessed. It typically involves mapping the long URL to a shortened code stored in a database and serving it through a web API. The status code 301 indicates that the requested URL has been permanently moved to a new location, so all future requests should use the new URL.</p>
10
New cards
11
New cards

What's the difference between 301 and 302 statuses?

301 is a permanent redirect, while 302 is a temporary redirect for URLs.

12
New cards

How is URL redirection implemented in a URL shortening service?

By storing the

13
New cards

What does the hash function do in URL shortening?

It converts long URLs into short URLs and maps them back.

14
New cards

What character set is used in the hash value for short URLs?

Characters [0-9a-zA-Z].

15
New cards

What is the minimum required length for the hash to support 365 billion URLs?

7 characters.

16
New cards

What is one potential issue using in-memory storage for URLs?

It does not persist across server reboots.

17
New cards
<p>What type of database structure can be used instead of a hash table for storing URLs?</p>

What type of database structure can be used instead of a hash table for storing URLs?

A simple relational table is preferrable.

In the simplified version, we're storing the URLs in a hash table. That is problematic as we'll run out of memory and also, in-memory doesn't persist across server reboot.

18
New cards

What algorithm is suggested for generating unique IDs in a distributed environment?

Twitter's snowflake algorithm.

19
New cards

What is a Bloom filter used for in the context of URL shortening?

To help detect collisions in the hash function without querying the database.

20
New cards

How does base62 conversion work in generating short URLs?

It converts a unique ID into a string of characters consisting of 62 potential characters.

21
New cards

What is a key advantage of using an ID-based approach for short URLs?

Collisions are not possible because IDs are unique.

22
New cards

What does introducing a cache in the service improve?

It improves read performance.

23
New cards

What happens if a short URL is not found in the cache?

The long URL is fetched from the database and stored in cache.

24
New cards

What is a rate limiter used for in the URL shortening service?

To protect against malicious actors trying to make excessive shortening requests.

25
New cards

How can the web server tier be scaled?

By introducing more stateless service instances.

26
New cards

What are two common approaches for scaling the database layer?

Replication and sharding.

27
New cards

What additional feature can provide insights about URL usage?

Integrating analytics tracking.

28
New cards

What fundamental concepts are emphasized in distributed systems as discussed?

Availability, consistency, reliability.

29
New cards

What is recommended for handling potential server load when choosing between status codes?

Choose 301 if you want to avoid extra server load.

30
New cards

Is it possible to delete or update shortened URLs in the proposed design?

No, for simplicity, it is assumed they cannot be updated or deleted.

31
New cards

What approach is suggested to keep the URL shortening service simple? In terms of the hash function

Using base62 encoding for the URL shortening.

32
New cards

What is meant by 'fault tolerance' in the context of the URL shortener?

The ability of the system to continue operation despite failures.

33
New cards

How can we track the number of clicks on a shortened URL?

By integrating analytics features in the service.