Welcome! Log In Create A New Profile

Advanced

Dynamic nginx configuration without reloading

Posted by House Lee 
House Lee
Dynamic nginx configuration without reloading
January 01, 2018 07:10AM
Hi All,

We are currently building a shared hosting platform for parts of our clients. We are using nginx as our web servers running on the nodes.

Everything works fine. However, we discovered that when we are hosting more than a certain amount of sites (typically around 300 conf files), reloading nginx conf is extremely slow.

Is there a way to dynamically configure nginx (e.g. adding/removing server blocks) without reloading nginx?


Thanks & Best Regards
House
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: Dynamic nginx configuration without reloading
January 01, 2018 10:00PM
Hello!

On Mon, Jan 01, 2018 at 12:07:04AM -0600, House Lee wrote:

> We are currently building a shared hosting platform for parts of
> our clients. We are using nginx as our web servers running on
> the nodes.
>
> Everything works fine. However, we discovered that when we are
> hosting more than a certain amount of sites (typically around
> 300 conf files), reloading nginx conf is extremely slow.
>
> Is there a way to dynamically configure nginx (e.g.
> adding/removing server blocks) without reloading nginx?

Short answer:

No.

Long answer:

There are ways to do limited reconfiguration without reloading,
notably the API module[1], available as part of our commercial
subscription. It won't, however, allow to add or remove server{}
blocks.

That is, to add or remove server{} blocks you have to do a
configuration reload. Note though, that in many cases you can
actually avoid adding or removing server{} blocks. Multiple
identical or slightly different sites can be handled using a
single server{} block with multiple server names.

Note well that 300 looks a way too low for "extremely slow",
you may want to check what actually makes it so slow. In
particular, make sure that:

- you do have enough memory, as reload creates a new set of
worker processes and this more or less doubles memory used by
nginx;

- you don't have problems with DNS and/or no names are used in a
configuration. Slow DNS can easily make loading a
configuration with multiple names extremely slow due to blocking
DNS lookups during configuration parsing.

[1] http://nginx.org/en/docs/http/ngx_http_api_module.html

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login