These exercises aim to sharpen your intuition for the latency of computer systems, inspired by Jeff Dean's 2009 keynote at LADIS. Solutions aren't meant to be exact, but should provide a basis for thinking about problems such as these.

Curated and solved by Tej Singh.

Fetching Integers

Problem: How long would it take for a machine located on the west coast of the US to fetch an array of 10,000 128-bit integers from a single server (hosted in us-east-1) and write the integers to 100 files (HDD)?


Solution
  1. Initial request latency → 40 ms

  2. Reading integers from memory:

    • Data size: (10,000 × 128 bits) × (1 byte / 8 bits) × (1 kb / 1000 bytes) = 160 kb
    • Memory throughput: > 10 gb/s, negligible
  3. Data transfer → 40 ms (dominated by packet latency)

  4. Writing to disk:

    • Data size: 160 kb × 100 files = 16 mb
    • Write speed: (16mb * 1s/200mb) → 80 ms
    • I/O latency:
      • 10 ms per open() call
      • 100 files → 1000 ms total

Total time: 40 ms (request latency) + 40 ms (response latency) + 80 ms (writes) + 1000 ms (I/O latency) = ~1.16 s