Reliability
OOM protection, cache deduplication, rate limiting for AI APIs, and built-in health checks for production environments.
Reliability & Metrics
In production, search engines often crash due to OOM errors or AI API rate limits. pg-smart-search (v1.3+) introduces native safeguards.
OOM Protection (MAX_ROWS)
If a user searches for a highly common term (e.g., "the"), a naive search will load millions of rows into Node.js memory, causing an Out-Of-Memory crash.
The engine enforces a MAX_ROWS limit at the database query level. It uses LIMIT clauses aggressively, ensuring your Node.js process never allocates more memory than necessary.
Redlock-Style Cache Deduplication
In distributed environments, multiple instances might receive the same search query simultaneously. Without deduplication, all instances query the database and update Redis at the same time.
We implement Redlock-style cache deduplication: only the first instance to acquire the lock queries the database; the rest wait and serve the cached result.
AI API Rate Limiting (p-queue)
Semantic search relies on external APIs (OpenAI, Gemini) which have strict rate limits. The engine includes an intelligent rate-limiting queue (p-queue):
- If the API returns
429 Too Many Requests, the engine automatically pauses vector search requests and retries them, preventing cascade failures.
True Zero-Freeze Networking
Native AbortController propagation ensures timeouts (10s default) actually kill underlying fetch requests to AI APIs, preventing frozen connections from blocking the event loop.