High memory usage

J.R. themadbeaker at gmail.com
Wed Oct 23 16:36:11 UTC 2019


> A typical vhost file is quite simple, it's just a proxy_pass to a backend,
> with some hack to do a retry is we first get and error message (based on
> proxy_intercept_errors). http2 is on. I don't use any caches.

Are you running PHP FPM? If so, check all your process manager
settings. I've seen when misconfigured that can eat up a ton of ram
quickly.

I've always left the worker_processes to auto, as the docs say it
should equal the number of cores of the system. Though it sounds like
6 is adequate if you are not experiencing high CPU load. Though I'm
not sure if more cores would allow for faster reading / processing of
your configuration files, maybe bump up to 12 since that is the number
of actual cores for that CPU.

Why do you suspect the gzip module? If anything I would think it would
eat CPU cycles, not memory... Unless you are trying to compress some
*really* large content. I know there is a minimum size setting, I
don't know if there is a maximum one too... I see you have the brotli
compression module installed too... Have you set brotli_comp_level
(among the other settings) ???

The point of the SSL session cache is to reduce CPU usage by having to
constantly re-negotiate a SSL session... Think about how long a person
will read a page on your site(s)... You would really want at minimum
like 5 minutes, otherwise the cache really isn't saving you any
processing and only eating up memory. Depending on your log level, the
error log would let you know if your cache gets full and needs to be
increased (or the TTL lowered) as you would see something like, "could
not allocate new session in SSL session shared cache...."

Are you using a shared cache across *all* your virtual hosts for the
ssl_session_cache & limit_conn, or does each vhost have their own? I
could see how that would eat up memory real quick with the number of
vhosts you have.

Whenever possible you should try to use settings at the http level so
that it's only creating that instance once. If you are using the same
thing under every server directive, then each server instance has its
own copy and thus using more memory.

Can you post your configuration settings? It's okay to strip out any
personal identifiable information. Otherwise it's just a guessing
game...


More information about the nginx mailing list