🍩
System Design: Zero to Hero
  • 👋About System Design Learning Journey
  • Contents
  • 1️⃣1. Fundamentals of System Design
    • 1.1. Introduction to System Design
    • 1.2. Basic Principles and Concepts
    • 1.3. Trade-offs in System Design
    • 1.4. Non-Functional Requirements in System Design
    • 1.5. Back-of-the-Envelope Calculations in System Design
    • 1.6. Mini-Project: Simple Key-Value Store in Go
Powered by GitBook
On this page
  • Why are these calculations important?
  • Key Areas for Calculations
  • Useful Numbers to Remember
  • Example Calculation: Estimating Storage for a Social Media Platform
  • Tips for Back-of-the-Envelope Calculations
  1. 1. Fundamentals of System Design

1.5. Back-of-the-Envelope Calculations in System Design

Back-of-the-envelope calculations are quick, rough calculations that provide approximate answers. In system design, these calculations help estimate system capacity, performance, and resource requirements.

Why are these calculations important?

  1. They help you quickly validate the feasibility of a design.

  2. They guide architectural decisions by providing order-of-magnitude estimates.

  3. They're often expected in system design interviews to demonstrate your analytical skills.

Key Areas for Calculations

1. Estimating System Capacity

To estimate system capacity, you need to consider:

  • Storage requirements: How much data will your system store?

  • Bandwidth requirements: How much data will be transferred?

  • Computation requirements: How much processing power is needed?

2. Traffic Estimates

For traffic estimates, consider:

  • Daily Active Users (DAU): How many users interact with the system daily?

  • Requests per second: How many operations does the system handle per second?

  • Read vs. Write ratio: What's the proportion of read operations to write operations?

3. Storage Estimates

For storage estimates, think about:

  • Data size per entity: How much storage does each user, post, or item require?

  • Total entities: How many users, posts, or items will the system have?

  • Data growth rate: How quickly will the data volume increase over time?

Useful Numbers to Remember

When doing these calculations, it's helpful to remember some key numbers:

  • Powers of 2:

    • 2^10 ≈ 1 thousand

    • 2^20 ≈ 1 million

    • 2^30 ≈ 1 billion

  • Latency numbers:

    • L1 cache reference: 0.5 ns

    • Main memory reference: 100 ns

    • SSD random read: 16,000 ns

    • HDD seek: 10,000,000 ns

  • Bandwidth numbers:

    • 1 Gbps network: 125 MB/s

    • SSD sequential read: 1 GB/s

    • HDD sequential read: 150 MB/s

Example Calculation: Estimating Storage for a Social Media Platform

Let's estimate the storage needed for user profiles on a social media platform:

  1. Assume 1 million users

  2. Each user profile contains:

    • User ID (8 bytes)

    • Name (32 bytes)

    • Email (32 bytes)

    • Profile picture URL (200 bytes)

    • Other metadata (100 bytes)

  3. Total per user: 8 + 32 + 32 + 200 + 100 = 372 bytes

  4. For 1 million users: 372 bytes * 1,000,000 = 372 MB

  5. Adding 20% for indexing and future growth: 372 MB * 1.2 ≈ 446 MB

So, we'd need about 450 MB of storage for user profiles.

Tips for Back-of-the-Envelope Calculations

  1. Round numbers: Use round numbers to simplify calculations.

  2. Use appropriate units: Convert between KB, MB, GB, and TB as needed.

  3. State your assumptions: Always clarify the assumptions you're making.

  4. Sanity check: Does your final answer make sense given the problem?

  5. Practice: The more you practice, the better you'll become at these estimations.

Remember, the goal is to get a reasonable estimate quickly, not to calculate an exact figure. These calculations provide a starting point for more detailed analysis and design decisions.

Previous1.4. Non-Functional Requirements in System DesignNext1.6. Mini-Project: Simple Key-Value Store in Go

Last updated 6 months ago

1️⃣