TRT
Sign in

An API Request's Journey

Follow an HTTPS request from browser to service and watch its response return through the same system.

The Runtime Theory Team08 stages

trace / request.md

CLIENTDNSTRANSPORTTLSHTTPEDGE OR PROXYAPPLICATIONRESPONSE

readyThe browser parses the URL, applies its policies, and prepares the HTTP request. A cache or reusable connection can change the later steps.

Use this flow as a map, not as a fixed packet-by-packet script. The pictured route is a fresh HTTPS request with an edge component. A cached response may finish at the client or edge, a warm connection can skip setup, and a small deployment may connect directly to its application server. For a deeper walk, read the HTTPS request trace.

Stage-by-stage execution walkthrough

This request flow decomposes An API Request's Journey into 8 sequential stages so you can trace where latency accumulates, which state transitions are irreversible, and where production failure modes occur.

Stage 1: Client

The browser parses the URL, applies its policies, and prepares the HTTP request. A cache or reusable connection can change the later steps. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Stage 2: DNS

If no usable address is cached, the client asks a resolver to find an IP address for the hostname. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Stage 3: Transport

A common path opens TCP. HTTP/3 instead uses QUIC over UDP, so this stage has a different setup. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Stage 4: TLS

For HTTPS, the client establishes security with the service endpoint and verifies its identity. An edge proxy may terminate this connection. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Stage 5: HTTP

The client sends a method, target, headers, and optional body. HTTP defines the request and response semantics. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Stage 6: Edge or proxy

A CDN, firewall, or load balancer may answer, reject, or route the request. A deployment may have none of these. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Stage 7: Application

Server code authenticates, validates, and handles the operation, possibly calling a database or another service. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Stage 8: Response

The server returns a status, headers, and optional body. The client processes it and may reuse the connection. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Production invariants and failure modes

The response is available to the client. A streamed body can continue arriving after the response headers are received. When debugging or capacity-planning this flow in production, instrument each stage boundary separately (measuring both p50 median and p99.9 tail latency), verify what happens when an intermediate stage times out or drops packets, and ensure retry or fallback paths preserve end-to-end idempotency.

Not started

Sign in to save your learning progress.

Sign in to save