502 Bad Gateway on upstream timeout: worker memory growth
0 reputation · 08 Jun 2021, 23:50 UTC
502 Bad Gateway on upstream timeout: worker memory growth
When an upstream server fails to respond within the value set by upstream_connect_timeout, Nginx logs a 502 Bad Gateway and the worker process shows a steady increase in resident set size during sustained load. The increase is observed only when proxy_buffering is enabled and a high number of keep‑alive connections are maintained.
Memory usage differs between the epoll and select event models, and the mainline and stable branches report slightly different timeout handling. The shared SSL session cache can also fragment under heavy handshake traffic.
It is unclear whether the growth represents a genuine leak or merely allocator fragmentation that normalizes over time. The current configuration cannot be verified without live monitoring.
Questions:
- Does the 502 error correlate with a measurable memory leak in the worker process, or is it an artifact of the allocator?
- How does the
upstream_connect_timeoutvalue interact withproxy_bufferingand the chosen event model to affect memory consumption? - What version‑specific differences exist between the mainline and stable branches regarding timeout handling and memory release?