Anoop Alias
March 07, 2019 10:10PM
Its simple..Nginx has a master process and number of worker process as you
configure in nginx.conf . Its the workers that handle connections and each
one does async

When you do a HUP, all the master process is doing is spawning n new
workers and all new connections to port 80/443 are handled by the new
workers, but remember that he old workers may still be doing some job and
terminating it then and there means you are closing off some connections in
a non-graceful way, so the master process keeps the old workers also active
for sometime to let it gracefully finish all its doing

So if the worker process is n , during reload it will become 2n and then n
workers are gracefully shutdown which means if n workers use x memory ,
then during reload the memory become 2x

You can set workers to a low value ,say 1 worker process if the system is
limited in memory ,but the possibility of having 2n workers during reload
cannot be avoided as its more like a feature and the 2x memory usage is an
unwanted side effect of this feature

Having said that Nginx dev's can still look into why defining more vhost
consume lot of memory while apache dont have this problem. I develop an
automation script for a popular web control panel and most servers using
the script have upto 10k vhost defined and the memory usage would be 4x
times than apache for nginx with this much amount of vhosts defined . with
ssl defs etc needed for each vhost we cannot reduce the number of
vhosts also


On Fri, Mar 8, 2019 at 8:05 AM wkbrad <nginx-forum@forum.nginx.org> wrote:

> Thanks, Anoop! But I don't think you understood the point I was trying to
> get across. I was definitely not trying to compare nginx and apache memory
> usage. Let's just ignore that part was ever said. :)
>
> I'm trying to understand why Nginx is using 2x the memory usage when the
> HUP
> signal is sent, i.e. the normal reload process.
>
> When you use the USR2/QUIT method, i.e. the binary upgrade process, it
> doesn't do this.
>
> It's a big problem on high vhost servers when you go from normally using 1G
> of ram to using 2G and then 4G during subsequent reloads.
>
> It's that brief 4G spike that initially caught my attention. But then I
> noticed that it was always using 2x more ram. Whoa!
>
> This is super easy to reproduce so I invite you to test it yourself.
>
> Posted at Nginx Forum:
> https://forum.nginx.org/read.php?2,283216,283312#msg-283312
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>


--
*Anoop P Alias*
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Possible memory leak?

wkbrad February 28, 2019 01:43PM

Re: Possible memory leak?

Maxim Dounin February 28, 2019 03:08PM

Re: Possible memory leak?

wkbrad February 28, 2019 03:54PM

Re: Possible memory leak?

Maxim Dounin February 28, 2019 04:50PM

Re: Possible memory leak?

wkbrad February 28, 2019 05:06PM

RE: Possible memory leak?

Reinis Rozitis February 28, 2019 05:28PM

Re: Possible memory leak?

Alceu R. de Freitas Jr. via nginx February 28, 2019 06:02PM

Re: RE: Possible memory leak?

wkbrad February 28, 2019 06:44PM

Re: Possible memory leak?

wkbrad March 07, 2019 01:33PM

Re: Possible memory leak?

Anoop Alias March 07, 2019 08:06PM

Re: Possible memory leak?

wkbrad March 07, 2019 09:35PM

Re: Possible memory leak?

Anoop Alias March 07, 2019 10:10PM

Re: Possible memory leak?

wkbrad March 08, 2019 10:39AM

Re: Possible memory leak?

Anoop Alias March 08, 2019 06:54PM

Re: Possible memory leak?

gariac March 08, 2019 01:10AM

Re: Possible memory leak?

wkbrad March 08, 2019 10:42AM

Re: Possible memory leak?

gariac March 08, 2019 08:08PM

Re: Possible memory leak?

wkbrad March 11, 2019 04:37PM

Re: Possible memory leak?

Anoop Alias March 12, 2019 09:56AM

Re: Possible memory leak?

Maxim Dounin March 12, 2019 10:40AM

Re: Possible memory leak?

Anoop Alias March 12, 2019 11:00AM

Re: Possible memory leak?

Maxim Dounin March 12, 2019 11:48AM

Re: Possible memory leak?

wkbrad March 12, 2019 02:09PM

Re: Possible memory leak?

Maxim Dounin March 12, 2019 09:58PM

Re: Possible memory leak?

Peter Booth via nginx March 13, 2019 01:44AM

Re: Possible memory leak?

Anoop Alias March 13, 2019 01:54AM

Re: Possible memory leak?

wkbrad March 20, 2019 06:41PM

Re: Possible memory leak?

Maxim Dounin March 21, 2019 09:46AM

Re: Possible memory leak?

Maxim Dounin March 21, 2019 09:48AM

Re: Possible memory leak?

wkbrad March 21, 2019 11:29AM

Re: Possible memory leak?

Maxim Dounin March 21, 2019 02:18PM

Re: Possible memory leak?

wkbrad March 21, 2019 05:55PM

Re: Possible memory leak?

Maxim Dounin March 25, 2019 08:40AM

Re: Possible memory leak?

wkbrad March 27, 2019 02:54PM

Re: Possible memory leak?

Maxim Dounin March 27, 2019 04:26PM

Re: Possible memory leak?

gariac March 13, 2019 01:58AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 81
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready