implement upstream max_conns in lua

253 views
Skip to first unread message

David Birdsong

unread,
Apr 20, 2015, 3:08:33 PM4/20/15
to openresty-en
Hi, I'd like to make upstream decisions based on current connection counts or even better, upstream connection counts.

I haven't found any variables supplied by nginx core that could help me track. Does such a value exist? Is there some API that I can read to count connections?

in...@ecsystems.nl

unread,
Apr 21, 2015, 5:09:12 AM4/21/15
to openre...@googlegroups.com

Yichun Zhang (agentzh)

unread,
May 7, 2015, 8:57:07 AM5/7/15
to openresty-en
Hello!

On Tue, Apr 21, 2015 at 3:08 AM, David Birdsong wrote:
> Hi, I'd like to make upstream decisions based on current connection counts
> or even better, upstream connection counts.
>

Have you looked at the standard least connection upstream balancer module?

http://nginx.org/en/docs/http/ngx_http_upstream_module.html#least_conn

Also, the standard ngx_limit_conn module may also be relevant here:

http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html

> I haven't found any variables supplied by nginx core that could help me
> track. Does such a value exist? Is there some API that I can read to count
> connections?
>

See above.

FWIW, once the balancer_by_lua directive of the ngx_lua module is
opensourced (it is already implemented internally in CloudFlare), such
tasks would be trivial for a little bit of Lua :)

Best regards,
-agentzh

David Birdsong

unread,
May 7, 2015, 3:13:12 PM5/7/15
to openre...@googlegroups.com
Thanks for these links. The module is really cool, I'll probably check it out for monitoring.

I do need something that can be examined in path of a request though, so I was hoping to find an in-memory reference that could be examined for making routing decisions.

On Monday, April 20, 2015 at 9:08:33 PM UTC+2, David Birdsong wrote:
Hi, I'd like to make upstream decisions based on current connection counts or even better, upstream connection counts.

I haven't found any variables supplied by nginx core that could help me track. Does such a value exist? Is there some API that I can read to count connections?

--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Birdsong

unread,
May 7, 2015, 3:15:54 PM5/7/15
to openre...@googlegroups.com
great, this is exactly what I was hoping for. i look forward to seeing that come out.

i scour cloudflare's github page frequently, but will you post it here on the list when it comes out?

Best regards,
-agentzh

Yichun Zhang (agentzh)

unread,
May 7, 2015, 11:29:38 PM5/7/15
to openresty-en
Hello!

On Fri, May 8, 2015 at 3:15 AM, David Birdsong wrote:
>
> i scour cloudflare's github page frequently, but will you post it here on
> the list when it comes out?
>

Yes, sure. There will be an announcement here when the balancer_by_lua
thing is opensourced.

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages