Periodic external HTTP exchange from NGINX for dynamic control of upstream server list

Philip Walenta philip.walenta at gmail.com
Tue Oct 17 13:19:31 UTC 2017


It sounds like you want to control what upstream servers are available
based on a set of criteria.

This setup might do what you want, just not implemented in the exact way
you desire:
https://medium.com/@sigil66/dynamic-nginx-upstreams-from-consul-via-lua-nginx-module-2bebc935989b



On Tue, Oct 17, 2017 at 7:01 AM, rnmx18 <nginx-forum at forum.nginx.org> wrote:

> Hi,
>
> I have a requirement to de-select or exclude one or more servers from an
> upstream group, if that server is either just newborn or exhausted
> (overloaded or showing reduced performance).
>
> So, consider there are servers A, B and C in the upstream group. An
> external
> program periodically checks A, B and C and keeps track of different
> parameters (uptime, average response time etc), and assigns a "good" or
> "bad" status flag to each of them.
>
> I would like to implement a mechanism in NGINX, in which it can
> periodically
> (say every 5 minutes) communicate with this external program and collect
> the
> status flag for A,B and C. This would be an HTTP communication with a
> response in a parse-able text format. Assume if B is reported as "bad", I
> would like to exclude B temporarily, till I get a "good" value back for it.
>
> I am aware of the native upstream healthcheck mechanism in NGINX.
>
> However, the requirement here is to bring some additional parameters into
> consideration for the selection of upstream.
>
> I would like to know whether this is feasible to realize in NGINX. Could
> someone please explain some design insights for this problem?
>
> Going a bit deeper, I could identify the following potential requirements
> or
> questions?
>
> a) Should I depend on both (a) the passive upstream check native to NGINX
> and (b) the status value to be obtained from the external process? I think
> since the native health check is passive in nature (like when NGINX tries
> to
> connect to an upstream when it wants to proxy the request), it is beyond my
> programmable-control. So, I needn't worry about that. What I should be
> worried is about enabling NGINX to dynamically exclude a particular server,
> based on a "bad" feedback from the external process.
>
> b) How to communicate periodically with the external process over HTTP? How
> can I get an HTTP client functionality in NGINX to send an external request
> and process the response? Can I build this functionality as an NGINX
> module?
>
> c) Last but not the least, I would need some mechanism by which I should be
> able to map the server(s) reported as "bad" to the configured upstream
> servers, and then temporarily exclude them (mark down), and later include
> them when the status changes to "good".
>
> Thanks
> Rajesh
>
> Posted at Nginx Forum: https://forum.nginx.org/read.
> php?2,276912,276912#msg-276912
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20171017/6834bcc3/attachment.html>


More information about the nginx mailing list