I noticed following behavior of nginx recently, everything I describe
here is related to the case when we have huge number of configuration
files(> 1000). Once nginx is started it occupies more than 100MB of
memory, memory is not freed on fork. That is expected behavior but the
weird thing happens on configuration reload, once HUP signal is sent,
master process doubles occupied memory size, if reload is repeated
memory consumption stays the same, so it looks like memory is not reused
in process of reload, instead new pool is created, which leads to the
waste of memory.
I noticed following behavior of nginx recently, everything I describe
here is related to the case when we have huge number of configuration
files(> 1000). Once nginx is started it occupies more than 100MB of
memory, memory is not freed on fork. That is expected behavior but the
weird thing happens on configuration reload, once HUP signal is sent,
master process doubles occupied memory size, if reload is repeated
memory consumption stays the same, so it looks like memory is not reused
in process of reload, instead new pool is created, which leads to the
waste of memory.
Of course it creates a new pool. Nginx must continue to work and handle
requests, even if it fails to load the new configuration.
once HUP signal is sent,
continue to work and handle
requests, even if it fails to load the new
configuration.
Sounds reasonable, but unused pool(after reload process successfully
finished) is not destroyed, and after fork the amount of unused memory
is multiplied by the number of workers. I mean that we have two pools in
every worker and in the master process - pool with active configuration
and unused pool used for reload purposes.
On Tue, Jun 19, 2012 at 10:46:52PM +0400, Valentin V. Bartenev wrote:
Actually it is destroyed. But only after all old workers have finished
servicing their clients.
No, old cycle’s pool is destroyed right after new configuration
reading, at ngx_init_cycle() end.
(Note that this applies to normal mode of operation with master
process. Without master process there are some shims to delay old
cycle’s pool destruction as it might be needed. This is for
debugging only though.)
Maxim D.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.