0
0
HLDsystem_design~20 mins

First design walkthrough (URL shortener) in HLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
URL Shortener Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Identify the main components in a URL shortener system

Which of the following lists correctly identifies the essential components needed to build a scalable URL shortener?

AFile Storage, Image Processing, CDN, Video Streaming Service
BLoad Balancer, Cache, User Authentication, Payment Gateway
CAPI Gateway, Database, URL Redirect Service, Analytics Service
DWeb Server, Email Service, Notification Service, Logging Service
Attempts:
2 left
💡 Hint

Think about what components handle requests, store data, and redirect users.

scaling
intermediate
2:00remaining
Scaling the database for high read traffic

In a URL shortener, most traffic is read-heavy (redirects). Which approach best improves read scalability?

AAdd read replicas to the database and use caching for redirects
BUse database sharding to split data by URL hash ranges
CStore all URLs in a single master database with no replicas
DUse a distributed file system to store URL mappings
Attempts:
2 left
💡 Hint

Consider how to reduce load on the main database for frequent reads.

tradeoff
advanced
2:30remaining
Choosing the URL key generation strategy

Which URL key generation method balances uniqueness, short length, and ease of generation?

AGenerate a random 10-character alphanumeric string for each URL
BUse a sequential numeric ID converted to base62 encoding
CUse the full original URL as the key without shortening
DUse the current timestamp as the key
Attempts:
2 left
💡 Hint

Think about avoiding collisions and keeping keys short.

🧠 Conceptual
advanced
2:30remaining
Handling expired or deleted URLs

What is the best approach to handle URLs that have expired or been deleted in a URL shortener system?

ARedirect to the original URL regardless of expiration
BReturn a 404 error when the short URL is accessed
CAutomatically generate a new short URL for the expired one
DRedirect to a default homepage or informational page
Attempts:
2 left
💡 Hint

Consider user experience when a URL is no longer valid.

estimation
expert
3:00remaining
Estimating storage needs for URL mappings

Estimate the approximate storage required to store 100 million URL mappings if each original URL averages 100 characters and each short URL key is 7 characters. Assume UTF-8 encoding (1 byte per character) and 20 bytes overhead per record for metadata.

AApproximately 12 GB
BApproximately 10 GB
CApproximately 15 GB
DApproximately 8 GB
Attempts:
2 left
💡 Hint

Calculate total bytes per record and multiply by 100 million.