[Leetcode] Design tinyurl Streamlined URL address

Source: Internet
Author: User
Tags alphanumeric characters

Note:for The Coding companion problem, please see:encode and Decode tinyurl.

How would your design a URL shortening service that's similar to TinyURL?

Background:
TinyURL is a URL shortening service where you enter a URL such as and https://leetcode.com/problems/design-tinyurl it returns a short URL such as http://tinyurl.com/4e9iAk .

Requirements:

    1. For instance, "http://tinyurl.com/4e9iak" are the tiny URL for the page "https://leetcode.com/problems/design-tinyurl" . The identifier (the highlighted part) can is any string with 6 alphanumeric characters containing 0-9 , a-z A-Z .
    2. Each shortened URL must is unique; That's, No. Different URLs can shortened to the same URL.

Note about Questions:
Below is just a small subset of questions to get you started. In real world, there could being many follow ups and questions possible and the discussion is open-ended (No one true or Corr ECT-Solve a problem). If you had more ideas or questions, please ask in discuss and we may compile it here!

Questions:

    1. How many unique identifiers possible? Would you run out of unique URLs?
    2. Should the identifier is increment or not? Which is easier to design? Pros and cons?
    3. Mapping an identifier to a URL and its reversal-does This problem ring a bell?
    4. How does you store the URLs? Does a simple flat the file database work?
    5. What is the bottleneck of the system? Is it read-heavy or write-heavy?
    6. Estimate the maximum number of URLs a single machine can store.
    7. Estimate the maximum number of queries per second (QPS) for decoding a shortened URL
    8. How would the service? For example, a viral link which was shared in social media could result in a peak QPS at a moment ' s notice.
    9. How could handle redundancy? I,e, if a server is off, how could are you ensure the service is still operational?
    10. Keep URLs Forever or prune, pros/cons? How are we do pruning? (Contributed by @alex_svetkin)
    11. What API would provide to a third-party developer? (Contributed by @alex_svetkin)
    12. If You can enable caching, what would you cache and what ' s the expiry time? (Contributed by @Humandroid)

S

[Leetcode] Design tinyurl Streamlined URL address

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.