I wrote a module for nginx 4 years ago which limited the number of
connections to upstream in order that the upstream servers would not be
too
busy to work efficiently. Now I think this module is stable, and expect
it
to be merged into nginx official if possible.
the code is here:
GitHub - cfsego/nginx-limit-upstream: limit the number of connections to upstream for NGINX
https://github.com/cfsego/nginx-limit-upstream
sincerely
Hi Chuanwen
Your module did not quite work for me. I opened up a ticket here.
opened 02:59AM - 20 Jun 16 UTC
closed 02:59AM - 26 Sep 16 UTC
When compiling with OpenResty 1.9.15.1 there is the following error
```
/home/… ubuntu/nginx-limit-upstream/ngx_http_qos_module.c: In function ‘ngx_http_limit_upstream_cleanup’:
/home/ubuntu/nginx-limit-upstream/ngx_http_qos_module.c:367:9: warning: implicit declaration of function ‘ngx_http_upstream_connect’ [-Wimplicit-function-declaration]
ngx_http_upstream_connect(ctx->r, ctx->r->upstream);
^
/home/ubuntu/nginx-limit-upstream/ngx_http_qos_module.c: In function ‘ngx_http_limit_upstream_get_peer’:
/home/ubuntu/nginx-limit-upstream/ngx_http_qos_module.c:411:25: error: ‘ngx_http_upstream_t’ has no member named ‘blocked’
if (ctx->r->upstream->blocked) {
^
/home/ubuntu/nginx-limit-upstream/ngx_http_qos_module.c:413:25: error: ‘ngx_http_upstream_t’ has no member named ‘blocked’
ctx->r->upstream->blocked = 0;
^
/home/ubuntu/nginx-limit-upstream/ngx_http_qos_module.c:607:25: error: ‘ngx_http_upstream_t’ has no member named ‘blocked’
ctx->r->upstream->blocked = 1;
^
/home/ubuntu/nginx-limit-upstream/ngx_http_qos_module.c:609:16: error: ‘NGX_BLOCK’ undeclared (first use in this function)
return NGX_BLOCK;
^
/home/ubuntu/nginx-limit-upstream/ngx_http_qos_module.c:609:16: note: each undeclared identifier is reported only once for each function it appears in
/home/ubuntu/nginx-limit-upstream/ngx_http_qos_module.c: In function ‘ngx_http_limit_upstream_init_peer’:
/home/ubuntu/nginx-limit-upstream/ngx_http_qos_module.c:684:16: error: ‘ngx_http_upstream_t’ has no member named ‘blocked’
r->upstream->blocked = 0;
^
make[2]: *** [objs/addon/nginx-limit-upstream/ngx_http_qos_module.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/home/ubuntu/openresty/openresty-1.9.15.1/build/nginx-1.9.15'
make[1]: *** [build] Error 2
make[1]: Leaving director
```
Posted at Nginx Forum: