`httpd.timeout` in CouchDB 3.2.0 `_changes` long-poll boundary
0 reputation · 20 Feb 2022, 21:43 UTC
0 reputation · 20 Feb 2022, 21:43 UTC
CouchDB 3.2.0 replaces the fixed 30‑second HTTP request limit with a configurable httpd.timeout integer in the httpd section of local.ini or default.ini. This timeout governs how long the server waits before returning HTTP 408 and aborting the connection. The same interval also governs _changes long‑poll feeds: if no change notification occurs within the configured period, the connection closes and the client must reconnect. Setting the value to 0 restores indefinite waiting, but the timeout applies uniformly across request and feed contexts.
The uniform timeout applies to both short‑lived API calls and indefinite _changes feeds, yet the documentation offers no per‑endpoint override or adaptive mechanism. Operators must choose between risking 408 errors for slow legitimate clients and retaining open connections under load, creating a configuration tension without granular control.
How does the timeout interact with multiple simultaneous _changes feeds on a single node? Can a client effectively extend the wait interval through request pipelining or intermediate proxies? What is the expected behavior when timeout is set to 0 alongside active long‑poll sessions that previously exceeded the default 30‑second bound?
34775 reputation · 21 Feb 2022, 01:55 UTC
Each _changes long-poll is an independent HTTP request with its own per-connection wait boundary. Multiple simultaneous feeds on one node do not share or reset each other's timer. The node will track sockets, memory and CPU per feed, so OS file-descriptor and connection limits are usually hit before any per-feed timeout becomes the bottleneck.
HTTP pipelining cannot extend a blocking long-poll wait. The connection is held until CouchDB responds, so queued pipelined requests are head-of-line blocked and do not make the server wait longer. An intermediate proxy or load balancer can only terminate, buffer or reconnect the feed; it adds its own idle timeout and may return 504/502 or close the connection earlier than CouchDB. It does not make CouchDB wait longer.
If httpd.timeout is set to 0, newly established long-poll sessions after a reload/restart can wait indefinitely for a change, subject to the _changes timeout query parameter and any proxy/TCP idle limits. Sessions that were already open under the previous limit typically keep the deadline they were created with and will close at that deadline or on reconnect. Behavior on a live reload is version-specific.
curl -s http://localhost:5984/_node/_local/_config/httpd/timeout
Inspect default.ini and local.ini under [httpd] and confirm the key is accepted by your build.curl -v "http://localhost:5984/db/_changes?feed=longpoll&timeout=60000"
Repeat with concurrent curls. Each should close independently.Operational note: uniform indefinite waiting retains slow clients but can exhaust connections, file descriptors and memory under load. Prefer a finite _changes timeout with heartbeat for continuous feeds rather than relying on httpd.timeout=0.
One missing diagnostic that changes the recommendation: the resolved CouchDB build and the effective [httpd] timeout value in your deployment. If the key is absent or ignored in your build, the whole timeout interaction described above does not apply.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.