Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 9 Next »

The Framework proposed in this space (Alex Xu) is applied to propose a design : Getting started - a framework to propose...

Introduction

URL shortening is used to create shorter aliases for long URLs. We call these shortened aliases “short links.” Users are redirected to the original URL when they hit these short links. Short links save a lot of space when displayed, printed, messaged, or tweeted. Additionally, users are less likely to mistype shorter URLs.

//Shorten long URL through TinyURL
from https://www.educative.io/courses/grokking-the-system-design-interview/m2ygV4E81AR
to https://tinyurl.com/rxcsyr3r

Step 1 - Understand the problem and establish design scope

How it works ?

URL https://www.blablablabla.com/q=chatsystem&c=logged&cl=long is the original URL and we create un alias with shorter length: https://tinyurl.com/y7keocwj

Traffic volume ?

100 Million URLs per day

How long is the shortened url ?

As short as possible.

Characters in the shortened URL ?

Combination of numbers and characters (a-z, A-Z).

Can it be deleted or updated ?

CANNOT be deleted or updated.

Back-of-the-envelope calculation

For Traffic

  • Write operations: 100 million URLs are generated per day

  • Write operation per second: 100 million / 24 / 3600 sec = 1160 operation per sec.

  • Read operation: Assuming 1160 * 10 = 11600 read per sec.

  • Assuming the URL shortener service runs for 10 years, this means we must support 100 Million * 365 * 10 = 365 billion records.

  • Assuming average length is 100

For Storage

  • Storage requirement over 10 years : 365 billion * 100 bytes = 36.5 TB.

On this page.

Step 2 - High-level design

API endpoints

A URL shortener primary needs 2 API endpoints :

  • URL Shortening : to create a new short url, a client sends a POST request which contains one parameter: the original long URL.

    • POST api/v1/data/shorten : return short url.

  • URL redirecting : to redirect a short URL to the corresponding long URL, a client sends a GET request.

    • GET api/v1/shortUrl : return long url for http redirection.

URL redirecting

URL shortening

bbb

Step 3 - Design deep dive

Step 4 - Pros & Cons

  • No labels