Hi, On Tue, May 25, 2010 at 11:00:36AM +1200, Srdan Dukic wrote: > Hi, > > I've setup HAProxy (version 1.3.15.2 from repo's) on Debian to load balance > requests to a bunch of Windows web services running on IIS7. My problem is > that after load testing the system, Windows runs out of sockets as they all > end up in the TCP TIME_WAIT state.
Could you please recheck the state on the server ? I don't believe a minute that it runs "out of sockets" if they are in TIME_WAIT state because TIME_WAIT is a final state without data and the socket does not exist anymore in the process which previously hold it. You can easily have millions of them, they are harmless. OK this is Windows, but their TCP stack is not *that* bad. What may happen however is that if you stop and restart the service, then it cannot bind because of "address already in use", but I hope that IIS developers have handled this very common issue. > (Nice explanation of this TCP state found here: > http://blog.zhuzhaoyuan.com/2009/03/a-word-on-time_wait-and-close_wait/) > > When removing the load balancer and having the requests go directly to the > web server there are only a maximum of 10 sockets in the TIME_WAIT state at > any one time. This is because when you connect directly, you maintain the connections for as long as possible, while via haproxy they are closed after every exchange. > It seems like there's some error in communication between HAProxy and > Windows/IIS7 where the sockets aren't closed properly. In fact it's the opposite. If you see them in the TIME_WAIT state, then they are properly closed. How did you conclude that Windows ran out of sockets ? Just because you can't connect anymore ? Are you sure you don't have iptables loaded on your load balancer, which would have its state stable filled after a few thousand tests and which would refuse to let new connections pass ? Regards, Willy