Part 1 · Blueprint 02
Latency Numbers & Networking Foundations
15 min reading · Sources · Editorial review pending
Connection establishment and sequential dependencies consume time before useful work completes.
Page details
Published date · Last edited:
Draft edition. Editorial review and supplementary reading recommendations are still being completed.
Format: Architecture walkthrough. Prerequisites: the beginner bootcamp. Chapter prerequisites: Back-of-Envelope Capacity Estimation.
Sixty-second mental model
Problem: Connection establishment and sequential dependencies consume time before useful work completes.
Use: Reuse connections and propagate the remaining deadline.
Design boundary: Allocate one user-visible deadline across DNS/connection setup, queueing, service work and dependencies. Distinguish a measured percentile from a deadline: neither average latency nor adding independent p99 values predicts the end-to-end p99.
Layer 1 · Intuition
Hypothetical scenario: Northwind is designing latency budgets. Maya represents product requirements, Dev implementation and Priya reliability. The team must agree what one network exchange means and which component owns the request deadline.
Think of a parcel crossing several depots. Separate the requester from request deadline, then identify the retained evidence needed after failure.
- Authority
- The entitled state owner.
- Invariant
- A rule preserved across concurrency and failures.
- Client
- A program acting as the requester in an interaction. Analogy: A customer placing an order at a counter.
- Connection pool
- A bounded set of reusable connections managed for callers. Analogy: A shared set of open phone lines reused for many calls.
- DNS
- Domain Name System: a distributed system for resolving names into records such as IP addresses. Analogy: A directory that finds an address from a name.
- HTTP
- Hypertext Transfer Protocol: application semantics for requests and responses over the web. Analogy: A shared form for asking a service and reading its answer.
- HTTP/2
- An HTTP mapping that multiplexes streams over a connection, commonly TCP. Analogy: Several conversations sharing one ordered delivery pipe.
Architecture and worked reasoning
Design boundary: Allocate one user-visible deadline across DNS/connection setup, queueing, service work and dependencies. Distinguish a measured percentile from a deadline: neither average latency nor adding independent p99 values predicts the end-to-end p99.
Responsibilities on the request path
Workload and limiting resource
Hypothetical deadline: 300 ms. Reserve 40 ms for network/response and 30 ms safety margin, leaving 230 ms. If admission consumed 50 ms, only 180 ms remains for service and dependencies. Two serial 100 ms calls cannot fit; concurrency helps only if those calls are independent and their combined resource demand is affordable.
Keep the units attached to each intermediate result. The assumptions above describe a hypothetical exercise, not observed vendor capacity. A real capacity decision also needs a measured service curve, skew, recovery traffic and an explicit admission policy for overload.
Mutation or publication path
- Create a deadline at entry and carry the remaining budget.
- Reject work that cannot finish usefully rather than letting queues grow.
- Cancel downstream work where the interface actually supports cancellation.
Observation and recovery path
- Separate network setup from reused-connection requests.
- Trace queue residence and service time independently.
- Report timeout outcomes separately from slow successful responses.
Failure that changes the decision
Hypothetical scenario: An upstream timeout releases a socket while expensive downstream work continues. Repeated retries create orphan work; propagate deadlines and bound attempt counts.
Attempt this decision before reading the explanation
A dependency has p99 of 100 ms. Are two serial calls guaranteed to fit 200 ms?
No. Percentiles do not compose by simple addition, distributions may be correlated, and connection/queue overhead remains. Use joint traces or a justified probabilistic model and enforce the actual remaining deadline.
Supporting mechanism analysis
Hypothetical scenario: Northwind. Maya represents product, Dev implementation and Priya reliability. The following workflow develops the underlying mechanism.
Hypothetical scenario. At Northwind, The price page waits on connections before Postgres sees a query.
In short. Allocate round trips and service time separately. Measure the slow dependency on the actual critical path.
Capacity answers how much demand arrives. Networking adds where the work travels, which exchanges must finish first, and how connections carry that work. A wide pipe does not eliminate propagation delay, server queues, connection setup or dependency ordering. The useful design question is which part of the user's wait changes when an architectural choice changes.
For a payload of a known size, dividing bits by a chosen transfer rate estimates serialization time under that simplified model. It does not count travel time, contention, request processing or time spent waiting for dependencies. A small request can therefore take longer than a much larger local transfer.
Similarly, a protocol version does not establish a latency guarantee. RFC 9113 specifies HTTP/2 streams and their multiplexing over a connection. This changes application-level scheduling, but a shared TCP connection still has ordered transport delivery. QUIC's stream model removes that particular cross-stream delivery dependency; congestion, path quality and application dependencies still matter.
A connection is also a finite resource. Reusing connections can avoid repeated setup, while a pool with too few usable slots can make callers queue. Making the pool enormous can instead overload a downstream service. Identify both the work saved and the load admitted.
The response's critical path is the longest required dependency chain, not the sum of all work performed anywhere. Parallelism can reduce elapsed time while increasing simultaneous resource demand. It also changes failure policy: decide whether missing inventory blocks the result or can be represented honestly as unavailable.
Northwind's landing page crosses several independently operated boundaries. DNS finds an address; a transport connection carries bytes; TLS authenticates and protects the connection; HTTP defines the request and response. A load balancer chooses an upstream destination, but that choice does not prove that the destination has enough free application or database capacity. Connection health and useful request success are separate observations.
For a hypothetical cold path, let DNS consume 20 ms and the network round trip be 40 ms. A TCP handshake consumes one such round trip, and the simplified TLS 1.3 handshake budget consumes another. Sending a request and receiving its first response adds a third. The communication subtotal is therefore 20 + 40 + 40 + 40 = 140 ms before application processing, queueing and response-body transfer. These are declared teaching assumptions, not internet latency measurements. A reused connection avoids some setup work but retains request and application costs.
Hypothetical scenario. Choose three sequential remote exchanges. Each has a 40 ms network round trip and 10 ms of server work, with no queueing, overlap or connection setup included. One exchange takes 40 + 10 = 50 ms; the sequence takes 3 × 50 = 150 ms. If the final two exchanges are independent after the first, the required path becomes 50 + max(50, 50) = 100 ms. Work is still performed by all three dependencies.
Now choose an established connection transferring a 2,000-byte response over a hypothetical 100,000,000-bit/s usable payload rate. Serialization is 2,000 × 8 ÷ 100,000,000 = 0.00016 seconds = 0.16 ms. This narrow component is small relative to the chosen 40 ms round trip. It does not establish the complete download time because the calculation deliberately excludes other costs.
For pool reasoning, choose a stable arrival rate of 200 operations/s and a mean slot-holding time of 0.1 seconds. Rate multiplied by holding time gives an estimated mean occupancy of 200 × 0.1 = 20 slots under the stated steady-flow accounting. This is not a safe pool-size prescription: variability, uneven scheduling, long operations and the downstream limit still require examination.
If the pool exposes 25 slots and operations occupy each for exactly 0.1 seconds with no other overhead, its idealized ceiling is 25 ÷ 0.1 = 250 operations/s. At an attempted 300 operations/s, the model has 300 − 250 = 50 operations/s of excess demand. An unbounded wait list grows instead of creating service capacity. A real system needs admission and timeout policies, not reliance on the idealized ceiling.
The primary reference establishes this concrete distinction: hTTP/2 multiplexing is distinct from TCP/application dependencies.
Traffic distribution adds another boundary. A Layer 4 distributor routes using transport-level information, whereas a Layer 7 proxy can use application-level information such as an HTTP route. A choice depends on required routing behavior, termination, visibility and operational cost. There is no universal proxy throughput figure that can replace measurements of the intended request mix.
Discovery supplies candidate endpoints; routing chooses where a particular request goes. A cached discovery result can outlive an endpoint, and a registered endpoint can fail after selection. Define membership refresh, connection retirement and what clients do when discovery itself is unavailable. A registry is not a promise that every listed server can complete the real operation.
The 80 ms difference belongs to this chosen path, not every new connection. Resuming TLS can change handshake work and authentication state; it is not synonymous with sending application data at zero round trips. Optional early data has weaker replay protection, which TLS 1.3, Section 8 treats explicitly. Retrying a side effect still needs an application-level operation contract.
HTTP/2 gives separate streams on a connection so messages can be interleaved rather than requiring each response to finish before another is carried. It does not remove TCP's ordered-byte delivery. If a segment is lost, later bytes on that connection can wait for recovery even when their frames belong to another stream. Application response ordering and transport head-of-line blocking are different boundaries.
Multiplexing also does not remove connection or stream flow control, peer limits, server queues or application dependencies. A slow required inventory read remains on the page's critical path. More connections might isolate some transport contention while adding startup, resource and operational costs. Choose from measured work and failure behavior rather than treating a protocol name as a latency guarantee.
Hypothetical scenario. An application widens its connection pool to reduce caller waiting. Requests immediately reach a database that was already resource constrained. The queue moves from the application into the database, where more in-flight operations hold memory and increase latency. Callers time out and retry, adding more work.
Layer 3 · Internals
Trade-offs and limits
| Approach | Provides | Requires |
|---|---|---|
| Sequential dependency calls | Preserves operations that genuinely depend on earlier results. | Elapsed waiting adds along the path. |
| Independent parallel requests | Can reduce the critical path to the slowest required branch. | Adds simultaneous load and requires a partial-failure policy. |
Recovery decision
Hypothetical scenario: An upstream timeout releases a socket while expensive downstream work continues. Repeated retries create orphan work; propagate deadlines and bound attempt counts.
No. Percentiles do not compose by simple addition, distributions may be correlated, and connection/queue overhead remains. Use joint traces or a justified probabilistic model and enforce the actual remaining deadline.
Write your design before revealing the review
A dependency has p99 of 100 ms. Are two serial calls guaranteed to fit 200 ms?
Drafts and self-review are stored only in this browser. They are separate from reading completion.
Compare your decision
No. Percentiles do not compose by simple addition, distributions may be correlated, and connection/queue overhead remains. Use joint traces or a justified probabilistic model and enforce the actual remaining deadline.
An upstream timeout releases a socket while expensive downstream work continues. Repeated retries create orphan work; propagate deadlines and bound attempt counts.
Check your understanding
A dependency has p99 of 100 ms. Are two serial calls guaranteed to fit 200 ms?
No. Percentiles do not compose by simple addition, distributions may be correlated, and connection/queue overhead remains. Use joint traces or a justified probabilistic model and enforce the actual remaining deadline.
How would you recover from this failure: An upstream timeout releases a socket while expensive downstream work continues. Repeated retries create orphan work; propagate deadlines and bound attempt counts.
Start with the exact boundary that failed. Create a deadline at entry and carry the remaining budget. Reject work that cannot finish usefully rather than letting queues grow. Cancel downstream work where the interface actually supports cancellation. Then recover evidence through the observation path: Separate network setup from reused-connection requests. Trace queue residence and service time independently. Report timeout outcomes separately from slow successful responses. Preserve the distinction between a confirmed state change and an unavailable response.
Which assumption in the worked calculation would a burst or concentrated tenant invalidate first?
Hypothetical deadline: 300 ms. Reserve 40 ms for network/response and 30 ms safety margin, leaving 230 ms. If admission consumed 50 ms, only 180 ms remains for service and dependencies. Two serial 100 ms calls cannot fit; concurrency helps only if those calls are independent and their combined resource demand is affordable. Recompute the affected resource rather than multiplying unrelated storage and network budgets by the same factor. Allocate one user-visible deadline across DNS/connection setup, queueing, service work and dependencies. Distinguish a measured percentile from a deadline: neither average latency nor adding independent p99 values predicts the end-to-end p99.
Which component in this topology could be removed from a smaller first deployment?
Browser, Edge connection, API deadline, Database call name responsibilities, not a requirement for separate processes. Co-locate responsibilities when their transaction, trust and capacity boundaries permit it. Create a deadline at entry and carry the remaining budget.
What evidence must a caller have before relying on the observation path?
Separate network setup from reused-connection requests. Trace queue residence and service time independently. Report timeout outcomes separately from slow successful responses. No. Percentiles do not compose by simple addition, distributions may be correlated, and connection/queue overhead remains. Use joint traces or a justified probabilistic model and enforce the actual remaining deadline.
45-minute interview rubric
- 00–05: scope network exchange and request deadline.
- 05–12: identify the limiting resource and derive the domain workload above, retaining units and assumptions.
- 12–28: draw request deadline, numbered writes and reads.
- 28–40: challenge recovery: Reuse connections and propagate the remaining deadline.
- 40–45: defend request_id placement, observations and remaining assumptions.
Go deeper
- RFC 9113: HTTP/2 · Primary document · www.rfc-editor.org. Reuse connections and propagate the remaining deadline. Verified 2026-10-26.
- RFC 8446: The Transport Layer Security (TLS) Protocol Version 1.3 · Primary document · www.rfc-editor.org. Reuse connections and propagate the remaining deadline. Verified 2026-10-26.
- RFC 9000: QUIC: A UDP-Based Multiplexed and Secure Transport · Primary document · www.rfc-editor.org. Reuse connections and propagate the remaining deadline. Verified 2026-10-26.
Decision log
Reuse connections and propagate the remaining deadline.
Preserve network exchange identity and request deadline ownership.
Revisit changed workload, observations or recovery objectives.