Web / NGINX Interview questions
How do you troubleshoot high memory usage in NGINX worker processes?
High worker memory usage usually traces back to a handful of common causes rather than a leak in NGINX itself, which is written to be lean by design.
- Large buffers - oversized
proxy_buffers,client_body_buffer_size, orlarge_client_header_bufferssettings inflate per-connection memory use. - Excessive worker_connections - each open connection carries some memory overhead; a very high limit under real traffic multiplies that.
- Response buffering with slow clients - if
proxy_bufferingis on and clients read slowly, NGINX may spool large responses to disk or hold them in memory longer than expected. - Third-party or custom modules - compiled-in modules can introduce their own memory behavior outside NGINX core's normal footprint.
Useful diagnostic steps include checking ps or top per worker PID, reviewing buffer-related directives against actual response sizes, and testing whether memory growth correlates with a specific traffic pattern - such as large file uploads or slow downstream clients - rather than climbing steadily, which would instead point to an actual leak worth reporting upstream.
More Related questions...