Podcast
Questions and Answers
What is the main advantage of using a URL shortener service, especially when sharing links through SMS or tweets?
What is the main advantage of using a URL shortener service, especially when sharing links through SMS or tweets?
The main advantage is that tiny URLs are exceedingly handy to share through SMS/tweets and printed materials, as they have less characters, which implies less printing cost and are easier to type.
What should you ask the interviewer when designing a URL shortener service?
What should you ask the interviewer when designing a URL shortener service?
You should ask the interviewer what features are expected in the service, which will then become the basis for functional requirements.
Can a customer create a custom tiny URL of their choice, and what is the maximum character limit for such URLs?
Can a customer create a custom tiny URL of their choice, and what is the maximum character limit for such URLs?
Yes, a customer can create a custom tiny URL of their choice, and the maximum character limit is 16.
What is assumed about the life span of a created URL in the system?
What is assumed about the life span of a created URL in the system?
Signup and view all the answers
What is the purpose of asking about the expected number of URL shortening requests per month?
What is the purpose of asking about the expected number of URL shortening requests per month?
Signup and view all the answers
What is the estimated number of unique shortened links generated per second, given 100 million new URL shortenings per month?
What is the estimated number of unique shortened links generated per second, given 100 million new URL shortenings per month?
Signup and view all the answers
What is the estimated total storage requirement for the system, assuming a lifetime of 100 years and 100 million shortened links creation per month, with each data object being 500 bytes long?
What is the estimated total storage requirement for the system, assuming a lifetime of 100 years and 100 million shortened links creation per month, with each data object being 500 bytes long?
Signup and view all the answers
What percentage of requests are assumed to be cached, based on the Pareto Principle, and how much memory is required to cache these requests?
What percentage of requests are assumed to be cached, based on the Pareto Principle, and how much memory is required to cache these requests?
Signup and view all the answers
What is the purpose of returning an HTTP 302 Redirect instead of an HTTP 301 Redirect, in the context of URL redirection?
What is the purpose of returning an HTTP 302 Redirect instead of an HTTP 301 Redirect, in the context of URL redirection?
Signup and view all the answers
What are the two functions that should be made accessible through the REST API, and what are the parameters required for these functions?
What are the two functions that should be made accessible through the REST API, and what are the parameters required for these functions?
Signup and view all the answers
Study Notes
URL Shortener Service
- A URL shortener service creates a short URL (alias/tiny URL) against a long URL.
- When a user clicks on the tiny URL, they get redirected to the original URL.
- Tiny URLs are useful for sharing through SMS/tweets (due to character limits) and printing in books/magazines (reducing printing cost).
- They are also easier to type and less error-prone compared to longer URLs.
Features
- Features of a URL shortener service may include:
- Customizable tiny URL lengths
- Expiration dates for tiny URLs
- User-generated tiny URLs
- Maximum character limit for custom URLs (e.g., 16 characters)
- Metrics for most visited links
- Analytics for targeted advertisements
System Design Goals
- Functional requirements:
- Non-functional requirements:
- Performance
- Scalability
- Availability
- Security
- Non-functional requirements:
Traffic and System Capacity
- Traffic assumptions:
- 200:1 read/write ratio
- 100 million new URL shortenings per month
- 40 URLs/second generated
- 8000 URLs/second redirected (with 200:1 read/write ratio)
- Storage requirements:
- 120 billion data points/objects (assuming 100 years of service)
- 60TB of storage required (assuming 500 bytes per data object)
- Memory requirements:
- 70GB of memory required (caching 20% of 700 million requests per day)
High-Level Design
- A rudimentary design for a URL shortener service includes:
- Components for URL shortening, caching, and analytics
- Limitations of the design (to be addressed later)
Algorithm and REST Endpoints
- Two REST API functions:
- long_url: A long URL to be shortened
- api_key: A unique API key for user authentication and access control
- custom_url (optional): A custom short link URL
- Return values:
- Short URL generated or error code (if invalid parameters)
- Note: "HTTP 302 Redirect" status is used instead of "HTTP 301 Redirect" to ensure analytics tracking.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Learn about URL shortener services that create short aliases for long URLs, making it easy to share and type URLs, especially in character-limited platforms like SMS and tweets.