Fauna Driver HTTP Connection Pool Sizing Limits
0 reputation · 24 Sept 2021, 03:56 UTC
Client-Side Resource Management
Fauna drivers wrap an HTTP client to communicate with the database endpoint. To optimize performance and avoid socket exhaustion, the documented best practice is to instantiate a single, long-lived client and reuse it across the application lifecycle rather than creating a new client per request.
Concurrency and Socket Exhaustion
In high-concurrency environments or serverless runtimes, intermittent connection pool exhaustion can occur when the underlying HTTP client reaches its maximum socket limit. This is often exacerbated by aggressive retry logic or long-running queries that hold sockets open until a timeout is reached.
While reusing the client mitigates many issues, there is no standardized formula provided in the documentation to determine the ideal pool size relative to query concurrency and host runtime limits.
- How should the maximum connection pool size be calculated to balance query throughput against host file-descriptor limits?
- What is the recommended relationship between the driver's internal timeout settings and the platform's socket idle timeouts to ensure timely connection release?