# Nginx as remote proxy - limit number of concurrent connections?

**URL:** <https://www.ruby-forum.com/t/nginx-as-remote-proxy-limit-number-of-concurrent-connections/218486>\
**Category:** NGINX\
**Created:** [April 2, 2012, 11:51am UTC](https://www.ruby-forum.com/t/nginx-as-remote-proxy-limit-number-of-concurrent-connections/218486 "2012-04-02T11:51:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 2, 2012, 11:51am UTC](https://www.ruby-forum.com/t/nginx-as-remote-proxy-limit-number-of-concurrent-connections/218486/1 "2012-04-02T11:51:30Z")

</div>

I’m using nginx as a remote proxy server in front of a bunch of Tomcat  
instances, and occasionally I’m running into a situation where all  
available threads are used up in the Tomcat instances, which causes  
various problems. Rather than trying to deal with these problems in that  
layer, I was wondering about preventing the situation from arising by  
limiting the number of concurrent connections to the upstream servers in  
nginx. I’m not entirely sure how to do this, but I have no doubt it’s  
doable. Suggestions, please!

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [April 2, 2012, 11:54am UTC](https://www.ruby-forum.com/t/nginx-as-remote-proxy-limit-number-of-concurrent-connections/218486/2 "2012-04-02T11:54:36Z")

</div>

> I’m using nginx as a remote proxy server in front of a bunch of Tomcat  
> instances, and occasionally I’m running into a situation where all  
> available threads are used up in the Tomcat instances, which causes  
> various problems. Rather than trying to deal with these problems in that  
> layer, I was wondering about preventing the situation from arising by  
> limiting the number of concurrent connections to the upstream servers in  
> nginx. I’m not entirely sure how to do this, but I have no doubt it’s  
> doable. Suggestions, please!

Try this: [http://nginx.localdomain.pl/wiki/UpstreamFair](http://nginx.localdomain.pl/wiki/UpstreamFair)

with the weight\_mode=peak option.

–appa
