You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/architecture/engines.md
+22-26Lines changed: 22 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Protocol Engines
2
2
3
-
The `Engine` demultiplexes requests by HTTP version and routes each request to the appropriate per-version engine. Each engine is a self-contained Akka.Streams sub-graph composed of a **unified ConnectionStage** (which handles encoding, decoding, and request/response correlation internally) and a **NetworkBufferBatchStage** (which coalesces outbound items into fewer, larger writes). The engine's output connects to a transport stage (`TcpConnectionStage` or `QuicConnectionStage`) that manages the actual network connection.
3
+
The `Engine` demultiplexes requests by HTTP version and routes each request to the appropriate per-version engine. Each engine is a self-contained Akka.Streams sub-graph composed of a **unified ConnectionStage** (which handles encoding, decoding, and request/response correlation internally). The engine's output connects to a transport stage (`TcpConnectionStage` or `QuicConnectionStage` from Servus.Akka) that manages the actual network connection.
4
4
5
5
---
6
6
@@ -15,15 +15,14 @@ HTTP/1.0 uses a **close-then-respond** model. Each connection handles exactly on
|`NetworkBufferBatchStage`| Coalesces consecutive outbound network buffers into fewer, larger writes — correctly handles interleaved control items (connection reuse signals) by flushing the buffer before forwarding them |
55
-
|`TcpConnectionStage`| TCP transport with connection reuse — returns leases to the pool on keep-alive, requests new connections on close |
|`TcpConnectionStage`| TCP transport with connection reuse (from Servus.Akka) — returns leases to the pool on keep-alive, requests new connections on close |
56
54
57
55
**Keep-alive handling:**
58
56
59
57
After decoding each response, `Http11ConnectionStage` evaluates the `Connection` header internally:
60
58
61
-
-`Connection: keep-alive` (or HTTP/1.1 default) → the connection lease is returned to `ConnectionPool` for reuse
59
+
-`Connection: keep-alive` (or HTTP/1.1 default) → the connection lease is returned to the connection manager actor for reuse
62
60
-`Connection: close` → the lease is released without returning it to the idle queue; the next request triggers a new connection
63
61
64
62
**Pipelining:**
@@ -78,15 +76,14 @@ HTTP/2 provides **stream multiplexing** — many logical requests share a single
|`Http20ConnectionStage`| Central unified stage: allocates client stream IDs (1, 3, 5, …), HPACK-encodes request headers and emits `HEADERS` + `DATA` frames, handles frame encoding/decoding (9-byte frame header + payload), manages connection-level frames (`SETTINGS`, `PING`, `WINDOW_UPDATE`, `GOAWAY`), tracks connection and stream-level flow control windows, assembles per-stream `HEADERS` + `DATA` frames into `HttpResponseMessage`, and correlates responses by stream ID |
88
-
|`NetworkBufferBatchStage`| Coalesces consecutive outbound frame buffers into fewer, larger writes — reducing syscall count under concurrent multiplexed streams; control items are flushed through immediately to preserve frame ordering |
89
-
|`TcpConnectionStage`| TCP transport — emits the HTTP/2 connection preface on first connect |
Copy file name to clipboardExpand all lines: docs/architecture/pipeline.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,11 @@ Each `HttpRequestMessage` passes through the following stages before reaching th
21
21
| 5 | Cookie Injection (`CookieBidiStage`) | Looks up matching cookies for the target domain and path and adds a `Cookie` header |
22
22
| 6 | Retry (`RetryBidiStage`) | On the request side, attaches retry context; on a transient failure, re-enters below the Cookie stage (same URL, cookies already set) |
23
23
| 7 | Expect-Continue (`ExpectContinueBidiStage`) | For requests with large bodies, sends `Expect: 100-continue` and holds the body until the server confirms it will accept it |
24
-
| 8 | Cache Lookup (`CacheBidiStage`) | Checks the in-memory cache; on a **cache hit**, returns the cached response immediately — stages 9–12 are skipped entirely |
24
+
| 8 | Cache Lookup (`CacheBidiStage`) | Checks the in-memory cache; on a **cache hit**, returns the cached response immediately — stages 9–11 are skipped entirely |
25
25
| 9 | Content Encoding (`ContentEncodingBidiStage`) | Compresses the request body if a compression policy is configured; on the response side, transparently decompresses `gzip`, `deflate`, or Brotli |
26
26
| 10 | Alt-Svc Discovery (`AltSvcBidiStage`) | Checks for cached Alt-Svc entries and upgrades the request version if a faster protocol is available; captures Alt-Svc headers from responses |
27
27
| 11 | Version Router (`Engine`) | Routes the request to the correct protocol handler based on the requested HTTP version |
28
-
| 12 | Protocol ConnectionStage _(per version)_| Unified stage that serialises the request to bytes, parses the response, and correlates request/response — then `NetworkBufferBatchStage` batches the outbound writes and `TcpConnectionStage`/`QuicConnectionStage` handles the network connection |
28
+
| 12 | Protocol ConnectionStage _(per version)_| Unified stage that serialises the request to bytes, parses the response, and correlates request/response — then `TcpConnectionStage`/`QuicConnectionStage`(from Servus.Akka) handles the network connection|
29
29
30
30
---
31
31
@@ -59,7 +59,7 @@ If the cache entry is stale but has an `ETag` or `Last-Modified` validator, `Cac
59
59
60
60
### 2. Keep-Alive Feedback (HTTP/1.1 only)
61
61
62
-
After each HTTP/1.1 response, `Http11ConnectionStage` evaluates the `Connection` header internally and decides whether to reuse the TCP connection for the next request or close it and request a new one from the pool.
62
+
After each HTTP/1.1 response, `Http11ConnectionStage` evaluates the `Connection` header internally and decides whether to reuse the TCP connection for the next request or close it and request a new one from the connection manager actor.
63
63
64
64
This loop is invisible to the caller — the `Engine` and higher layers see only a continuous stream of `HttpResponseMessage` objects.
65
65
@@ -79,7 +79,7 @@ HTTP/3 uses QPACK for header compression. The server sends decoder table updates
79
79
80
80
## Connection Management
81
81
82
-
The pipeline uses a connection pool to reuse TCP (or QUIC for HTTP/3) connections efficiently:
82
+
The pipeline uses actor-based connection managers (from Servus.Akka) to reuse TCP (or QUIC for HTTP/3) connections efficiently:
83
83
84
84
-**HTTP/1.0**: Each request gets a new connection; it's closed after the response
85
85
-**HTTP/1.1**: Connections are kept alive and reused for multiple requests to the same host
0 commit comments