Giter Site home page Giter Site logo

social_network_system_design's Introduction

System Design Course

Example of system design of social network.
System Design course link.

Useful Links



Requirements

Functional requirements

  • Add and delete friends
  • View users' friends
  • View user's profile
  • Publish posts
  • View feed of posts (home and user feed)
  • Upload media files for posts
  • Send and read messages in one-on-one and group chats
  • View one-on-one and group chats

Non-functional requirements

  • 50 000 000 DAU
  • Availability 99.99% (52.56 minutes downtime per year)
  • The system should be scalable and efficient
  • Each user sends an average of 1 post per 3 day
  • Each user reads feeds an average of 10 times per day
  • The size of each post is a maximum of 3000 characters
  • The size of each media files is a maximum 1MB
  • 10% of posts contain media files
  • Each post has a maximum 3 media files
  • A message should reach the recipient in 3 seconds
  • Each user sends an average of 10 messages per day
  • Each user reads messages an average of 20 times per day
  • The size of each message is a maximum of 1000 characters
  • A user can have a maximum of 1000 friends
  • A group can have a maximum of 100 participants
  • Posts and messages are stored forever
  • Geo distribution is not supported
  • No seasonality

Basic estimation

RPS

Send posts

$$ \frac{50 \space million}{(3 \space \times 24 \space hrs \times 3600 \space seconds)} = \sim 193 \space requests/second $$

Read posts

$$ \frac{50 \space million \times 10 \space times \space per \space day}{(24 \space hrs \times 3600 \space seconds)} = \sim 5787 \space requests/second $$

Send messages

$$ \frac{50 \space million \times 10 \space messages \space per \space day}{(24 \space hrs \times 3600 \space seconds)} = \sim 5787 \space requests/second $$

Read messages

$$ \frac{50 \space million \times 20 \space times \space per \space day}{(24 \space hrs \times 3600 \space seconds)} = \sim 11574 \space requests/second $$

Traffic

Send posts

Text traffic:

$$ {193 \space requests/second \times 2 \times 3000 \space bytes} = \sim 1.2 \space MB/second $$

Media files traffic:

$$ {193 \space requests/second \times 0.1 \times 3 \times 1 \space MB} = \sim 57.9 \space MB/second $$

Total:

$$ {1.2 \space MB/second + 57.9 \space MB/second} = 59.1 \space MB/second $$

Send messages

$$ {5787 \space requests/second \times 2 \times 1000 \space bytes} = \sim 11.6 \space MB/second $$

Storage

Database size for storing messages for 5 years:

$$ {11.6 \space MB/second \times (24 \space hrs \times 3600 \space seconds) \times 365 \space days \times 5 \space years} = \sim 1.83 \space PB $$

Database size for storing posts for 5 years:

$$ {59.1 \space MB/second \times (24 \space hrs \times 3600 \space seconds) \times 365 \space days \times 5 \space years} = \sim 9.32 \space PB $$

Total:

$$ {1.83 \space PB + 9.32 \space PB} = 11.15 \space PB $$

Number of disks (disk capacity = 16 TB):

$$ \frac{11.15 \space PB \times 1000}{16 \space TB} = \sim 697 \space number \space of \space disks $$

Design overview

System context diagram

Level 1. System context diagram

Profile system container diagram

Level 2. Profile system container diagram

Relation system container diagram

Level 2. Relation system container diagram

Post system container diagram

Level 2. Post system container diagram

Media system container diagram

Level 2. Media system container diagram

Message system container diagram

Level 2. Message system container diagram

social_network_system_design's People

Contributors

mihailpodgorny avatar

Watchers

 avatar

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.