System Design Interview Question: Design URL Shortener
edit Mmh Shohagh, UI/UX Designer
edit 8 min
This is a system design interview question, which is to design a URL shortener tool like TinyURL or Bitly from the ground up. We'll cover everything from design requirements, architecture, and component design to scaling for high-performance and security best practices.
Defining the Scope: Functional and Non-functional Requirements
This is a contract between you and Quincy. You must read and agree to these Terms before using any part of the Service. If you do not agree, you may not use the Service. You may use the Service only if you can form a binding contract with Quincy, and only in compliance with these Terms and all applicable local, state, national, and international laws, rules and regulations. Any use or access to the Service by anyone under 13 is strictly prohibited and in violation of these Terms. The Service is not available to any Users previously removed from the Service by Quincy.
Estimation: Data Math
With this information, we need to calculate how long the URL should be after shortening. Of course, we're trying to make it as short as possible, but we need to keep in mind the number of created URLs each year.
With this information, we need to calculate how long the URL should be after shortening. Of course, we're trying to make it as short as possible, but we need to keep in mind the number of created URLs each year.
High-Level Architecture
Continuing this calculation, we see that 62⁷ (around 3.5 trillion) is the first value larger than our projected 315 billion URLs needed.
Therefore, to support our projected growth over the next ten years, our shortened URLs need a minimum of 7 characters.
With this information, we need to calculate how long the URL should be after shortening. Of course, we're trying to make it as short as possible, but we need to keep in mind the number of created URLs each year.
API Design
This is a contract between you and Quincy. You must read and agree to these Terms before using any part of the Service. If you do not agree, you may not use the Service. You may use the Service only if you can form a binding contract with Quincy, and only in compliance with these Terms and all applicable local, state, national, and international laws, rules and regulations. Any use or access to the Service by anyone under 13 is strictly prohibited and in violation of these Terms. The Service is not available to any Users previously removed from the Service by Quincy.
Database
Continuing this calculation, we see that 62⁷ (around 3.5 trillion) is the first value larger than our projected 315 billion URLs needed.
Therefore, to support our projected growth over the next ten years, our shortened URLs need a minimum of 7 characters.
With this information, we need to calculate how long the URL should be after shortening. Of course, we're trying to make it as short as possible, but we need to keep in mind the number of created URLs each year.
URL Shortener Service
This is a contract between you and Quincy. You must read and agree to these Terms before using any part of the Service. If you do not agree, you may not use the Service. You may use the Service only if you can form a binding contract with Quincy, and only in compliance with these Terms and all applicable local, state, national, and international laws, rules and regulations. Any use or access to the Service by anyone under 13 is strictly prohibited and in violation of these Terms. The Service is not available to any Users previously removed from the Service by Quincy.
Security Considerations
This is a contract between you and Quincy. You must read and agree to these Terms before using any part of the Service. If you do not agree, you may not use the Service. You may use the Service only if you can form a binding contract with Quincy, and only in compliance with these Terms and all applicable local, state, national, and international laws, rules and regulations. Any use or access to the Service by anyone under 13 is strictly prohibited and in violation of these Terms. The Service is not available to any Users previously removed from the Service by Quincy.