Fallacy 2: Latency is Zero
What You'll Learn
You'll understand why network latency is a critical cost in distributed systems and how to mitigate its impact through caching, batching, and asynchronous patterns.
The Core Problem
The second fallacy assumes network calls happen instantaneously—but every network hop takes real time. A local function call might execute in nanoseconds, but a network request across data centers can take 50-200 milliseconds or more. When you multiply this across hundreds or thousands of requests, latency becomes a major bottleneck.
The hidden cost: If your application makes 10 sequential network calls at 100ms each, that's a full second of waiting—even if the actual work takes milliseconds.
Why This Matters
Unlike in-memory operations, network latency is governed by physics: the speed of light, routing infrastructure, and geographic distance. You can't make it disappear, but you can design around it.
Mitigation Strategies
Caching: Store frequently accessed data locally or in a nearby cache (like Redis) to avoid repeated network roundtrips. Think of it like keeping commonly used tools on your workbench instead of walking to the storage room every time.
Batching: Instead of making 100 individual API calls, combine them into one bulk request. This trades one larger latency hit for many smaller ones.
Async patterns: Don't block waiting for responses. Fire off requests and continue other work, then handle results when they arrive. This is like sending multiple emails and checking replies later, rather than waiting for each response before sending the next.
Key Takeaway: Network latency is unavoidable but manageable—design systems that minimize roundtrips through caching, batch operations where possible, and use asynchronous communication to prevent blocking on slow network calls.