Concept

Request-Response Pattern

Definition

The request-response pattern is a communication style in which a client sends a discrete request to a server and then waits for a paired response before continuing. Every request has at most one response, the two are correlated by an identifier or by the underlying transport, and the client is generally blocked or at least logically suspended until the response arrives. HTTP is the canonical example, but the same pattern shows up in RPC, database queries, and most REST and GraphQL APIs.

The pattern contrasts with two other major styles. Publish-subscribe decouples producers from consumers: a producer emits events without knowing who will read them, and any number of subscribers can react. Streaming maintains a long-lived bidirectional channel over which messages flow in both directions independently of any one-to-one request pairing. Request-response is the simplest of the three to reason about, which is why it dominates synchronous web APIs and most internal microservice calls.

Why it matters

How it works

A request-response exchange has three observable parts: the client constructs a payload describing what it wants, sends it over a transport that preserves ordering, and waits on a logical handle that will resolve when the matching response arrives. The server parses the request, runs whatever computation the payload implies, formats a response, and sends it back over the same connection — or, for HTTP/1.1, over a connection from a pool sized to the expected concurrency.

The interesting engineering happens around the edges. Timeouts bound how long the client will wait before treating the request as failed. Idempotency keys let the client retry safely without risking double-application of side effects. Backoff and jitter spread retry storms across time so a flapping server is not pummelled into staying down. And the choice of synchronous versus asynchronous APIs at the language level — promises, futures, async/await — determines whether the calling thread is genuinely blocked or merely logically suspended while the network does its work.

Where it goes next

Continue exploring

Tags