AlgoViz

Resource estimation examples

medium 30 min

Five complete estimates, each from the given facts to a decision: a timeline, a URL shortener, video streaming, chat and a shop.

See it run

Five systems, the same sums, five different limits.

Operations

Timeline

500 million users read 100 posts ten times a day and write one.

Step 1 of 5

Reads

SumWorkingResult
Reads500M × 10 / 86,40058K/s, peak 174K
Writes
Storage
Bandwidth
Machines

5 billion a day: 58,000 a second, 174,000 at peak.

Step 1: Reads

reads  = 500_000_000 * 10 / 86_400writes = 500_000_000 * 1 / 86_400stored = 500_000_000 * 1_000 * 365 * 5out    = reads * 100 * 1_000 * 8servers = ceil((reads + writes) * 3 / 700) + 1
Limit
Reads
You leave with
Prepared timelines

Ten requests read per request written, but a thousand posts. Say which you mean.

In the real world

The same resource estimation examples doing real jobs. Pick one and step through it.

Five systems with similar sums, limited by different things.

Step 1 of 5

Timeline

SystemPeakStorageLimit
Timeline174K reads/s2.7 PBfan-out reads
Short links
Video
Chat
Shop

Many reads, each gathering a hundred posts.

Step 1: Timeline

Common mistakes

The bugs interviewers watch for, with the fix beside each.

  • Trusting the brief

    critical

    Given facts can contradict each other. A second method finds it in ten seconds.

    Wrong
    peak = 1_000_000      # as given
    Right
    peak = users * hours / 24 * 3assert peak < 2 * given, "ask"
  • Counting messages, not deliveries

    major

    A group message is one write and many sends. Gateways feel the sends.

    Wrong
    load = messages
    Right
    load = messages * (group - 1)
  • Forgetting the peak for machines

    major

    The average is never the hour in which a system falls over.

    Wrong
    servers = average / capacity
    Right
    servers = ceil(peak / (capacity * 0.7)) + 1
  • Stopping at the total

    critical

    A thousand orders a second on a thousand products is easy. On one product it is a queue.

    Wrong
    ok = orders < database_limit
    Right
    ok = orders_for_hottest < 1 / lock_time

Interview tips

  • How to explain it

    • Same sums every time.
    • Find which result no machine can carry.
    • End each sum with a part or with nothing.
  • Memory trick: the class trip

    • How many people.
    • How fast through the gate.
    • Luggage, road, rest stops.
  • Quick guesses

    • Media: bandwidth and storage.
    • Live: connections.
    • Sale: one row. Text: usually nothing.
  • Say out loud

    • What you assume.
    • Which facts disagree.
    • What you decide not to compute.