reloading conf

Maxim Dounin mdounin at
Tue May 3 04:27:51 MSD 2011


On Mon, May 02, 2011 at 07:00:18PM -0300, Jonathan Leibiusky wrote:

> Hi! How reloading my conf can affect my running nginx instances that are
> under load?

While reloading nginx master process parses new configuration, 
starts new worker processes and instructs old worker processes to 
gracefully terminate (i.e. finish processing of all requests and 
then exit).

This shouldn't affect anything but may require additional 
resources (mostly memory).  If you don't have enough memory reload 
may be problematic operation, and it's generally good idea to make 
sure your running nginx doesn't consume more than half of your 
server memory under normal load (to make sure it will be possible 
to start additional worker processes on reload).

> Just made a small test and I saw that some requests to the upstream are
> being lost. I am reloading the same configuration I had, didn't change
> anything.

It's strange you see something being lost.  Are you sure you 
actually did reload (i.e. sent SIGHUP to nginx master process)?

> Is there any best practice on how to do it? how often? if I should avoid
> something in particular? etc...

General practice is to reload config when you've changed it.

If you are doing reloads often - you may want to make sure 
previous reload was completed (i.e. old workers terminated) before 
doing another one (there is nothing fatal if it's not, but see 
above about resources).  Please note that with some use cases 
(long-running requests, downloads and so on) reload may take 
several hours or even more.

Maxim Dounin

More information about the nginx mailing list