# 5000 connections to backends in TIME\_WAIT state, nginx grows and starts swapping

**URL:** <https://www.ruby-forum.com/t/5000-connections-to-backends-in-time-wait-state-nginx-grows-and-starts-swapping/199887>\
**Category:** NGINX\
**Created:** [November 30, 2010, 9:25pm UTC](https://www.ruby-forum.com/t/5000-connections-to-backends-in-time-wait-state-nginx-grows-and-starts-swapping/199887 "2010-11-30T21:25:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 30, 2010, 9:25pm UTC](https://www.ruby-forum.com/t/5000-connections-to-backends-in-time-wait-state-nginx-grows-and-starts-swapping/199887/1 "2010-11-30T21:25:53Z")

</div>

Hi,

nginx version: nginx/0.7.67  
TLS SNI support enabled  
configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt=’-I  
/usr/local/include’ --with-ld-opt=’-L /usr/local/lib’  
–conf-path=/usr/local/etc/nginx/nginx.conf  
–sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid  
–error-log-path=/var/log/nginx-error.log --user=www --group=www  
–http-client-body-temp-path=/var/tmp/nginx/client\_body\_temp  
–http-proxy-temp-path=/var/tmp/nginx/proxy\_temp  
–http-fastcgi-temp-path=/var/tmp/nginx/fastcgi\_temp  
–http-log-path=/var/log/nginx-access.log  
–with-http\_gzip\_static\_module --with-http\_ssl\_module  
–with-http\_stub\_status\_module  
–add-module=/usr/ports/www/nginx/work/nginx\_upstream\_fair-20090923  
–add-module=/usr/ports/www/nginx/work/nginx\_upstream\_hash-0.3.1  
–with-pcre

I have two freebsd 8.0 servers using carp, nginx listens on the carp  
interface on both for high availability.

What I am seeing is that nginx opens 5,000 connections to the  
preferred back end. I have a backup back end declared, but prefer one.  
This causes nginx to grow in size, use a lot of swap, and die.

I’ve mitigated this by setting net.inet.tcp.keepidle=300000 on  
freebsd. The connections go away after 5 minutes.

It’s a pretty simple nginx.conf I use, and I’m not sure why I’m  
getting this behaviour. Should I simply upgrade my nginx to latest?

Thoughts appreciated.

* * *

Stefan C.  
cell: 416 561 4871  
Skype: stefan.caunter
