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
-
Initial request latency → 40 ms
-
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
-
Data transfer → 40 ms (dominated by packet latency)
-
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