Envoy internals

  • Main and worker ownership, connections and streams, filter processing, upstream pools, responses and TCP alternatives.
100%
Envoy internal architecture Envoy internal architecture Generic TCP / HTTP/1.1–HTTP/2 path · process → workers → connections → streams ENVOY PROCESS MAIN THREAD · configuration / lifecycle / administration Config BootstrapxDS Configuration Subscriptions / validationPublish worker updates Listener manager Listener configurationInstall / drain listeners Cluster manager Cluster + endpoint updatesHealth / discovery coordination Admin + stats flushing Admin interface / server lifecycleTelemetry export; not a request hop Configuration updates → workers WORKER 1 · event loop / dispatcher · non-blocking I/O LISTENER SUBSYSTEM · downstream connection Client DownstreamTCP Listener Socket / accept Listener filters e.g. TLS inspectorSNI / ALPN Chain match SNI / ALPN / IPSelect ONE chain SELECTED FILTER CHAIN / CONNECTION Transport TLS / raw socketDecrypt / encrypt NETWORK FILTERS → HCM HTTP connection manager HTTP/1.1 or HTTP/2 codec HTTP stream · per request HTTP filters router decode → ← encode Route table VirtualHost→ ordered routesInline or RDS CLUSTER SUBSYSTEM · upstream Thread-local cluster view Named cluster → host set / health stateLoad balancer → select upstream host Connection pools Per worker / hostProtocol / priorityResource admission Upstream connection HTTP codecTLS / raw transportTCP socket Host IP : portUpstreamendpoint Worker-local pools ≠ per-worker breaker budgets One established TCP connection + its HTTP streams → one worker for the connection lifetime WORKERS 2 … N | own event loops · listener instances · connections · HTTP streams · upstream pools ALTERNATIVE WORKER PATH · TCP proxy · no HCM / HTTP route table Downstream transport Network filters → tcp_proxy Cluster / host / TCP pool Upstream TCP connection Host HTTP/3 / QUIC / UDP paths not drawn. Additional HTTP streams repeat the per-stream filter chain, not the worker thread.

Select a component to trace its direct connections. Drag to pan · Ctrl + wheel or pinch to zoom.

  • A downstream connection is the client connection into Envoy. One worker owns it for its lifetime. On HTTP/2, several request streams on that connection can be active on the same worker.
  • For each stream, the HTTP connection manager applies filters and selects a route. The router sends the request through an upstream connection pool. A filter can also answer the client locally.
Process, workers and connection lifetime

Process, workers and connection lifetime

  • The main thread coordinates configuration, lifecycle, administration and stats flushing. Workers own traffic-processing event loops.
  • One established downstream TCP connection and its multiplexed HTTP streams stay on one worker for the connection lifetime.
  • Worker count is neither an admitted-request allowance nor a thread-per-request model. Auxiliary threads and optional extensions are omitted from this generic source view.
Listener and selected filter chain

Listener and selected filter chain

  • TCP accept is followed by listener filters and selection of one filter chain. TLS inspector extracts matching information and does not terminate TLS.
  • The selected transport socket supplies plaintext or decrypted bytes to the network filters. HCM is a network filter inside that connection path, not a separate service.
  • UDP, QUIC and HTTP/3 need different transport paths; this TCP/HTTP source diagram does not route them through TCP accept.
HTTP codec and per-stream filters

HTTP codec and per-stream filters

  • The HCM codec interprets HTTP/1.1 or HTTP/2 and creates streams. Each request stream has its own HTTP filter chain.
  • Decoder filters lead to the router; the router joins downstream HTTP processing to the upstream cluster subsystem.
  • The route table is a configuration side input, delivered inline or through RDS. Route lookup is not another network hop.
Cluster view, host selection and pools

Cluster view, host selection and pools

  • The worker uses its thread-local cluster view, chooses a host and acquires capacity from the appropriate connection pool.
  • Connection pools are worker-local and further partitioned by host, protocol and priority. Cluster resource limits are not independent per-worker budgets.
  • The upstream HTTP codec and transport socket are separate from their downstream counterparts.
Response encoding and local replies

Response encoding and local replies

  • HTTP responses pass through encoder processing in the reverse direction. A stopped request decoder path can still produce an encoded local response.
  • Upstream allocation failure and filter-generated local replies have different causes and resource accounting.
  • Admin/export is ancillary; stats updates and access-log generation still occur during request or lifecycle processing. Telemetry has processing cost.
Raw TCP alternative

Raw TCP alternative

  • A selected tcp_proxy network-filter path bypasses HCM and HTTP route/filter processing.
  • It still selects a cluster/host and obtains TCP upstream capacity. Opaque application HTTPS does not become visible HTTP merely by forwarding it.