A decision proxy in front of SearXNG: speculative execution, per-engine circuit breakers, and keyless fallback
TL;DR searxng-gateway is a Go HTTP proxy that sits in front of SearXNG and adds multi-provider fallback (Brave, Exa, Jina, Tavily), a per-engine circuit breaker, an in-memory LRU cache, Prometheus metrics, and a zero-key mode. It preserves SearXNG's JSON response shape, so clients do not change. The interesting parts are the execution model, the breaker semantics, and the trade-offs — including a…
The searxng-gateway is a Go HTTP proxy that sits in front of the SearXNG search engine, adding several features to improve reliability and performance. It preserves the JSON response shape produced by SearXNG, so clients do not need to change. Key features include speculative execution, per-engine circuit breakers, an in-memory LRU cache, Prometheus metrics, and a zero-key mode.
Speculative execution allows SearXNG and a configurable number of premium providers to start together, with premium calls running serially within that pass. Bounded fallback kicks in if the merged result count is below a threshold, trying remaining providers round-robin until the time budget expires.
Per-engine circuit breakers are implemented for each SearXNG engine and premium provider using the gobreaker library. A single 4xx-class error immediately opens the circuit, preventing further requests to that engine. After a five-minute timeout, the circuit enters a half-open state, sending a single probe request. If successful, the circuit closes and increments the recovery counter; otherwise, it re-opens for another five minutes.
SearXNG itself has its own cooldown mechanism, skipping it entirely after a certain number of consecutive failures.
Observability is provided through Prometheus metrics and an importable Grafana dashboard, with example alert rules available. Keyless mode allows the gateway to run on SearXNG's free engines without requiring API keys.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.