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:
https://github.com/cfsego/nginx-limit-upstream
https://github.com/cfsego/nginx-limit-upstream
sincerely