Repository navigation
fix(mux-h2): emit fewer connection-level WINDOW_UPDATE frames when receiving DATA - #1752
Merged
Merged
Conversation
…ceiving DATA Sōzu returns connection credit in one stream-0 WINDOW_UPDATE per half of h2_initial_connection_window received (RFC 9113 §6.9). With the 1 MiB default that is one frame per 512 KiB: a 64 MiB transfer cost 125 of them, enough at LAN speed to trip a peer's stream-0 WINDOW_UPDATE flood detection, Sōzu's own included. Raise the default to 16 MiB (Chromium 15 MB, Envoy 24 MiB): the same transfer now costs 8, as H2 server and as H2 client. The window stays advertised, not enforced; DATA is read only when its stream buffer has room, so the buffer pool still bounds memory. Stream-level credit is still returned per DATA frame: at the 65535-octet stream window, returning it per half window halved single-stream throughput on loopback. Fixes #1744 Signed-off-by: Florentin Dubois <[email protected]>
On a backend connection, handle_settings_frame granted the connection window surplus (initial_connection_window - 65535) whenever Sōzu's own send window was at most 65535, so every SETTINGS frame from a backend that had not granted credit queued another grant. With a 16 MiB window about 128 repeats push the backend's send window past 2^31-1, a FLOW_CONTROL_ERROR (RFC 9113 §6.9.1). Track the enlargement with a flag so it is sent once per connection. Document the kernel cost of the larger default: user-space memory stays bounded by the buffer pool, but a connection Sōzu stops reading may hold up to min(window, max_concurrent_streams x 65535), about 6.25 MiB by default, in its socket receive buffer. Refs #1744 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/h2-window-update-coalescing
branch
from
October 1, 2026 19:39
98b8949 to
7e982b9
Compare
Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 3, 2026
…1809) Audit of the docs, `bin/config.toml` and `os-build/config.toml` against everything merged on `main` from 2026-10-01 to 2026-10-03 (43 commits, #1724 through #1808). Most of the new keys were already documented by their own PRs (`max_connection_attempts`, `h2_stream_refusal_percent`, health check `mode`/`accepted_statuses`, the raised flood defaults, the 16 MiB connection window). This PR fixes what was still stale. | Area | Where | Was | Now | |---|---|---|---| | #1806 | `bin/config.toml`, `os-build/config.toml` answer comments | 503 only for "no backend available"; "504 means the backend timed out" | 503 also when every attempt failed; 504 = connected backend silent or frontend timeout while waiting; connect timeout fails over | | #1806 | `bin/config.toml` `max_connection_attempts` | connect timeout always fails over | a TCP session whose connect times out is closed | | #1806 | `doc/debugging_strategies.md` | 503 after a circuit breaker of 3 failed connections; ERROR log lines, one that no longer exists | `max_connection_attempts` (default 5), `backend.connect.retries_exhausted`, real TCP log levels and text | | #1806 | `doc/configure.md` `front_timeout` / `connect_timeout` rows | "inactivity for a request to connect" | time to establish a backend connection; HTTP fails over, TCP closes; H1 failover bound by `front_timeout` | | #1806 | `doc/configure.md` `client_timeout_during_response`, `backend_timeout`, `http.503.errors` | "connection-level slowness", "circuit breaker" | failover case included; established connection only; attempt budget | | #1806 | `LIFECYCLE.md` backend timer | 504 for any linked stream | established connection only | | #1806 | `cli.rs` help, `doc/configure_cli.md` | "answered 503" | "or a TCP session is closed" | | #1756 | `doc/configure.md` flood metrics | RST lifetime rows described as absolute ceilings; no `window_update_stream0_window` row | floor-and-ratio semantics; row added | | #1756/#1798 | `doc/architecture.md`, `doc/h2_mux_internals.md` | 6 / 13 `H2FloodConfig` thresholds | 14, with `h2_stream_refusal_percent` | | #1756 | `doc/configure_admin_ops.md` | "halve" example 50/25 (old defaults); H2 knobs HTTPS only | 1000/500; HTTP and HTTPS; `h2.flood.stream_refused` | | #1752 | `doc/configure.md` glitch tuning | "1 MiB window ... about 64" frames | 64 KiB stream window, about four | | #1805 | `doc/health_checks.md` | `remove` resets backends to healthy; DOWN logs an error; `load_balancing.rs::BackendList::healthy` | backends keep their last state (see note); warning; `BackendList::select_tiers` in `backends.rs` | | #1805 | `doc/metrics.md` | health-check counters "per cluster" | unlabelled | | #1805 | `doc/configure_cli.md` | no health-check section | short section, `--mode`, `--probe-timeout` vs global `--timeout` | | #1746 | `cli.rs` `--load-balancing-policy`, `bin/config.toml`, proto comment | HRW/MAGLEV key = UDP flow key | UDP affinity key (source IP, or IP and port) | | UDP | `doc/configure.md` | hot upgrade drains flows bounded by idle timeout; `udp.flows.evicted` reasons | soft-stop closes flows at once; listener removal/soft-stop/abort added | | #1770 | `doc/udp_simulation.md` | no per-source limits | in reconfig storms and the invariant list | | #1743 | `doc/lifetime_of_a_session.md` | keep-alive backend always reused | unless its backend was removed | | older | `command.proto` update messages | `h2_stream_shrink_ratio >= 1` | `>= 2`, as validated in `state.rs` | | #1806 | e2e shuffle-sharding doc comment | "three connection attempts" | `max_connection_attempts` (5 by default) | Reported here, not changed in this PR: - `sozu cluster health-check remove` does not reset backends a probe marked DOWN (`remove_health_check_state` skips the reset that `set_health_check_config(None)` does), so they stay out of rotation until the cluster is added again. The doc now describes this. It looks like a code bug. - `sozu top`'s H2 pane reads `h2.flood.violation.{rapid_reset,made_you_reset,ping,settings,priority,continuation}`, which the detector never emits (it emits `rst_stream_pre_response_lifetime`, `ping_window`, ...). Only `glitch_window` matches, and `h2.flood.stream_refused` is not shown. - `h2_flood_detector.rs` comments still refer to a 1 MiB connection window, and the `h2_stream_idle_timeout_seconds` proto comment says "Default: 30" where the value inherits `back_timeout`. - `connections.rejected_per_cluster_ip` is documented as also counting TCP rejections; only the HTTP 429 path increments it. Validation: - `sozu config check` passes on `bin/config.toml`, on a copy with every commented key under review uncommented (global and cluster `max_connection_attempts`, the H2 block, the health check block), and on `os-build/config.toml` with local state/socket paths. Negative controls (`max_connection_attempts = 0`; `expected_status = 200` next to `accepted_statuses`) are rejected. - `cargo +1.93.1 test -p sozu-command-lib --all-features --locked`: 235 passed. - `cargo +1.93.1 test -p sozu --bin sozu --locked`: 124 passed (including the `--load-balancing-policy` help tests). - `cargo +nightly fmt --all --check` and `python3 .github/scripts/check_doc_citations.py --root . --base origin/main` are clean. Signed-off-by: Florentin Dubois <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sōzu sends one stream-0
WINDOW_UPDATEper half ofh2_initial_connection_windowit receives (RFC 9113 §6.9). With the 1 MiB default, a 64 MiB transfer costs 125 of these frames. That happens whether Sōzu is the H2 server receiving a request body or the H2 client receiving a backend response. At LAN speed this rate can trip a peer's stream-0WINDOW_UPDATEflood detection, including Sōzu's own.This raises the default to 16 MiB. For comparison, Chromium uses 15 MB, Envoy 24 MiB and Go's HTTP/2 client 1 GiB. The same transfer now costs 8 frames. The window is advertised but not enforced: DATA is read only when its stream buffer has room, so the buffer pool still bounds memory. Listeners that set the key explicitly keep their value.
User-space memory stays bounded by the buffer pool. The kernel cost does grow: a connection Sōzu stops reading may now hold up to min(window,
h2_max_concurrent_streams× 65535) octets, about 6.25 MiB by default instead of about 1 MiB, in its socket receive buffer. This is documented indoc/configure.md.On a backend connection, the one-shot connection-window grant fired on every SETTINGS frame while Sōzu's own send window was at most 65535, not only on the first. A backend re-sending SETTINGS could thus be pushed past 2^31-1 (RFC 9113 §6.9.1). The grant is now tracked by a flag and sent once per connection;
repeated_backend_settings_enlarge_the_connection_window_oncecovers it.Stream-level credit is still returned per DATA frame. At the default 65535-octet stream window, returning it per half window halved single-stream throughput on loopback. A larger stream window is a separate decision.
Tests:
e2e/src/tests/h2_window_update_tests.rsmoves 64 MiB through Sōzu in each position, with a sender that honours the windows Sōzu grants. Each test asserts that the transfer completes and that Sōzu sends at most 1 + 64 MiB / 8 MiB stream-0WINDOW_UPDATEframes. With the 1 MiB default both tests fail (125 > 9); with 16 MiB both pass (8).Commands run:
cargo +nightly fmt --all -- --check,cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps,cargo test -p sozu-lib --all-features -- protocol::mux, targetedcargo test -p sozu-e2e(window / flow-control / large-response / upload),cargo +nightly fuzz build,check_doc_citations.py(self-test, root, base origin/main, audit).Docs:
doc/configure.md,doc/h2_mux_internals.md,bin/config.toml, proto and config comments, CHANGELOG.Fixes #1744