Rules for Low-Latency Systems

Practical habits that keep response times low and predictable under load.

Advanced8 min read3 interview questions

Low latency is rarely about one clever trick. It comes from removing work from the critical path: fewer hops, less waiting, less data and fewer surprises at the tail.

The rules below apply whether you build trading systems, real-time games or an ordinary API that must answer in under 100 ms.

Diagram

RequestNearby edgefewer milesServiceno blockingIn-memory datacache / poolAsync queueslow work laterResponse
Keep the critical path short: serve close to the user, read from memory and push slow work off the request.

How it works

  1. Measure first: trace a request and find where the time goes.
  2. Remove or parallelise network calls on the critical path.
  3. Keep hot data in memory and use connection pools.
  4. Move non-essential work (emails, analytics, resizing) to background queues.
  5. Compress and trim payloads; return only the fields the client needs.
  6. Avoid locks and garbage-collection pressure in hot code; reuse buffers.
  7. Deploy close to users and keep services in the same region as their data.
  8. Set timeouts everywhere so one slow dependency cannot stall the request.

Key concepts

Critical path
The chain of work the user must wait for. Everything else should happen in parallel or later.
Connection pooling
Reuse database and HTTP connections instead of paying for handshakes on every call.
Batching
Combine many small reads or writes into one round trip.
Pre-computation
Calculate expensive results ahead of time (materialised views, denormalised read models).
Tail latency
Optimise p99, not just the average. Hedged requests and timeouts help.

Trade-offs

Benefits

  • Better user experience and conversion
  • Lower latency usually means lower resource use
  • More headroom under traffic spikes

Costs

  • Pre-computation and caching add complexity and staleness
  • Micro-optimisation can make code hard to maintain

Use it when

  • User-facing APIs with strict response targets
  • Real-time features: chat, games, live dashboards, payments

Common mistakes

  • Optimising without profiling
  • Logging synchronously to disk or a remote service on every request
  • Cross-region database calls hidden inside an innocent repository method

Interview questions

Q1Your API p50 is 40 ms but p99 is 2 seconds. Where do you look?
Things that affect a few requests: garbage-collection pauses, lock contention, cold caches, slow database queries for large tenants, retries and a slow downstream dependency. Distributed traces of slow requests show which.
Q2What is a hedged request?
If a call has not returned within, say, the p95 time, send a duplicate to another replica and use whichever answers first. It cuts tail latency at a small cost in extra load.
Q3Why does async logging help latency?
Writing logs to a lock-free in-memory buffer returns immediately; a background thread flushes to disk or the network, keeping I/O off the request path.