Back of the envelop estimation

Latency Numbers

  • https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know
  • RAM Memory: 100ns
  • Read 1 MB SSD: 1,000,000ns or 1ms ~ 1000 MB/s
  • Read 1 MB HDD: 30,000,000ns or 30ms ~ 30 MB/s
  • Conclusions
    • Memory is fast but the disk is slow.
    • Avoid disk seeks if possible.
    • Simple compression algorithms are fast.
    • Compress data before sending it over the internet if possible.
    • Data centers are usually in different regions, and it takes time to send data between them.

Data

  • 1 KB ~ 10^3 bytes
  • 1 MB ~ 10^6 bytes = 1 Million bytes ~ 10^3 KB
  • 1 GB ~ 10^9 bytes = 1 Billion bytes ~ 10^6 KB
  • 1 TB ~ 10^12 bytes = 1 Trillion bytes ~ 10^9 KB
  • 1 PB ~ 10^15 bytes = 1 Quadrillion bytes ~ 10^12 KB

Time

  • 1 day = 24 * 60 * 60 seconds = 86400 seconds ~ 10^5 = 100K seconds
  • 1 hour = 3600 seconds
  • 1 million requests/day ~ 10 requests/second
  • 1 billion requests/day ~ 10K requests/second

Database

  • ID: BIGINT
    • 8 bytes
  • UUID:
    • 16 bytes
  • created_date: DATETIME
    • 8 bytes
  • name: VARCHAR
    • ?? bytes
  • age: INTEGER
    • 4 bytes
  • email: VARCHAR(255)
    • 255 bytes
    • RFC limit: 254 characters
  • price: DECIMAL(15, 2)
    • 16 bytes
  • street address: VARVHAR(??)
    • ?? bytes
  • summary: VARCHAR(255)
    • 255 bytes
  • description: VARCHAR(1000)
    • 1000 bytes (1 KB)
  • Note: 1 char != 1 byte in UTF-8
    • we are assuming it considering all data to be saved in ASCII
    • Some Japanese characters take b/w 2-4 bytes
    • emojis take > 1 byte
    • UTF-8 characters in general take b/w 1 byte and 4 bytes

Hard Drive

  • Typical Big Hard Drive ~ 6 TB
  • HDD Good Speed: 150 MB/s

Population of the world

  • Total : 8 Billion, 8*10^9
  • Internet Users: 5 Billion, 5*10^9 (~60%)

Population of India

  • Total : 1.4 Billion, 1.4*10^9
  • Internet Users: 0.8 Billion, 0.8*10^9 (~60%)

To reach 100M users:

  • Threads took 5 Days
  • ChatGPT took 2 months
  • TikTok took 9 months

Most users

  • Google Search: 85 Billion searches every month

QPS, TPS, RPS

  • Queries per second
    • includes query operations like HTTP GET
  • Transactions per second
    • can consists of multiple requests
    • include state changing operations like DB writes
  • Requests per second
    • includes HTTP requests (writes or reads)
  • Use:
    • Measures throughput

Requests per second from ChatGPT