A decision proxy in front of SearXNG: speculative execution, per-engine circuit breakers, and keyless fallback
Описание и применение
Готовый рецепт развертывания HTTP‑прокси searxng-gateway, который улучшает надёжность поиска SearXNG, добавляя кэш, предсказательное выполнение, ограниченный откат и индивидуальные разъёмы для каждого поискового движка, при этом сохраняя исходный JSON‑ответ.
Задача
Self-hosted SearXNG search degrades when free engines fail unpredictably, causing fewer results, higher latency, and unclear failure ownership.
Результат
The gateway improves search reliability by proactively managing engine failures, reducing latency, and providing clear observability, while keeping client integration unchanged.
Рабочий процесс
- 1. Deploy SearXNG and searxng-gateway as Docker services using the provided docker-compose snippet.
- 2. Configure environment variables: SEARXNG_BACKEND_URL, FALLBACK_PROVIDERS, T1_PREMIUM_COUNT, SUFFICIENT_MIN_RESULTS, FALLBACK_TIMEOUT_SECONDS, etc.
- 3. Start services; gateway exposes /search, /healthz, /metrics endpoints.
- 4. On each request, gateway normalises query, checks LRU cache, and decides whether to call SearXNG based on cooldown state.
- 5. Execute SearXNG and a configurable number of premium providers concurrently; premium providers are called serially within their pass.
- 6. Merge and deduplicate results by URL; if result count below threshold, perform bounded fallback round-robin until threshold met or timeout.
- 7. Record request outcome labels (cache_hit, searxng_ok, premium_ok, searxng_plus_premium_ok, fallback_fail, timeout).
- 8. Apply per-engine circuit breakers: a single 4xx error opens circuit for 5 minutes, then probes for recovery.
- 9. Expose Prometheus metrics and Grafana dashboard for observability.
- 10. Optionally run in keyless mode by omitting API keys, using only free engines.
Доказательства
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.
The gateway picks T1_PREMIUM_COUNT providers by atomic round-robin and invokes them serially within that pass.
Each premium provider and each SearXNG engine gets its own circuit breaker, built on sony/gobreaker.
- Дата записи: 2026-09-21T20:30:27.770Z