Several points to provide TinyURL solution

Requirement: Design a system to take user-provided URL and transform them to a shortened URL that redirect back to original.

How to evaluation a system design?

  • Bad: no sense of requirement
  • Pool: limited knowledge
  • Good: reasonable solution, explain clearly
  • Great: well thoughtful, tradeoff

There are several points that can be considered before design a Tiny URL solution.

  1. How to map a short URL to the original long URL? how to encode long URL to the short key (MD5 or Base64)? If MD5, truncate the rest, long leave 5 characters. How to avoid conflicts?
  2. How to save the key – value mapping? RMDB or NoSQL?
  3. Consider Memcache, and combined with a NoSQL DB (CouchBase, MongoDB).
  4. How to support multiple DB servers to scale the performance for future queries?
    – sharding: hash(URL)%Server_no = server_id
    – to achieve high availability, consider standby
    – how to replicate the data across server (cross region, master/slave, master/master)
    – how to recover from crush (master need a checkpoint, slave needs recreate)
    – how to guarantee data consistency
  5. How to coordinate multiple clusters? ZooKeeper is one option
  6. How to limit single user send spam queries?
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on RedditShare on StumbleUponEmail this to someoneShare on TumblrDigg this

2 thoughts on “Several points to provide TinyURL solution

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">