Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 3 of 6 · Concept · 20 min · revision 1

Numbers to carry in your head: latency, throughput, powers of two

Get units right (KB versus KiB, bits versus bytes, seconds in a day), learn a dated ladder of latency and throughput orders of magnitude, use it to find the slowest step of a request, and measure two numbers on your own machine.

Contentsand lesson path

What you will learn

  • Use latency and throughput reference numbers to locate the likely bottleneck before choosing components.

01. Why it matters

Before you choose a database, a cache or a queue, you need to know which part of the work will be slow. A handful of reference numbers tells you that in minutes: reading memory takes around a hundred nanoseconds, a round trip inside a data centre around half a millisecond, a round trip across an ocean around a hundred milliseconds. These differ by factors of a thousand, so even rough values are enough to show which step dominates.

The numbers are orders of magnitude, not constants. They depend on the hardware, the year, the size of the operation and whether you look at a typical or a slow case. This lesson gives each number with its source and date, shows how to use them to find a bottleneck, and ends by measuring two of them on your own machine. First, the units, because a unit error can be bigger than any of these differences.

02. Units: powers of two, bits and bytes, seconds

Three conversions cause most estimation mistakes:

  • Decimal and binary sizes. A kilobyte (KB) is 1,000 bytes; a kibibyte (KiB) is 2 to the power 10, or 1,024 bytes. The binary names (KiB, MiB, GiB, TiB) were approved by the International Electrotechnical Commission (IEC) in 1998, so that kilo and mega could keep their decimal meaning. Disk makers and network speeds use decimal units; memory sizes and many operating-system tools use binary ones, sometimes still labelled GB or just G.
  • Bits and bytes. Networks are measured in bits per second (Mbit/s, Gbit/s); storage and files in bytes. There are 8 bits in a byte, so a 1 Gbit/s link moves at most 125 MB/s.
  • Seconds in a period. A day has 86,400 seconds. Rounding that to 100,000 makes mental arithmetic easy and overstates a day by about 16%, which is fine for an estimate as long as you remember the direction of the error.

The script below prints the conversions you will use most. Every printed line carries its unit.

Python · units.py
"""Unit conversions you will use in every estimate (Python 3.12, stdlib only)."""

print("Binary prefixes next to their decimal neighbours (bytes)")
for prefix, power in (("Ki", 10), ("Mi", 20), ("Gi", 30), ("Ti", 40)):
    size = 2**power
    decimal_power = power // 10 * 3
    ratio = size / 10**decimal_power
    print(f"   1 {prefix}B = {size:>17,} bytes = {ratio:.3f} x 10^{decimal_power}")

disk_bytes = 2 * 10**12
print(f"A disk sold as 2 TB holds {disk_bytes / 2**40:.2f} TiB")

print("Seconds in a period")
day = 24 * 60 * 60
for name, seconds in (("1 day", day), ("30 days", 30 * day), ("365 days", 365 * day)):
    print(f"   {name:>8}: {seconds:>10,} s")
print(f"Rounding a day to 100,000 s overstates it by {100_000 / day - 1:.1%}")

print("Bits per second to bytes per second (8 bits = 1 byte)")
for label, bits_s in (("100 Mbit/s", 100e6), ("1 Gbit/s", 1e9), ("10 Gbit/s", 10e9)):
    print(f"   {label:>10} = {bits_s / 8 / 1e6:>7,.1f} MB/s")
Terminal
python3.12 units.py
Expected output
Binary prefixes next to their decimal neighbours (bytes)
   1 KiB =             1,024 bytes = 1.024 x 10^3
   1 MiB =         1,048,576 bytes = 1.049 x 10^6
   1 GiB =     1,073,741,824 bytes = 1.074 x 10^9
   1 TiB = 1,099,511,627,776 bytes = 1.100 x 10^12
A disk sold as 2 TB holds 1.82 TiB
Seconds in a period
      1 day:     86,400 s
    30 days:  2,592,000 s
   365 days: 31,536,000 s
Rounding a day to 100,000 s overstates it by 15.7%
Bits per second to bytes per second (8 bits = 1 byte)
   100 Mbit/s =    12.5 MB/s
     1 Gbit/s =   125.0 MB/s
    10 Gbit/s = 1,250.0 MB/s

The gap between decimal and binary grows with size: 2.4% at kilo, 7.4% at giga, 10% at tera. A 2 TB disk shows up as about 1.82 TiB, which a tool may print as 1.8T. Nothing is missing; the units differ. In an estimate, pick one system, say which, and convert at the boundary. This skill uses decimal units for storage and traffic, and GiB for memory.

03. A latency ladder, with dates

The table below puts two sources side by side. The first is the list known as Latency numbers every programmer should know, credited to Jeff Dean and Peter Norvig; most of its figures date from about 2012. The second is the napkin-math project by Simon Eskildsen, last measured in October and November 2026 on large cloud virtual machines (GCP C4, AWS m8i and m8g); its disk and network figures are p99 values. The operations are not identical (block sizes differ, and one source gives typical values while the other gives p99), so read each row as an order of magnitude, and use the last column as the number to remember.

Latency of one operation · orders of magnitude, not constants
Operation                            ~2012 list   2026 cloud VMs   Remember
main memory read                     100 ns       150 ns           ~100 ns
SSD random read (4 to 8 KiB)         150 µs       200 µs (p99)     ~150 µs
round trip, same data centre/zone    500 µs       250 µs (p99)     ~0.5 ms
round trip between two zones         -            1 ms (p99)       ~1 ms
hard disk seek or random read        10 ms        25 ms (p99)      ~10 ms
round trip, US to Europe (*)         150 ms       100 ms (p99)     ~100 ms

1 ms = 1,000 µs = 1,000,000 ns. Neighbouring rows differ by 2 to over 1,000 times.
(*) 2012: California-Netherlands-California. 2026: a cross-Atlantic region pair,
    1 MiB. Part of the drop comes from the shorter route.

Notice what changed in fourteen years and what did not. Memory latency barely moved. Round trips inside a data centre or zone (one of the separate data centres that make up a cloud region) are lower in the 2026 measurements, even at p99. Hard disks still take milliseconds, because a mechanical arm has to move. And long-distance round trips are bounded by physics: light in glass fibre travels at about two-thirds of its speed in a vacuum, roughly 200,000 km per second, so every 100 km of cable adds about 1 ms to a round trip. Cables do not run in straight lines, so measured round trips are longer than the straight-line distance suggests.

Throughput, the amount of work per second, has its own ladder. The napkin-math figures for 2026 give about 30 GiB/s for reading memory sequentially with one thread, about 5 GiB/s for reading a local SSD sequentially, about 3 GiB/s for the network between two large virtual machines in the same zone, and about 200 MiB/s for reading a hard disk sequentially (napkin-math uses binary units, so each figure is 5 to 7% larger in decimal units). Smaller machines get less, and cloud providers publish network and disk limits per instance type. For estimates, remember the shape: memory is tens of GB/s, SSDs and fast networks a few GB/s, a hard disk a few hundred MB/s.

04. Use the numbers to find the bottleneck

To find the slow step of a request, list what it does, write a reference number next to each step and add them up. Steps that run one after another add; steps that run in parallel cost as much as the slowest of them. The script below does this for an order-history page that checks a session in a cache, loads 30 orders with one database query each, calls a tax service in another region and serialises the result.

Python · budget.py
"""Add up a request's latency from reference numbers (Python 3.12, stdlib only)."""

# Orders of magnitude in microseconds, from napkin-math (measured Oct-Nov 2026 on
# cloud VMs; network and disk figures are p99). Not constants: measure your own.
SAME_ZONE_RTT = 250
CACHE_GET = 25  # plus one round trip
PK_QUERY = 40  # primary-key query, plus one round trip
CROSS_REGION_RTT = 50_000  # another region on the same continent

# (step, how many times it runs one after another, microseconds each)
steps = [
    ("check session in cache", 1, SAME_ZONE_RTT + CACHE_GET),
    ("load 30 orders, one query each", 30, SAME_ZONE_RTT + PK_QUERY),
    ("call tax service in another region", 1, CROSS_REGION_RTT),
    ("serialise 30 orders to JSON", 30, 1),
]

total = sum(count * each for _, count, each in steps)
for name, count, each in steps:
    cost = count * each
    print(f"{name:<36} {cost:>7,} µs  {cost / total:>4.0%}")
print(f"{'total':<36} {total:>7,} µs  (about {round(total / 1000)} ms)")
Terminal
python3.12 budget.py
Expected output
check session in cache                   275 µs    0%
load 30 orders, one query each         8,700 µs   15%
call tax service in another region    50,000 µs   85%
serialise 30 orders to JSON               30 µs    0%
total                                 59,005 µs  (about 59 ms)

The call to another region is 85% of the total. Loading the orders in one query instead of thirty would save about 8 ms; keeping tax rates in the same region, or caching them, would save about 50 ms. Without the arithmetic, many people start by tuning the JSON code, which costs almost nothing here. Because the inputs are p99 values added together, the total is pessimistic: use it to rank the steps, not to predict the exact latency.

The same habit works for throughput. To copy a 2 TB backup over a 1 Gbit/s link, divide the bytes by 125 MB/s: 16,000 seconds, about four and a half hours, before any protocol overhead. If the backup window is two hours, the link is the bottleneck, whatever the disks can do.

05. Replace a reference number with a measurement

Reference numbers get you started; measurements on the hardware you will use replace them. This script measures memory copy speed and the time to write 4 KiB and wait for the disk to confirm it (fsync), similar to what a database does when it commits. Run it from a folder on the disk you want to measure.

Python · measure.py
"""Measure two numbers on your own machine (Python 3.12, stdlib only).

Run it from a folder on the disk you care about: it writes a small test file,
probe.bin, there and deletes it afterwards.
"""
import os
import statistics
import time


def copy_speed_gib_s(size_mib: int = 256, rounds: int = 5) -> float:
    source = bytearray(size_mib * 2**20)
    target = bytearray(len(source))
    best = float("inf")
    for _ in range(rounds):
        start = time.perf_counter()
        target[:] = source  # copies every byte into memory already allocated
        best = min(best, time.perf_counter() - start)
    return size_mib / 1024 / best


def fsync_ms(writes: int = 200) -> tuple[float, float]:
    block = os.urandom(4096)
    timings = []
    with open("probe.bin", "wb") as f:
        for _ in range(writes):
            start = time.perf_counter()
            f.write(block)
            f.flush()
            os.fsync(f.fileno())  # wait until the disk says the data is stored
            timings.append((time.perf_counter() - start) * 1000)
    os.remove("probe.bin")
    timings.sort()
    return statistics.median(timings), timings[int(0.99 * len(timings)) - 1]


print(f"memory copy: {copy_speed_gib_s():.1f} GiB/s (best of 5 copies of 256 MiB)")
median, p99 = fsync_ms()
print(f"4 KiB write + fsync: median {median:.1f} ms, p99 {p99:.1f} ms (200 writes)")
Terminal
python3.12 measure.py
Illustrative output · one run, November 2026, on a 2012 desktop (Core i7-3770) writing to a 7,200 rpm hard disk; your numbers will differ
memory copy: 6.8 GiB/s (best of 5 copies of 256 MiB)
4 KiB write + fsync: median 13.8 ms, p99 22.3 ms (200 writes)

On this old desktop, memory copies at about 7 GiB/s, well below the 2026 server figure for reading (a copy both reads and writes, on hardware 14 years older), and each confirmed write to the hard disk takes about 14 ms, in line with the ~10 ms rung of the ladder. A second run seconds later gave a median of 21 ms and a p99 of 72 ms: on a busy machine tail numbers move a lot, so repeat a measurement before you trust it. The script appends, so every fsync also records the new file size; databases usually write into log files allocated in advance, which can make SSD commits several times cheaper. On a laptop SSD the fsync time is usually far lower. A design that confirms every order with its own fsync on that hard disk could commit only about 70 orders per second, one after another, unless it batches several orders into one write. That is the kind of fact you want before choosing components.

06. Check your understanding

Practice check · 3 questions

Units, sources and bottlenecks

Use units and reference numbers to reason about three new situations.

Q1. You plug in a new SSD sold as 500 GB. Before creating any file system you run `lsblk`, which reports its size as roughly 466G. What explains the difference?
Q2. Your design calls fsync once for every order on a local disk. A 2012 reference list says an SSD random read takes about 150 µs. Your own test of 4 KiB writes with fsync, on the disk model you will deploy, gives a median of 2 ms. Which number should the estimate use?
Q3. A collector must receive 1.5 GB/s of telemetry on one server with a 10 Gbit/s network card, compress it 4:1 on 8 cores that each compress about 400 MB/s, and append the result to an NVMe drive that sustains about 2 GB/s. Which part limits it first?
Practice only: not graded, not saved, not evidence.

07. Apply it

For each of your three practice prompts, pick the busiest path and write its latency budget, as budget.py does:

  1. Paste service: reading a paste by its link. Ride-hailing: a driver phone reporting its position until a nearby rider can see it. Metrics pipeline: a measurement travelling from a server to the storage behind the dashboards.
  2. List each step, mark whether it runs in sequence or in parallel, and write a reference number with its source and year.
  3. Name the step that dominates, and one change that would remove most of it.
  4. Run measure.py on your own machine and add the result, with the machine and date, to one of the pages.

08. Review prompt

Without looking back, answer in your own words:

  1. How many bytes per second can a 10 Gbit/s link carry at most, and how many GiB is a 1 TB disk?
  2. Give the order of magnitude of a memory read, a round trip inside a data centre, a hard-disk seek and a round trip across an ocean.
  3. Why are these numbers orders of magnitude rather than constants, and what should you write next to each one you use?
  4. In a latency budget, how do steps in sequence and steps in parallel combine?

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

10 questions · about 8 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check