Skip to main content

Module strategy

Module strategy 

Source
Expand description

Proxy rotation strategy trait and built-in implementations.

§Why Thompson Sampling

Round-robin assumes proxy health is stationary; in practice a proxy that worked a minute ago may now be banned, and a dead one may recover. Round-robin therefore wastes a fixed fraction of every batch on dead proxies. Thompson sampling — see docs/dev/project/scraping-guide-2026-llm-context.md §“Stop Round-Robining Dead Proxies: Bayesian Selection” (L3018-3021) — models each proxy’s success probability as a Beta(α, β) posterior and draws one sample per candidate on each acquisition. The 2026 ProxyOps benchmark cited in the guide reports 76 % success with Thompson sampling vs 36 % with round-robin on identical proxies and targets (549 114 requests in 7 days) — more than double the success rate.

[ThompsonStrategy] is the Stygian implementation; it lives behind the bayesian-rotation cargo feature (off by default to preserve deterministic round-robin in existing deployments). The hot path is two atomic loads + one xorshift64 draw per candidate, which stays well under the 1 µs acquisition budget documented in crates/stygian-proxy/AGENTS.md.

Structs§

LeastUsedStrategy
Selects the healthy proxy with the fewest total requests.
NoopBayesianObserver
Discarding BayesianObserver used when no strategy is configured.
ProxyCandidate
A lightweight view of a proxy considered for selection.
RandomStrategy
Selects a healthy proxy uniformly at random on each call.
RoundRobinStrategy
Cycles through healthy proxies in order, distributing load evenly.
WeightedStrategy
Selects a healthy proxy with probability proportional to its weight.

Traits§

BayesianObserver
Callback that receives outcome observations for a specific proxy.
RotationStrategy
Selects a proxy from a slice of candidates on each request.

Functions§

capable_healthy_candidates
Filter all to candidates that are healthy and satisfy req.
healthy_candidates
Filter all to only the candidates that are currently healthy.

Type Aliases§

BoxedBayesianObserver
Shared-ownership type alias for a BayesianObserver implementation.
BoxedRotationStrategy
Shared-ownership type alias for a RotationStrategy implementation.