Memory usage doubles on reload

Hello we are running nginx 1.2.7 with this in conf:
output_buffers 5 5m;
sendfile off;

That works well, BUT if I reload server configuration with nginx -s
reload
Memory consumptions for few hours(clients use long lived(few hours) tcp
connections). Is this behavior correct? Can we avoid this? We have to
had as
twice much RAM to be able to restart nginx under load.

Sincerely Petr Holik

Posted at Nginx Forum:

Hello!

On Wed, Mar 05, 2014 at 05:47:47PM -0500, PetrHolik wrote:

Hello we are running nginx 1.2.7 with this in conf:
output_buffers 5 5m;
sendfile off;

That works well, BUT if I reload server configuration with nginx -s reload
Memory consumptions for few hours(clients use long lived(few hours) tcp
connections). Is this behavior correct? Can we avoid this? We have to had as
twice much RAM to be able to restart nginx under load.

On configuration reload nginx spawns new worker processes, and
gracefully shuts down old worker processes (and gracefull shutdown
may take a while, especially if there are long-lived requests).
That is, behaviour you observe is expected.

Some more details can be found here:
http://nginx.org/en/docs/control.html


Maxim D.
http://nginx.org/

Hello Maxim, thanks for reply.

Is there possibility to purge allocated buffer(RAM) in old(gracefully)
worker processes? IMO worker thread have allocated all memory till last
clients disconnects. That is really isue for us - we have currently
32Gigs
of spare RAM to be able to handle reload under load.

Sincelery Petr Holik

Posted at Nginx Forum:

Hello!

On Thu, Mar 06, 2014 at 03:01:49PM -0500, PetrHolik wrote:

Hello Maxim, thanks for reply.

Is there possibility to purge allocated buffer(RAM) in old(gracefully)
worker processes? IMO worker thread have allocated all memory till last
clients disconnects. That is really isue for us - we have currently 32Gigs
of spare RAM to be able to handle reload under load.

All allocations done for a particular requests are freed as long
as the request is finished. The problem though is that OS
memory allocators rarely return freed memory back to the OS,
especially on Linux. You may try playing with allocators and/or
allocator options to make things better.

Note well that “spare” memory isn’t really spare, as it can be
used by OS for file cache.


Maxim D.
http://nginx.org/

Ok, thanks for info.

I’ll, do some research. I read some articles about memory allocation and
I
think when the system will be going to out of memory, the will try to
reclaim freed pages which in normal situations when have enough ram does
not
because of avoiding memory fragmentation.

Petr Holik

Posted at Nginx Forum: