Step 2 of 5
Systems Knowledge
Latency numbers every developer should know, latency vs throughput vs bandwidth, and publish-subscribe messaging.
11 min read
Good engineers carry a rough model of how long things take and how data moves. It's what lets you glance at a design and say "that's going to be slow" before anyone builds it. This guide covers the latency numbers worth memorizing, the three performance terms people most often confuse, and the publish-subscribe pattern at the heart of event-driven systems.
Latency numbers every developer should know#
These are orders of magnitude, not benchmarks - exact values vary by hardware - but the ratios between them are what matter.
- L1 cache reference~1 ns
- L2 cache reference~4 ns
- Main memory (RAM) reference~100 ns
- SSD random read~100 µs
- Round trip within a datacenter~500 µs
- HDD disk seek~10 ms
- Round trip California ↔ Netherlands~150 ms
Log scale - each step right is roughly 10× slower.
Make it human#
Scale everything so an L1 cache hit takes one second:
| Operation | Real | If L1 = 1 second |
|---|---|---|
| L1 cache | 1 ns | 1 second |
| L2 cache | 4 ns | 4 seconds |
| RAM | 100 ns | ~1.7 minutes |
| SSD random read | 100 µs | ~1.2 days |
| Datacenter round trip | 500 µs | ~6 days |
| HDD seek | 10 ms | ~4 months |
| Transatlantic round trip | 150 ms | ~4.8 years |
What the numbers tell you#
- Memory is ~100× slower than cache. Data layout matters: arrays that fit in cache beat pointer-chasing structures.
- Network calls dwarf in-process work. One cross-service call inside a datacenter costs as much as thousands of memory reads. Batch calls; avoid chatty APIs; watch for N+1 queries.
- Disks are slow; seeks are slower. SSDs are ~100× faster than spinning-disk seeks for random reads. Sequential access is always faster than random.
- The speed of light is a hard limit. A cross-continent round trip is ~150 ms no matter how fast your code is - put data and compute close to users.
- LLM calls are in the seconds. A model call takes hundreds of milliseconds to many seconds, making it the slowest operation in most AI systems by far. Cache, stream, and parallelize accordingly.
Latency vs throughput vs bandwidth#
Three different things that people use interchangeably:
Latency
timeHow long one operation takes, start to finish. One round trip. Measured in ms. 'How long did my request take?'
Throughput
rateHow much work completes per unit of time. Measured in requests/sec or tokens/sec. 'How many requests can we serve?'
Bandwidth
capacityThe maximum data rate a link can carry. Measured in bits/sec. 'How wide is the pipe?'
The highway analogy: bandwidth is the number of lanes, latency is how long one car takes to drive the route, and throughput is how many cars actually arrive per hour. Adding lanes raises capacity but doesn't make any individual car faster.
They trade off. Batching raises throughput but adds latency (requests wait for the batch). LLM serving is the textbook case: bigger batches mean more total tokens per second across users, but each user's tokens arrive a little slower.
Two relationships worth knowing:
Little's Law - average items in a system = arrival rate × average time in the system. 100 requests/sec × 0.2 s each = 20 requests in flight on average.
Bandwidth-delay product - how much data is 'in the pipe' at once. A 1 Gbps link with 100 ms round trip holds ~12.5 MB in flight, which is why long, fat links need large network buffers.
Pub-sub architecture#
In publish-subscribe, a publisher sends a message to a topic once. Every subscriber to that topic receives its own copy, independently. The publisher doesn't know - or care - who's listening.
- Email serviceSends the receipt
- InventoryReserves stock
- AnalyticsRecords the sale
- Fraud checkScores the order
Pub-sub vs a message queue#
Pub-sub (fan-out)
- Each subscriber gets every message.
- Used to broadcast events: 'this happened.'
- Subscribers are independent - add or remove freely.
- Examples: Kafka topics with multiple consumer groups, Google Cloud Pub/Sub, AWS SNS, Redis pub/sub, NATS.
Queue (point-to-point)
- Each message goes to exactly one worker.
- Used to distribute work: 'do this.'
- Add workers to process faster (competing consumers).
- Examples: AWS SQS, RabbitMQ work queues, Celery, one Kafka consumer group.
When to use it#
- Decoupling: services evolve and deploy independently; the publisher has no list of consumers to maintain.
- Fan-out: one event triggers many independent reactions.
- Buffering and resilience: a slow or offline subscriber catches up later without slowing the publisher (with a durable broker).
When not to: when the caller needs an immediate answer (use a direct request), or when strict ordering and exactly-once processing across many consumers are critical and you can't design for idempotency.
Delivery guarantees#
| Guarantee | Meaning | Implication |
|---|---|---|
| At-most-once | Delivered zero or one time | Fast; messages can be lost |
| At-least-once | Delivered one or more times | The common default - consumers must be idempotent |
| Exactly-once | Effectively once | Possible within specific systems with careful configuration; expensive |