system design: estimating storage

2021-12-22

 | 

~2 min read

 | 

209 words

Some rules of thumb for data sizing:

  • int - 4 bytes
  • bigint - 8 byts
  • float - 4 bytes
  • date - 3 bytes
  • datetime - 5 bytes
  • single character - 2 bytes (depends on encoding)
  • an email - 2 KB
  • image (average) - 200 KB
  • audio (per minute) - 1 MB
  • image (good) - 2 MB
  • video (per minute) - 50 MB

Examples:

  • A text only tweet: 140 characters * 2 bytes = 280 bytes
  • A tweet with an embedded 2 minute video = 140 characters 2 bytes + 2 50 MB = ~100 MB
  • A database record tracking a transaction with the following fields:
    • created_at - 5 bytes
    • product_id - 8 bytes
    • category_id - 4 bytes
    • seller_id - 8 bytes
    • buyer_id - 8 bytes
    • quantity - 4 bytes
    • total_price - 5 bytes
    • Total: 42 bytes
  • A database storing 100 million transactions of ~40 bytes = 100,000,000 * 40 = 4,000,000,000 bytes or 4 GB

Sources


Related Posts
  • System Design: A Framework For Approaching The Problem


  • Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!