Loading...
Loading...
Design a URL shortening service similar to Bitly, where users can convert long URLs into shorter, more manageable links. Users submit an original URL and receive a shortened version that can be shared with others. When someone accesses the shortened URL, the system must redirect them to the corresponding original destination.
The platform should also support optional customization. Users may specify a custom alias instead of using an automatically generated short code, and they may optionally set an expiration date for their shortened links. Each short code must uniquely identify one original URL, preventing different destinations from being assigned the same code.
The central challenge is supporting extremely high read traffic while maintaining fast, reliable URL redirection. Shortened links may be accessed thousands of times after creation, making the system significantly more read-heavy than write-heavy. The estimated read-to-write ratio is approximately 1000:1, meaning redirect requests vastly outnumber new URL creation requests.
The system must redirect users to their original destinations within 100 milliseconds while maintaining 99.99% availability. It should scale to approximately 1 billion shortened URLs and 100 million daily active users. Availability takes priority over strict consistency for the redirect workload, but uniqueness must still be guaranteed when new short codes are created.
The design focuses on URL creation, optional custom aliases, link expiration, and redirection. User authentication, account management, click analytics, geographic tracking, spam detection, and malicious URL filtering are outside the scope.
URL Shortening: Users can submit a long URL and receive a shortened URL that references the original destination. The system must generate a unique short code for each newly created mapping.
Custom URL Aliases: Users can optionally specify a custom alias when creating a shortened URL, allowing them to choose a readable identifier instead of using an automatically generated code.
Link Expiration: Users can optionally specify an expiration date for a shortened URL. The system must respect the configured expiration when handling future requests.
URL Redirection: When a user visits a shortened URL, the system must resolve its short code to the associated original URL and redirect the user to that destination.
Short Code Uniqueness: Each short code must map to exactly one original URL. The system must prevent conflicting mappings when short codes are generated or custom aliases are requested.
Low Redirection Latency: Complete URL redirection with minimal delay, targeting less than 100 milliseconds.
High Availability: Target 99.99% availability for the URL shortening service.
Availability Priority: Favor availability over strict consistency for serving URL redirection requests.
Scalability: Support approximately 1 billion shortened URLs and 100 million daily active users.
High Read Throughput: Handle a heavily read-oriented workload with an estimated 1000:1 read-to-write ratio.