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
https://twitter.com/colmmacc/status/1034492056968736768?s=19
this is a kind of load balancing where client requests can be sent to various backend servers, but each client request can have a different set of backend servers. The idea is to avoid complete overlap: in the case of a client request that brings down the server, the client could retry the request and bring down another server, until it has destroyed its entire set, other client requests would still be sent to live servers because their sets do not overlap.
Grounded in Workload Isolation Using Shuffle Sharding (Colm MacCárthaigh, Amazon Builders' Library, 2019): the isolation gain comes from C(N,k) virtual shards versus N/k plain partitions, so it is negligible on small pools (N=4, k=2 gives 6 combinations, nearly every client overlaps) and grows fast from N≈8 (C(8,2)=28, 7× better than 4 partitions). Shards must be stable for a client; HRW top-k gives that, since a change of N only moves backends at the tail of a client's ranking.
Current state on main: only the UDP datapath passes an affinity key to load balancing (next_available_backend_with_key(Some(flow_hash))); HTTP and TCP call it with None, so a cluster configured with MAGLEV or RENDEZVOUS silently degrades to round-robin.
Scope, two PRs in sequence.
PR 1 — affinity key for HTTP/TCP: pass a client key to the consistent-hashing policies on the HTTP, HTTPS and TCP paths, so Maglev/HRW pin a client as documented.
PR 2 — shuffle sharding: restrict selection to the client's top-k backends of the HRW ranking.
Client key. Default: the real client source IP (after proxy protocol). Per-cluster option to derive it from a named request header or cookie (HTTP/HTTPS only; TCP always uses the source IP). If the configured header/cookie is absent, fall back to the source IP.
Shard size. Per-cluster percentage of the cluster's backends: k = max(2, ceil(pct × N)), capped at N (minimum 2 keeps a retry possible inside the shard). Hot-updatable.
Activation threshold. Per-cluster min_backends, default 8 (the reference example of the paper). Below it the cluster behaves exactly as today.
Compatibility by default. Shuffle sharding is off until the shard percentage is configured. When enabled, the default mode is fallback: if every backend of a client's shard is unavailable, selection spills over to the rest of the cluster. Strict isolation (no spill-over, 503 with a dedicated metric) is opt-in per cluster.
Sticky sessions win. A sticky cookie naming a live backend is honoured even outside the client's shard; otherwise selection happens inside the shard.
/goal prompt
/goal Implement sozu-proxy/sozu#524 as decided in the maintainer comment of 2026-09-30: an affinity key for Maglev/HRW on HTTP, HTTPS and TCP (PR 1), then shuffle sharding over HRW top-k (PR 2).
BASELINE (re-measure on current origin/main first; stop and report if a fact no longer holds):
- Only UDP passes a key: `BackendMap::backend_from_cluster_id_with_key` / `BackendList::next_available_backend_with_key` (lib/src/backends.rs); HTTP/HTTPS/TCP pass `None`, and `Maglev`/`Rendezvous` (lib/src/load_balancing.rs) fall back to round-robin without a key.
- Backend selection for HTTP/HTTPS goes through `BackendDialer::select_and_dial` (lib/src/protocol/mux/router.rs, implemented in lib/src/protocol/mux/mod.rs); TCP selects in lib/src/tcp.rs.
- If the #1684 sequence (clock/RNG injection, G2 reservation at selection) has changed these signatures, follow the new shapes; do not reintroduce wall-clock or OS-RNG reads into selection.
PR 1 — affinity key for HTTP/HTTPS/TCP:
- Key = hash of the real client source IP (post proxy-protocol). Per-cluster option: derive it from a named request header or cookie (HTTP/HTTPS only), falling back to the source IP when absent. Hash without allocation on the request path.
- Plumb the option through command.proto (Cluster), command/src/config.rs, state, CLI and display, hot-updatable; keep every existing cluster's behaviour byte-identical unless it uses MAGLEV/RENDEZVOUS (whose behaviour now matches the documentation — state this in the CHANGELOG as a fix).
- Success: an e2e test per protocol showing that, with RENDEZVOUS, N requests from one client key hit one backend and different keys spread across backends; with the header option, two clients behind one source IP split by header. Per-request allocation count unchanged (test_allocations).
GATE: stop after PR 1 is open and report; wait for the maintainer before PR 2.
PR 2 — shuffle sharding:
- Per-cluster `shard_percent` (off when unset), `shard_min_backends` (default 8), `shard_mode` = `fallback` (default) | `strict`.
- Active only when the cluster has at least `shard_min_backends` backends; then k = max(2, ceil(shard_percent × N)), capped at N; the shard is the client key's top-k of the HRW ranking (stable under N changes).
- Selection and retries stay inside the shard; a live sticky-session backend wins even outside it. When the whole shard is unavailable: `fallback` spills to the rest of the cluster, `strict` answers 503 and increments a dedicated counter (plus a counter for spill-overs in fallback mode).
- Success: unit tests that shard membership is deterministic and stable when a backend is added/removed (only tail changes), that k and the threshold follow the formulas, that strict never selects outside the shard; e2e tests for fallback vs strict with the whole shard down; zero allocation added on the selection path.
EVERY PR: one concern per PR from a worktree off origin/main; docs in the same change (doc/configure.md, load-balancing docs, LIFECYCLE.md where relevant) and CHANGELOG; new tests seen red before green; never weaken a check; performance first (no allocation or syscall added on the hot path, measured); `cargo +nightly fmt --all -- --check`, stable and MSRV clippy with -D warnings, `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --locked`, workspace tests, e2e suite, `cargo +nightly fuzz build` in `fuzz/`, and the four `check_doc_citations.py` modes all exit 0; signed-off and signed commits without generated-by trailers.
STOP CONDITIONS: stop at the gate after PR 1; at most five attempts per failing check, then post the attempt ledger and stop; stop and report if a baseline fact no longer holds. End each run with `done=<bool> state=<step> prs=<n> blockedReason=<reason|none>`.
feat(lb): shuffle-shard clients over the HRW ranking of their affinity key #1712: shuffle sharding over the HRW top-k of that key, with k = max(2, ceil(pct×N)), active from shard_min_backends (default 8), off by default, FALLBACK by default and STRICT opt-in, sticky cookie and connection reuse keep priority; upgrade notes in CHANGELOG and doc/configure.md.
Activity
FlorentinDUBOIS commentedon Sep 29, 2026
Maintainer decisions (2026-09-30)
Grounded in Workload Isolation Using Shuffle Sharding (Colm MacCárthaigh, Amazon Builders' Library, 2019): the isolation gain comes from C(N,k) virtual shards versus N/k plain partitions, so it is negligible on small pools (N=4, k=2 gives 6 combinations, nearly every client overlaps) and grows fast from N≈8 (C(8,2)=28, 7× better than 4 partitions). Shards must be stable for a client; HRW top-k gives that, since a change of N only moves backends at the tail of a client's ranking.
Current state on
main: only the UDP datapath passes an affinity key to load balancing (next_available_backend_with_key(Some(flow_hash))); HTTP and TCP call it withNone, so a cluster configured withMAGLEVorRENDEZVOUSsilently degrades to round-robin.k = max(2, ceil(pct × N)), capped at N (minimum 2 keeps a retry possible inside the shard). Hot-updatable.min_backends, default 8 (the reference example of the paper). Below it the cluster behaves exactly as today./goalpromptrefactor(mux): selection reserves, a failed dial releases (#1709)
feat(lb): pass a client affinity key to Maglev and HRW on HTTP and TCP
feat(lb): pass a client affinity key to Maglev and HRW on HTTP and TCP (
feat(lb): shuffle-shard clients over the HRW ranking of their affinit…
feat(lb): shuffle-shard clients over the HRW ranking of their affinit…
FlorentinDUBOIS commentedon Sep 30, 2026
Implemented in two parts:
k = max(2, ceil(pct×N)), active fromshard_min_backends(default 8), off by default, FALLBACK by default and STRICT opt-in, sticky cookie and connection reuse keep priority; upgrade notes in CHANGELOG anddoc/configure.md.