Giter Club home page Giter Club logo

system_design's Introduction

Tiny URL - System Design

Example of the homework for course by System Design. TinyURL is a URL shortening web service, which provides short aliases for redirection of long URLs.

Functional requirements:

  • creates tiny URL from long URL
  • redirects from long URL to tiny URL
  • gets analytics about tiny URL clicks

Non-functional requirements:

  • 50 000 000 DAU
  • availability 99,95%
  • tiny URLs are always stored
  • service operation time 5 years
  • each user creates one tiny URL per week
  • on average, each tiny URL is accessed 20 times a day
  • geo distribution is not needed
  • no seasonality

Design overview

For system design I have used C4 model. The C4 model was created as a way to help software development teams describe and communicate software architecture, both during up-front design sessions and when retrospectively documenting an existing codebase. It's a way to create maps of your code, at various levels of detail, in the same way you would use something like Google Maps to zoom in and out of an area you are interested in.


Level 1. System context diagram


Level 2. Core system container diagram


Level 2. Analytics system container diagram

Basic calculations

RPS (create tiny URL):

DAU = 50 000 000
Each user creates one link per week
RPS = 50 000 000 / 86 400 / 7 ~= 82 

RPS (redirect from long URL to tiny URL):

DAU = 50 000 000
Service operation time = 5 years
Each user creates one link per week
Created links for 5 years = 50 000 000 / 7 * 365 ~= 3e9
On average, each tiny URL is accessed 20 times a day
Maximum RPS = 3e9 * 20 / 86400 ~= 700 000

Tiny URL length:

Created links for 5 years = 50 000 000 / 7 * 365 ~= 3e9
URL encoded base64 with length 5, will give ~= 916e6
URL encoded base64 with length 6, will give ~= 56e9
Tiny URL length = 6

Required memory:

Replication factor = 3
Service operation time = 5 years
Created links for 5 years = 50 000 000 / 7 * 365 ~= 3e9
Each record size for link ~= 150B
Required memory for 5 years = 3e9 * 150 * 3 ~= 1.5TB

system_design's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.