Skip to content
Search lessons, topics, tests…
Esc

    ↑ ↓ moveEnter openEsc close
    Lesson2 / 23

    Back-of-the-Envelope Estimation: QPS, Storage, Bandwidth and Latency

    Estimate QPS, storage and bandwidth from traffic assumptions. Use latency budgets and measured capacity to estimate requests in flight and server count.

    A back-of-the-envelope estimate is a short calculation that gives you an approximate size, not a production guarantee. Its value comes from showing your assumptions and keeping the units correct.

    We will carry one online shop through these calculations. You will estimate its traffic, five-year storage, network use, cache memory and server capacity. You will also see why a request's latency is not always the sum of all its operations.

    If you need help establishing the assumptions first, start with how to run a system design interview.

    How do you estimate average and peak QPS?

    In this estimate, QPS counts API requests per second. State which operations you are counting.

    Ten million daily users do not determine QPS by themselves. Ask how many actions each user performs, and which actions cause requests.

    For our shop, assume:

    AssumptionValue
    Daily active users10 million
    Product-read requests per user per day20
    Order creations per user per day, averaged across users0.02
    Seconds per day86,400
    Peak factor10 times the daily average

    Here, we calculate peak QPS as 10 times average QPS. We assume this describes the busiest one-minute average, not every possible one-second burst.

    Calculate reads and writes separately:

    • Average read QPS = 10,000,000 × 20 / 86,400 ≈ 2,315.
    • Average order-creation QPS = 10,000,000 × 0.02 / 86,400 ≈ 2.31.
    • Peak read QPS ≈ 23,148.
    • Peak order-creation QPS ≈ 23.15.

    Doing it in your head. Round 86,400 to 100,000, or 10^5, seconds per day. Then 200 million daily reads / 100,000 ≈ 2,000 QPS. Another useful shortcut is that one million requests per day is about 12 QPS. For a first interview estimate, an answer within a factor of two is usually fine if you state your rounding.

    Before running this calculator, predict the read-to-write ratio.

    C#Runs
    const double dailyUsers = 10_000_000;
    const double readsPerUser = 20;
    const double ordersPerUser = 0.02;
    const double secondsPerDay = 86_400;
    const double peakFactor = 10;
    
    double averageReads = dailyUsers * readsPerUser / secondsPerDay;
    double averageOrders = dailyUsers * ordersPerUser / secondsPerDay;
    
    Console.WriteLine($"Average read QPS: {averageReads:F2}");
    Console.WriteLine($"Average order QPS: {averageOrders:F2}");
    Console.WriteLine($"Peak read QPS: {averageReads * peakFactor:F2}");
    Console.WriteLine($"Peak order QPS: {averageOrders * peakFactor:F2}");
    Console.WriteLine($"Read-to-write ratio: {readsPerUser / ordersPerUser:F0}:1");
    
    int waitingRequests = 0;
    for (int second = 1; second <= 3; second++)
    {
        waitingRequests += 3; // Three requests arrive each second.
        waitingRequests -= Math.Min(waitingRequests, 2); // Only two finish.
        Console.WriteLine($"Waiting after {second} second(s): {waitingRequests}");
    }
    Output
    Average read QPS: 2314.81
    Average order QPS: 2.31
    Peak read QPS: 23148.15
    Peak order QPS: 23.15
    Read-to-write ratio: 1000:1
    Waiting after 1 second(s): 1
    Waiting after 2 second(s): 2
    Waiting after 3 second(s): 3

    Multiplying users by actions gives daily request counts. Dividing by 86,400 converts those counts to requests per second. Multiplying each average by 10 gives our assumed peak.

    The ratio is 1,000 reads per order creation. An order creation is a business operation, not one physical database write. It might insert an order, several order lines and a payment record.

    Why size for peak traffic? When requests arrive faster than the servers can finish them, the extra requests wait in a queue and the queue keeps growing. The calculator's final loop illustrates this: three requests arrive each second, but only two finish. The waiting count grows from one to two to three. Latency and errors can then grow. A daily average hides that pressure. Validate the peak factor and its measurement window against traffic data when available.

    The mistake to avoid. Do not turn daily users directly into QPS, or call order-creation QPS the database write rate. Both need another assumption.

    In an interview, say: “I calculate reads and writes separately, then apply an explicit peak factor. Here, that gives about 23,148 peak reads and 23 peak order creations per second. This read-heavy ratio points toward caching or read replicas: database copies that serve reads. Write-heavy traffic would instead make me investigate write capacity or partitioning, which divides data across databases. The ratio guides investigation; it does not choose the design by itself.”

    How do you estimate storage for five years?

    Start with the records you retain, not every request you serve. Our product reads do not each create a stored record.

    Payload means the data being stored or transferred before separately counted overhead. Assume each order's retained payload includes its order lines and totals 2,000 bytes.

    Use decimal units throughout: 1 KB = 1,000 bytes, 1 GB = 1 billion bytes, and 1 TB = 1 trillion bytes.

    Our first storage estimate assumes a flat 200,000 orders per day, five years of retention, and 365 days per year:

    Payload = records per day × bytes per record × retention days.

    That gives 200,000 × 2,000 × 1,825 = 730 GB.

    For this estimate, assume three live copies: one primary and two replicas. Allow indexes to occupy another 30% of payload on each copy.

    C#Runs
    const long ordersPerDay = 200_000;
    const long bytesPerOrder = 2_000;
    const int retentionDays = 5 * 365;
    const decimal indexFraction = 0.30m;
    const int liveCopies = 3;
    const decimal bytesPerGb = 1_000_000_000m;
    
    long payloadBytes = ordersPerDay * bytesPerOrder * retentionDays;
    decimal indexBytes = payloadBytes * indexFraction;
    decimal liveBytes = (payloadBytes + indexBytes) * liveCopies;
    
    // Separate illustrative budgets, already including their own copies.
    decimal logBytes = 20m * bytesPerGb * 7;
    decimal backupBytes = 1_000m * bytesPerGb;
    
    Console.WriteLine($"Payload, one copy: {payloadBytes / bytesPerGb:F0} GB");
    Console.WriteLine($"Indexes, one copy: {indexBytes / bytesPerGb:F0} GB");
    Console.WriteLine($"Live data, all copies: {liveBytes / bytesPerGb:F0} GB");
    Console.WriteLine($"Logs: {logBytes / bytesPerGb:F0} GB");
    Console.WriteLine($"Backups: {backupBytes / bytesPerGb:F0} GB");
    Console.WriteLine($"Combined budget: {(liveBytes + logBytes + backupBytes) / bytesPerGb:F0} GB");
    Output
    Payload, one copy: 730 GB
    Indexes, one copy: 219 GB
    Live data, all copies: 2847 GB
    Logs: 140 GB
    Backups: 1000 GB
    Combined budget: 3987 GB

    The one-copy subtotal is 730 + 219 = 949 GB.

    We separately assume seven days of logs at 20 GB per day, giving 140 GB. We also reserve an illustrative 1,000 GB for backups. These are assumptions, not quantities derived from order payload.

    The combined budget is 3,987 GB, before extra free space for operation and growth. Do not multiply logs and backups by three again: their stated budgets already include their own copies.

    Actual backup size depends on the backup method, retained versions and changes between backups.

    The mistake to avoid. Do not multiply an already replicated storage total by the replica count again. Keep a separate row for each category and say what copies it includes.

    In an interview, say: “I multiply retained records per day by record size and retention days. Then I account separately for indexes, live copies, logs and backups. This estimate assumes flat traffic; growth or a different retention policy changes the result.”

    How do you estimate bandwidth from QPS?

    Bandwidth here means the data-transfer rate we need to support. Calculate uploads and downloads separately because their sizes can differ greatly.

    Assume each product-read response carries 20 KB, and each order upload carries 2 KB. At peak:

    Bits per second = requests per second × payload bytes × 8.

    There are eight bits in a byte. Network rates are commonly expressed in bits per second, so leaving out that conversion makes a large difference.

    C#Runs
    double peakReadQps = 10_000_000d * 20 / 86_400 * 10;
    double peakOrderQps = 10_000_000d * 0.02 / 86_400 * 10;
    
    double downloadBitsPerSecond = peakReadQps * 20_000 * 8;
    double uploadBitsPerSecond = peakOrderQps * 2_000 * 8;
    
    Console.WriteLine($"Read-response downloads: {downloadBitsPerSecond / 1_000_000_000:F3} Gbit/s");
    Console.WriteLine($"Order-payload uploads: {uploadBitsPerSecond / 1_000_000:F3} Mbit/s");
    Output
    Read-response downloads: 3.704 Gbit/s
    Order-payload uploads: 0.370 Mbit/s

    These are selected traffic categories, not the whole network budget. They exclude product images, read-request bytes, order responses, internal database traffic, replication and HTTP/network overhead. Compression changes the transferred payload size, so use representative compressed sizes when applicable.

    A content delivery network (CDN) can answer some user requests without contacting our backend, which we call the origin. The origin then sends only the misses: if the CDN serves 90% of product-image bytes, the origin sends the other 10%.

    Continue with the request path, including CDNs and load balancers when you need to decide where this traffic flows.

    The mistake to avoid. Do not label payload bytes per second as network bits per second, or assume all user-delivered traffic crosses your application servers.

    In an interview, say: “I multiply peak QPS by average transferred payload bytes and by eight. I separate uploads and downloads, identify excluded traffic, and allow for protocol overhead and compression. I also distinguish user traffic from origin traffic.”

    How much cache memory do you need?

    For this estimate, we plan to keep copies of frequently requested products in a cache. We call those frequently requested products hot items.

    Assume the shop has one million products and we want to cache the hottest 10%. Each serialized product occupies 2 KB. Serialized size means the size of its encoded representation, such as JSON bytes.

    Interviewers often cite the 80/20 rule: a small share of items, say 20%, gets most of the traffic. Use it only as a stated assumption, not a measured hit rate. Our example assumes a different hot share: 10%.

    Hot payload = hot item count × bytes per item.

    That gives 100,000 × 2,000 = 200 MB. It is not yet a memory allocation estimate.

    C#Runs
    const int productCount = 1_000_000;
    const decimal hotFraction = 0.10m;
    const int payloadBytesPerItem = 2_000;
    const int assumedExtraBytesPerItem = 1_000;
    const decimal targetMemoryUse = 0.75m;
    const decimal bytesPerMb = 1_000_000m;
    
    decimal hotItems = productCount * hotFraction;
    decimal payloadBytes = hotItems * payloadBytesPerItem;
    decimal occupiedBytes = hotItems * (payloadBytesPerItem + assumedExtraBytesPerItem);
    decimal provisionedBytes = occupiedBytes / targetMemoryUse;
    
    Console.WriteLine($"Hot items: {hotItems:F0}");
    Console.WriteLine($"Payload: {payloadBytes / bytesPerMb:F0} MB");
    Console.WriteLine($"Including assumed overhead: {occupiedBytes / bytesPerMb:F0} MB");
    Console.WriteLine($"Provisioned memory, one copy: {provisionedBytes / bytesPerMb:F0} MB");
    Output
    Hot items: 100000
    Payload: 200 MB
    Including assumed overhead: 300 MB
    Provisioned memory, one copy: 400 MB

    For illustration, we allow another 1,000 bytes per item for keys and implementation overhead. That makes 300 MB occupied. The real overhead must come from the chosen cache and data representation.

    Headroom is capacity deliberately left unused to absorb variation. Targeting 75% memory use gives 300 / 0.75 = 400 MB provisioned for one copy. Add other copies or buffers separately where applicable.

    Keeping 10% of products does not imply that the cache answers 90% of lookups, or a 90% hit rate. That depends on which products users request and whether those entries are present and usable.

    The mistake to avoid. Do not treat serialized payload size as provisioned memory, or turn a hot-item percentage into a hit-rate prediction.

    In an interview, say: “I estimate hot items times item size, then add keys, implementation overhead and headroom. The 80/20 rule can supply an initial hot-item assumption, but the hot share is not the hit rate. Here, our assumed 10% hot share needs 400 MB for one copy after overhead and headroom. Additional copies or buffers need separate space.”

    How do you estimate latency and the critical path?

    Latency is the elapsed time for an operation within a stated boundary, such as a complete API request. A round trip includes travel to a destination and back.

    A region is a geographic area, such as West Europe, where a cloud provider runs one or more datacenters. An availability zone is a separated group of datacenters within a region, with independent power, cooling and networking.

    A microsecond (µs) is one thousandth of a millisecond (ms). A nanosecond (ns) is one thousandth of a microsecond.

    The table gives examples of the well-known “latency numbers every programmer should know.” Treat them as rough rules of thumb, not fixed promises.

    OperationRough scale to remember
    Main-memory accessAbout 100 ns
    SSD random readAbout 100 µs, with substantial variation
    Network round trip within a datacenterUsually under 1 ms; about 0.5 ms is a common rule of thumb
    Between availability zonesAbout 1–2 ms as a rough example; measure the actual path
    Between regionsOften tens to hundreds of milliseconds; about 50–150 ms across a continent, while nearby regions can be faster

    These scales are not complete API timings. Software work, waiting, request size and load all matter. Azure's regional latency statistics report median network round trips, not application guarantees. Azure's zone guidance also describes the placement and resilience trade-off: keeping communicating resources close can reduce latency, while spreading them across zones protects against zone failures.

    Suppose our product endpoint does 10 ms of initial work, calls catalog and stock services, then spends 10 ms building its response:

    flowchart TD
        A["Initial API work: 10 ms"] -->|calls| B["Catalog call: 40 ms"]
        A -->|calls| C["Stock call: 60 ms"]
        B -->|completes before| D["Build response: 10 ms"]
        C -->|completes before| D

    The response-building step waits for both independent calls.

    C#Runs
    const int initialMs = 10;
    const int catalogMs = 40;
    const int stockMs = 60;
    const int responseMs = 10;
    
    int sequentialMs = initialMs + catalogMs + stockMs + responseMs;
    int parallelMs = initialMs + Math.Max(catalogMs, stockMs) + responseMs;
    
    int networkBudgetMs = 40;
    int applicationBudgetMs = 20;
    int dependencyBudgetMs = 100;
    int waitingAndReserveMs = 40;
    
    Console.WriteLine($"Sequential server time: {sequentialMs} ms");
    Console.WriteLine($"Parallel server time: {parallelMs} ms");
    Console.WriteLine($"End-to-end budget: {networkBudgetMs + applicationBudgetMs + dependencyBudgetMs + waitingAndReserveMs} ms");
    Output
    Sequential server time: 120 ms
    Parallel server time: 80 ms
    End-to-end budget: 200 ms

    The critical path is the longest chain of steps that must run one after another; it sets the response time. Here it runs through the slower stock call: 10 + 60 + 10 = 80 ms, not the 120 ms sum of every step. Each call duration includes its own network time; do not add that time again.

    A latency budget divides a response-time target among parts of the request. Our illustrative 200 ms budget allocates 40 ms to the external network round trip, 20 ms to application work, 100 ms to dependency calls on the critical path, and 40 ms to waiting and reserve.

    The 99th percentile, or p99, is a duration at or below which 99% of observed requests finish. Adding the p99 of each call does not calculate the end-to-end p99. The slow observations need not belong to the same requests. Here is a numerical counterexample with two sequential calls across 100 requests. Each call takes 1 ms normally and 100 ms twice, but their slow requests do not overlap. We take the 99th sorted observation as p99.

    C#Runs
    int[] firstCall = Enumerable.Repeat(1, 100).ToArray();
    int[] secondCall = Enumerable.Repeat(1, 100).ToArray();
    firstCall[0] = 100;
    firstCall[1] = 100;
    secondCall[2] = 100;
    secondCall[3] = 100;
    
    int[] completeRequests = firstCall.Zip(secondCall, (first, second) => first + second).ToArray();
    int firstP99 = firstCall.OrderBy(duration => duration).ElementAt(98);
    int secondP99 = secondCall.OrderBy(duration => duration).ElementAt(98);
    int completeP99 = completeRequests.OrderBy(duration => duration).ElementAt(98);
    
    Console.WriteLine($"First call p99: {firstP99} ms");
    Console.WriteLine($"Second call p99: {secondP99} ms");
    Console.WriteLine($"Sum of call p99s: {firstP99 + secondP99} ms");
    Console.WriteLine($"Complete request p99: {completeP99} ms");
    Output
    First call p99: 100 ms
    Second call p99: 100 ms
    Sum of call p99s: 200 ms
    Complete request p99: 101 ms

    Each call's p99 is 100 ms, but the complete request's p99 is 101 ms, not 200 ms. Measure the complete request against its target, as described in defining performance targets.

    The mistake to avoid. Do not add every parallel operation's duration, or present a sum of component percentiles as a measured end-to-end percentile.

    In an interview, say: “My rough rules of thumb are memory around 100 ns, an SSD random read around 100 µs, and network trips inside a datacenter well under a millisecond, about 0.5 ms. Between zones, about 1–2 ms (Azure aims for under about 2 ms round trip); between regions, often tens to hundreds. These are not guarantees. For a request, I estimate the critical path, allocate a budget and measure the end-to-end percentile.”

    How does Little's law estimate requests in flight?

    Throughput is the rate at which work completes. Concurrency is the amount of work happening at the same time, including requests waiting within the boundary we measure. In the Little's law calculation below, L counts all requests inside that boundary, both waiting and being served.

    Little's law relates averages in a stable system:

    L = λW: the average number of requests in flight (L) equals the arrival rate λ (requests per second) times the average time W a request spends inside the boundary (seconds).

    Stable here means work is not accumulating without bound. Use the same system boundary and compatible time units for all three quantities.

    At 2,000 requests per second and 50 ms average request duration:

    C#Runs
    const double requestsPerSecond = 2_000;
    const double averageLatencyMs = 50;
    
    double averageLatencySeconds = averageLatencyMs / 1_000;
    double averageInFlight = requestsPerSecond * averageLatencySeconds;
    
    Console.WriteLine($"Average requests in flight: {averageInFlight:F0}");
    Output
    Average requests in flight: 100

    Converting 50 ms to 0.05 seconds gives 2,000 × 0.05 = 100 requests in flight on average.

    This helps check capacity assumptions, but it does not directly set a connection pool's size. A request may hold a database connection for only part of its lifetime, and pools exist per process or configured resource. For database connections, use database-operation throughput and connection-holding time within that boundary.

    The mistake to avoid. Do not multiply QPS by milliseconds without converting units, or treat an average concurrency estimate as a peak requirement.

    In an interview, say: “About 100 requests are in flight on average: Little's law gives 2,000 times 0.05 seconds. That assumes stable averages and consistent boundaries. It is an input to capacity sizing, not an automatic connection-pool setting.”

    How many server instances do you need?

    Start with sustainable capacity measured under representative load. Sustainable means an instance maintains the required response time and error rate, rather than briefly accepting many requests while work piles up.

    Suppose a representative load test finds that one instance handles 2,000 QPS at the required latency and error rate. The test must use the shop's request mix, realistic data and relevant dependencies.

    Our combined peak is approximately 23,171 QPS:

    Active instances = round up(peak QPS / sustainable QPS per instance).

    C#Runs
    double peakQps = 10_000_000d * (20 + 0.02) / 86_400 * 10;
    const int sustainableQpsPerInstance = 2_000;
    const int unavailableInstances = 1;
    
    int active = (int)Math.Ceiling(peakQps / sustainableQpsPerInstance);
    int total = active + unavailableInstances;
    
    int halfCapacity = sustainableQpsPerInstance / 2;
    int activeAtHalfCapacity = (int)Math.Ceiling(peakQps / halfCapacity);
    int totalAtHalfCapacity = activeAtHalfCapacity + unavailableInstances;
    
    Console.WriteLine($"Peak QPS: {peakQps:F2}");
    Console.WriteLine($"Active instances: {active}");
    Console.WriteLine($"Total allowing one unavailable: {total}");
    Console.WriteLine($"Active at half capacity: {activeAtHalfCapacity}");
    Console.WriteLine($"Total at half capacity, allowing one unavailable: {totalAtHalfCapacity}");
    Output
    Peak QPS: 23171.30
    Active instances: 12
    Total allowing one unavailable: 13
    Active at half capacity: 24
    Total at half capacity, allowing one unavailable: 25

    We need 12 active instances, or 13 deployed if any one instance may be unavailable. This is capacity arithmetic; it does not assume the extra instance sits idle.

    Now halve per-instance capacity to 1,000 QPS. Recompute the active count first: round up(23,171 / 1,000) = 24. Add one spare allowance to get 25, not 26.

    The unavailable-instance allowance describes our failure model: the outage we intend to tolerate. One unavailable instance is not the same as losing a zone containing several instances.

    Adding instances is horizontal scaling. It does not guarantee proportional capacity growth: a shared database or another dependency may become the limit. Test multiple instances together. Microsoft's guidance on capacity planning and performance testing explains why workload patterns and representative environments matter.

    The mistake to avoid. Do not divide by an unqualified benchmark, assume linear scaling, or double a total that already includes a spare allowance.

    In an interview, say: “I round up peak QPS divided by load-tested sustainable QPS per instance at the required latency and error rate. Then I add capacity for the stated failure model and validate shared dependencies and multi-instance scaling.”

    Check yourself

    Five million daily users each make 30 read requests per day. Assume a peak factor of 4. Approximately what is peak read QPS?

    A 6,944
    B 1,736
    C 416,667
    D 600,000,000
    Show answer

    Correct answer: A

    Daily reads are 150 million. Divide by 86,400 seconds to get about 1,736 per second on average, then multiply by the assumed peak factor of 4.

    A service needs 12 active instances at 2,000 QPS each. Its estimated peak is about 23,171 QPS, and it must tolerate one unavailable instance. Capacity per instance falls to 1,500 QPS. How many instances should you provision under the same assumptions?

    A 16
    B 17
    C 18
    D 25
    Show answer

    Correct answer: B

    Recompute the active requirement: round up 23,171 / 1,500 to get 16. Then add one unavailable-instance allowance, giving 17. Scaling the old total of 13 by 2,000 / 1,500 gives 18, because it scales the spare as well.

    Going deeper

    Growth changes the storage calculation. If order volume grows each year, calculate each year's retained records at that year's rate, then add them. Rolling retention means keeping only the most recent N years and deleting older records as new ones arrive. Those N years are the retention window. At a constant arrival rate and record size, the retained payload stops growing once that window is full. Count only records still inside it. Data deletion schedules and temporary working space can make provisioned storage larger than retained payload.

    Peak measurements need context. A one-minute average can hide a much sharper burst. Automatic scaling also takes time to detect demand and make capacity available. Validate those transitions, not just the final instance count. Azure's performance-efficiency guidance treats performance as an ongoing design and measurement concern.

    Physical limits still matter. A bandwidth estimate does not prove a network connection can sustain the required rate with acceptable latency. Likewise, enough storage bytes do not prove that a database can serve the required reads and writes. Check data-transfer rates and operation capacity as well as space.

    Test the assumptions with the greatest effect. Recalculate with larger responses, lower cache effectiveness or half the measured instance capacity. A design that becomes unaffordable under a small assumption change needs better evidence before you commit to it.

    Sources

    Practice

    Practice test: System Design Estimation Practice: Check the Units and Assumptions5 questions · 1 mark each, no negative marking
    Take the test
    Practice: Back-of-the-Envelope Estimation: QPS, Storage, Bandwidth and Latency9 questions · 9 marks
    Sign in to mark lessons done and keep your place in the course.Sign in

    Checked before publishing: C# examples run on .NET 10, links opened, reviewed while it was written and read in full. How lessons are checked

    Updated 28 Nov 2026 ·