QPS and storage calculation of a twitter

Hello friends,

Today, let’s undersand how to calculate QPS (Query Per Second) and Storage calculation of a twitter app (now a days called x).

Let’s get started.

QPS (Query Per Second) Calculation:

  • Lets assume total users- 1 B = 1000 M
  • DAU (Daily Active Users)- 10% of users = 100 M
  • Read (Use case- Load profile, Retweet) – Assuming each user do avg 20 actions/ day that involves reading data then
    • No of reads/day = 100 M * 20 operation/ day= 100 * 10^6 * 20 = 2* 10^9
    • No of reads/sec = 2* 10^9 / 60*60*24 = 2* 10^9 / ~100000 = 2* 10^9/ 10^5 = 20,000
    • No of reads/sec = Adding peak load factor = 2* 20000=40000
  • Write (Update profile, post tweet, like, comment)-
    • No of write/day = 100 M * 10 operation/day
    • Since writes are half than reads then No of reads/sec = 40000/2 = 20000

Storage capacity planning (1 year):

  • Profile storage for 1 B users- Assume it takes 1000 bytes = 10^9 * 1000 = 10^12
  • Assume DAU do likes and comments so- 100 M * 5 bytes * 365 days = ~ 10^8 * 5 * 400 M = 2 * 10^11
  • If 1% of DAU add new tweets then 1 M * 50 bytes * 365 days= ~ 20* 100 * 10 ^6 = 2 * 10^9
  • Total storage= 10^12  + 2* 10^11 + 2* 10^9 = 10^ 12 + 0.2 * 10^ 12 + 0.002 * 10^ 12
  • Total storage= 1.202 * 10^12 Bytes = ~ 1.2 TB

For easy calculation, some of the numbers are taken conservately however the goal was to explain the concept and calculation approach in easy way.

Hope you liked the blog, look forward to the comments/ suggestions in section below.


Posted

in

by

Comments

Leave a comment