Hello!
On Fri, May 6, 2016 at 9:42 AM, jonathan wrote:
> What you're talking about doing is certainly possible in openresty, but I
> think you might be better off just having your control-panel alter an
> nginx.conf file, and then `kill -HUP` nginx to reload it. nginx does a
> "graceful reload" with `kill -HUP {master_pid}`, so you wouldn't have any
> downtime (just some lingering connections processed with the old config
> during the transition).
>
I would recommend the Lua approach to lazily load and cache dynamic
configurations. For example,
https://openresty.org/en/dynamic-routing-based-on-redis.html
You can extend this to much more complicated scenarios BTW.
HUP reload has these issues:
1. You need some external mechanism to generate a new nginx.conf (from
some template maybe), adding operations overhead.
2. You also need some external mechanism to reload nginx and test
nginx.conf integrity too.
3. Nginx reload flush out all the JIT compiled Lua code, which can be
a pain when you have a *lot* of Lua code and reload your nginx often.
4. You may accumulate many (gracefully) "exiting" nginx workers when
you have some long running downstream connections or requests.
5. When you run a large network with many unevenly distributed hosts
and configurations, generating a huge nginx.conf is not feasible nor
efficient. Loading stuff on demand and cache it is much more efficient
due to the locality nature of the traffic.
Well, just my 2 cents.
Regards,
-agentzh