Learning pathsPricingChecking sign-in…
GUIDED PRACTICE

Networking Essentials

Trace what changes between a cold HTTPS request, a reused connection, and a regional path.

What, why, when and how

What is it?

Networking connects clients and services through naming, transport, encryption and request routing. DNS, TCP or QUIC, TLS, HTTP and load balancers each solve a different part of that path.

Why is it needed?

A working application still fails if connections cannot be established, requests exceed their deadlines, or retries overload a dependency. Understanding the path helps locate that failure.

When should I use it?

Use this reasoning whenever an API crosses a network boundary, especially for multi-region traffic, persistent connections and latency-sensitive requests.

When should I choose something else?

Do not add a proxy, CDN or persistent socket without a requirement it serves. A simple regional HTTP API is often a sufficient baseline.

How do I use it?

Trace name resolution, connection setup, TLS, routing and application work separately. Assign one end-to-end deadline, reuse connections where appropriate, and bound retries within the remaining budget.

Can you show a concrete example?

If DNS takes 20 ms, setup is budgeted at 160 ms, request transit at 80 ms and origin work at 50 ms, the illustrative cold request costs 310 ms. A reused connection can remove setup work; these are assumptions to measure, not universal timings.

Cold connection: DNS 20 ms + setup 160 ms; Transit 80 ms + origin work 50 ms; Illustrative total: 310 ms; reuse saves setup
Networking Essentials: one concrete example
Read the diagram

Cold connection: DNS 20 ms + setup 160 ms; Transit 80 ms + origin work 50 ms; Illustrative total: 310 ms; reuse saves setup

Open original
Networking Essentials: worked example
Cold connection: DNS 20 ms + setup 160 ms; Transit 80 ms + origin work 50 ms; Illustrative total: 310 ms; reuse saves setup

Networking Essentials: one concrete example

Follow the detailed diagrams below to trace the additional state changes and failure cases behind these answers.

Before a request reaches your application, several separate conversations may occur. DNS discovers an address; a transport carries bytes; TLS protects the connection; HTTP gives the exchange application meaning. The path changes when a browser reuses a connection, a user crosses a region, or a route changes. Explain where a request waits, which network layer owns a failure, and which component can prove that a business operation committed.

Learning goals

DNS lookup versus request routing; IP; TCP and QUIC; TLS; HTTP connection reuse; timeouts; proxies; L4/L7 balancing; CDN cache behavior; SSE versus WebSocket.

Trace bytes and names as different paths

A name lookup obtains an address; application traffic then goes to that address. With a cached answer there may be no new DNS query. DNS is not a reverse proxy through which every HTTP request travels. The link layer carries frames locally, IP routes packets, transport supplies a TCP byte stream or UDP datagrams, and application protocols define operations. TLS protects the connection's bytes and peer identity; object authorization remains application work.

For this exercise only, use DNS=20 ms, regional RTT=80 ms and origin work=50 ms. A cold TCP/TLS setup budget of two RTTs is 160 ms; request/response transit adds 80 ms. The simple total is 310 ms. A reused connection removes this setup allowance, leaving roughly 130 ms before other queueing. These assumptions are not Internet constants. HTTP/2 multiplexes streams over TCP, so packet loss can delay progress on the shared transport. HTTP/3 uses QUIC over UDP; its stream transport and integrated handshake change these boundaries, but cannot remove geography or application work.

NeedCandidateRemaining work
Bounded ordinary requestHTTP request/responseAuth, timeout and safe retry
Browser receives changesSSEEvent IDs, resume and slow-client limits
Two-way interactive messagesWebSocketApplication ordering, heartbeat and reconnect
Real-time mediaWebRTCSignaling, ICE candidates and possible TURN relay
DNS assumption: 20 ms; name lookup, not HTTP route; TCP/TLS setup allowance: 2 x 80 ms = 160 ms; Request/response transit: 80 ms; origin work: 50 ms; Cold total: 310 ms; reused estimate: 130 ms; 600 ms deadline: dependencies spend remaining budget
Trace bytes and names as different paths
Read the diagram

DNS assumption: 20 ms; name lookup, not HTTP route; TCP/TLS setup allowance: 2 x 80 ms = 160 ms; Request/response transit: 80 ms; origin work: 50 ms; Cold total: 310 ms; reused estimate: 130 ms; 600 ms deadline: dependencies spend remaining budget

Open original
Trace bytes and names as different paths
DNS assumption: 20 ms; name lookup, not HTTP route; TCP/TLS setup allowance: 2 x 80 ms = 160 ms; Request/response transit: 80 ms; origin work: 50 ms; Cold total: 310 ms; reused estimate: 130 ms; 600 ms deadline: dependencies spend remaining budget

Trace bytes and names as different paths

WebRTC signaling exchanges session descriptions and candidates through a separate service. STUN helps discover reachable addresses; TURN relays media when a direct candidate path cannot work. A successful signaling response proves neither media connectivity nor adequate bandwidth. UDP itself supplies no retransmission or ordered byte stream; protocols above it can add reliability where appropriate. Choose based on the application's loss and latency behavior rather than declaring UDP universally unreliable or universally faster.

Spend a deadline once

A caller has a 600 ms deadline. After 100 ms of edge and application work, only 500 ms remains. Allocate, for example, 200 ms to lookup, 200 ms to the next dependency and 100 ms to response/reserve; pass the remaining budget downstream. Two fresh two-second timeouts cannot fit. A retry spends this same budget and adds bounded jitter; if the first write may have committed, reuse its operation identity and resolve its status.

A circuit breaker stops sending more work to a dependency after a declared failure threshold, then permits bounded probes. It is not a durable work queue and not a substitute for timeouts. Report whether the response is a permitted stale result, a degraded result or a failure. Client-side balancing obtains endpoints and chooses locally; a dedicated L4/L7 tier centralizes routing but adds a dependency. Drain connections during deploy and explicitly reconnect long-lived streams. Health checks, discovery and routing updates all have delays.

Show answer and explanation

Answer: If a regional path loses packets after a reservation request, TCP acknowledgement does not establish whether the seat transaction committed. Query the operation result under the same identity. Moving to QUIC does not fix that business ambiguity.

The mechanism at a glance

Three numbered stages show an assumed cold path: cached-or-recursive DNS resolution, TCP plus TLS setup (or QUIC setup), then edge/origin work and response. A second lower path shows a reused HTTP connection skipping DNS and handshake while still paying routing and application time. The stated 20 ms, 160 ms, and 130 ms add to an illustrative 310 ms; all are assumptions.
An illustrative cold request pays for name resolution and connection setup; a reused connection skips those steps, while origin work and regional RTT remain.
Read the diagram

Three numbered cold-path stages show assumed DNS, TCP/TLS or QUIC setup, and edge/origin work. The sum is about 310 ms under the stated assumptions. A second path reuses an HTTP connection and skips DNS and handshake but still pays routing and application time. The note names the simplified HTTP, TLS, transport, IP, and link stack, and explains that regional RTT and replication trade-offs remain.

Open original
First request vs reused connection
Three numbered stages show an assumed cold path: cached-or-recursive DNS resolution, TCP plus TLS setup (or QUIC setup), then edge/origin work and response. A second lower path shows a reused HTTP connection skipping DNS and handshake while still paying routing and application time. The stated 20 ms, 160 ms, and 130 ms add to an illustrative 310 ms; all are assumptions.

An illustrative cold request pays for name resolution and connection setup; a reused connection skips those steps, while origin work and regional RTT remain.

Read the labeled arrows and state boundaries. Independent paths are not one global execution sequence; the scenario later in this lesson follows one concrete sequence.

Step-by-step reasoning

1. Resolve a name

A browser usually consults cached DNS information or a recursive resolver to obtain an address. The resolver may consult authoritative DNS servers if needed. After resolution, ordinary application requests go to the resolved destination, not through the authoritative DNS server. DNS TTL affects how long an answer may be reused; it is not a precise traffic-switch timer for every client.

2. Establish a protected transport

HTTP/1.1 and HTTP/2 commonly run over TCP with TLS for HTTPS. HTTP/3 uses QUIC over UDP and integrates TLS. Connection setup and geographic round trips can dominate a small response, so reuse matters. TCP supplies an ordered byte stream; it does not tell your application that a purchase committed. TLS protects data in transit but does not replace authorization. For illustration, assume an 80 ms regional round trip: a cold DNS lookup might add about 20 ms, while TCP plus a full TLS 1.3 handshake can add roughly two round trips before request data. QUIC can combine transport and TLS setup; resumption and preconnect may reduce setup. These are scenario assumptions, not fixed protocol timings. A nearer region or edge can reduce path RTT, but cross-region reads, writes, and failover add consistency and replication trade-offs. Route users by product needs and measured latency; DNS-based steering is constrained by cached answers and client behavior.

3. Route at the correct layer

A layer-four balancer routes connections using transport information. A layer-seven proxy understands HTTP attributes such as host and path and can send /images and /api to different origins. A CDN can answer eligible cache hits at the edge. Private, user-specific responses require careful cache keys and policies; a fast shared cache is harmful if it leaks another user’s data. Round robin is simple when instances have similar capacity and request cost; least-outstanding-work can help with uneven durations but needs fresh counts; consistent hashing can preserve cache locality but can skew under hot keys. Health checks need thresholds and enough hysteresis to avoid flapping. During a deploy, stop assigning new work, let eligible in-flight connections drain until a deadline, then close them; long-lived streams need a reconnect and cursor policy.

4. Choose a real-time transport

For browser updates, polling, SSE, and WebSockets have different directionality and reconnect costs. WebRTC uses a separate signaling channel to exchange session descriptions and ICE candidates; signaling does not carry the media itself. ICE tries candidate paths, STUN helps discover a reachable address, and TURN relays media when a direct path cannot be established. Real-time media uses its own encrypted transport and congestion behavior. Do not treat a successful signaling request as proof that media can flow.

5. Budget timeouts and retries

Give the full request a deadline and allocate smaller budgets to dependencies. Otherwise three independent two-second waits may exceed the user’s total budget. Retry only when the operation contract permits it, with a bounded count, jitter, and a stable idempotency identity for writes. Transport acknowledgments and successful HTTP delivery still do not prove that a business operation committed; use an operation result or status lookup to resolve ambiguity.

Contracts and state

The following sketch makes the decision boundary concrete. Field names and capacity assumptions are illustrative; adapt them to the stated product contract.

Contract / pseudocode
Simplified request stack (boundaries vary by protocol)
Application: HTTP request / response
Security: TLS protects bytes in transit
Transport: TCP ordered stream or QUIC streams over UDP
Network: IP routes packets across networks
Link / physical: Wi-Fi, Ethernet, radio, fiber
Name lookup: DNS resolves a name before a new destination is used; caches may avoid another lookup.

Illustrative cold request (assumptions):
DNS 20 ms + TCP/TLS setup 160 ms + edge/origin work and return 130 ms = about 310 ms
Reused connection: setup may be skipped; routing and application work still remain.
Regional RTT and every timing here are illustrative, not Internet constants.

Worked example

A dashboard shell loads quickly from a CDN but its API calls take two seconds. DNS is cached and the browser reuses its connection. The slow segment is an origin database query; adding DNS servers will not help. Instrument client-to-edge, edge-to-origin, application, and database time separately, including p50 and p99. If users are far from the origin, compare a closer read region or cache against replication lag and write ownership. An 80 ms regional RTT repeated across serial calls can dominate a short computation.

Failure walkthrough

Suppose POST /orders reaches the origin, commits an order, and loses the response on the return path. The client sees a timeout, but the system has an order. A network timeout means the caller lacks a result, not that the operation failed. A retry with the same idempotency identity or a status lookup resolves this uncertainty without blindly creating another order. DNS cache expiry also does not force every client to switch regions at once; existing connections may continue to the old endpoint.

Five numbered states: client sends POST /orders; origin commits the order; the response is lost on the return path; the client deadline expires with an unknown outcome; same-key retry or status lookup finds the committed order.
The origin commits an order but the response is lost; a timeout leaves the caller uncertain until an idempotent retry or status lookup resolves it.
Read the diagram

The client sends an order request with a stable idempotency key. The origin commits the order, but the return packet is lost. The deadline expires, leaving the client uncertain. A same-key retry or status lookup finds the committed order instead of creating a duplicate.

Open original
Timeout: find the business result, not the packet
Five numbered states: client sends POST /orders; origin commits the order; the response is lost on the return path; the client deadline expires with an unknown outcome; same-key retry or status lookup finds the committed order.

The origin commits an order but the response is lost; a timeout leaves the caller uncertain until an idempotent retry or status lookup resolves it.

Decisions and trade-offs

ChoiceGood fitCost or limitation
PollingInfrequent state changesRepeated requests; freshness bounded by interval
SSEServer-to-browser updatesOne-way stream; reconnect requires a cursor
WebSocketBidirectional interactionConnection lifecycle, backpressure, slow-client management
WebRTCLow-latency peer media or dataSignaling is separate; ICE/TURN, NAT and congestion behavior
Round robinSimilar instances and request costsDoes not account for slow or overloaded instances
Least outstanding workUneven request durationCounts can be stale; long-lived requests skew
Consistent hashingCache locality or stable shard selectionHot keys and membership changes can skew load
Regional routingUsers benefit from a closer serving regionReplication lag, write ownership, DNS cache and failover behavior

Check your understanding

Trace a first request and a later request to the same HTTPS API. Which setup work can be reused? Then explain where an 80 ms regional RTT matters, how a load balancer drains a connection, and why a WebRTC signaling success does not prove media delivery.

Show answer and explanation

Answer: DNS answers and established connections may be reused when cache validity, connection health, and server policy allow it. A cold request can pay DNS and transport/TLS setup; a reused connection can skip those waits, but still pays for routing, origin work, and response transfer. The 80 ms RTT is an exercise assumption: repeated serial regional calls can dominate latency, while moving reads nearer the user introduces freshness and ownership trade-offs. A balancer marks a target unavailable, stops assigning new requests, and drains eligible in-flight connections to a bounded deadline. WebRTC signaling exchanges session descriptions and ICE candidates; ICE selects a path, and TURN may relay media. Signaling and media are distinct, so the application must observe media connectivity separately.

Interviewer follow-ups

  • Which request steps happen on a cold connection, and which may be reused? State how DNS TTL, connection pooling, and HTTP version affect the answer.
  • A service moves from one region to another. Which users may still reach the old region, and which operations cannot safely fail over without checking state ownership?
  • Choose round robin, least outstanding, or consistent hashing for a mixed workload. What observation would make you change the algorithm?
  • A target fails its health check during a deploy. When do you stop new traffic, how long do existing connections drain, and how do streams resume?
  • A browser receives a successful WebRTC signaling response but no media. What separate ICE, STUN, TURN, firewall, and media checks do you inspect?
  • The server commits an order but the response times out. What evidence distinguishes an unknown result from a failed operation?

For each answer, state the requirement, the state owner, the failure boundary and the remaining trade-off.

Transfer to a new scenario

Trace a browser opening a dashboard and then calling its API; identify the separate DNS and application exchanges.

Does every request travel through the authoritative DNS server?

Primary documentation

Continue the connection

Study API Design and explain which guarantee from this lesson carries into that topic.

Follow one browser request

Typing a URL starts several distinct operations. DNS resolves the hostname to a destination; it is not normally a proxy that forwards the HTTP request. Cached DNS answers may avoid a resolver round trip. The browser then establishes or reuses a transport connection, negotiates security as needed, and sends an HTTP request. A CDN edge may answer from cache or forward to an origin. Each of these boundaries can fail independently.

For an API hostname, DNS may direct traffic to a gateway or load balancer. For a website hostname, it may direct traffic to a CDN. The hostname alone does not determine the architecture; the DNS records and serving configuration do. WAF rules inspect supported application traffic at the configured boundary, while network DDoS protection addresses a different layer of attack.

Choose protocols by the contract

ChoiceUseful propertyCost or limitation
TCPReliable ordered byte streamLoss can delay later bytes on the connection
UDPDatagrams with minimal transport machineryApplication or higher protocol must supply needed reliability
HTTP/2Multiplexed HTTP streams over TCPTCP loss can affect progress across streams
HTTP/3HTTP over QUIC, with separate transport streamsDeployment and network support still need consideration
REST-style HTTPFamiliar resource operations and toolingChatty endpoints may require multiple round trips
GraphQLCaller selects a response shapeResolver cost, authorization and query limits need control
gRPCTyped RPC contracts and streamingBrowser access and intermediary support may require adaptation
SSEServer-to-client event streamClient writes use another request path
WebSocketBidirectional persistent messagesReconnect, replay, backpressure and session ownership remain application work

Do not describe WebSocket as durable delivery. A connection can disappear after the server sends bytes and before the client records them. Message IDs, acknowledgements, retained history and resume cursors address that uncertainty. Polling can be the right choice when updates are infrequent and operational simplicity matters.

WebRTC signaling and media

A signaling service exchanges session descriptions and ICE candidates, often over HTTPS or a WebSocket. ICE tests candidate paths; STUN helps discover a reachable address, while TURN relays encrypted media if direct connectivity fails. Once connected, WebRTC media uses its own real-time transport and congestion behavior. The signaling service arranges the call; it does not carry the ongoing media stream.

Six states separate offer/answer signaling, ICE path checks, direct media, and TURN relay fallback.
WebRTC: signaling is not the media path
Read the diagram

Peer A creates an offer and ICE candidates. A signaling server relays setup data to Peer B, which returns an answer. ICE tests candidate pairs; STUN helps discover reachable addresses. If a direct path works, encrypted SRTP media flows between peers. If direct connectivity fails, TURN relays the media. Signaling success does not prove that media is connected.

Open original
WebRTC: signaling is not the media path
Six states separate offer/answer signaling, ICE path checks, direct media, and TURN relay fallback.

WebRTC: signaling is not the media path

Latency budgets and deadlines

Suppose a fictional request has a 300 ms deadline. Spend 30 ms on edge and routing, 40 ms on application work, 150 ms on dependencies, and reserve 80 ms for network variation and response work. These are a budget, not measured universal timings. If the first dependency consumes 140 ms, the second must not start with a fresh 300 ms timeout.

Propagate an absolute deadline or remaining budget. Bound connection acquisition as well as socket reads. A request can wait in a pool without ever reaching the remote service. Cancel work when the caller no longer needs it, while recognizing that cancellation does not undo an already committed side effect.

Retry without creating a storm

Retry transient failures only within an overall deadline and attempt budget. Add jitter so many clients do not retry at the same instant. If three layers each retry three times, one original request can produce 27 downstream attempts. Assign retry ownership deliberately and expose attempt counts in tracing.

A timeout does not tell you whether the remote operation committed. Reads are usually easier to retry; mutating requests need a stable operation key or a way to query the outcome. A circuit breaker can stop repeated calls to an unhealthy dependency, but it needs a recovery probe and should not become a permanent failure state.

Load balancers and connection state

A layer-4 balancer routes transport connections; a layer-7 proxy can route using HTTP properties after the appropriate termination point. Long-lived connections can distribute unevenly because one connection may carry much more work than another. Monitor active work and bytes, not only connection counts.

Connection draining lets existing work finish while a node leaves service. Idle timeouts must align across browser, proxy and application or apparently healthy streams will disconnect repeatedly. Keep application state recoverable outside the connection-owning process so a gateway replacement does not lose durable messages.

A concrete failure exercise

A client times out after submitting an order through a gateway. The database shows the order, but the client received no response. Should the client create a new order?

Show answer and explanation

Answer: Retry or query with the original operation identity. The gateway timeout may have occurred after the commit. Creating a new identity can create a second order. Trace the request ID, deadline, commit point and response path to establish which guarantee failed.

Protocol references

HTTP semantics, RFC 9110 and QUIC transport, RFC 9000 define the underlying protocol behavior. The latency budgets above are teaching assumptions.

22:00Self-guided practice timer
The timer resets when you leave this page. Save your design separately.
Your challenge

Trace a first request and a later request to the same HTTPS API. Which setup work can be reused? Then explain where an 80 ms regional RTT matters, how a load balancer drains a connection, and why a WebRTC signaling success does not prove media delivery.

Your design draft

Clarify assumptions, explain your approach, and test the difficult cases. Save your draft, then compare it with the study notes.

Read study notes

Self-review checklist

Self-guided practice. Automated AI feedback and code execution are not connected.