RE: [squid-users] Linux: Cannot bind to socket ...

From: NGUYEN, KHANH, ATTSI <nguyenkt@dont-contact.us>
Date: Tue, 27 Mar 2007 09:36:21 -0400

Hmm I did set /proc/sys/net/ipv4/ip_local_port_range to 1024 65000

I will look into how to manual assign port at the squid then.
Thanks,
Khanh


-----Original Message-----
From: Henrik Nordstrom [mailto:henrik@henriknordstrom.net]
Sent: Monday, March 26, 2007 6:29 PM
To: NGUYEN, KHANH, ATTSI
Cc: squid-users@squid-cache.org
Subject: Re: [squid-users] Linux: Cannot bind to socket ...


mån 2007-03-26 klockan 11:08 -0400 skrev NGUYEN, KHANH, ATTSI:

> I send a load of 4000-5000 request/second to the server. After about 5
> hours, the ability to serve 5000 requests drops and the cache.log is
> filled with error 'commBind: Cannot bind socket FD 204 to *:0: (98)
> Address already in use

You ran out of free ports, all ports occupied by open server connections
of TIME_WAIT sockets.

TCP is much better at accepting connections than making connections at
high rates. Making outgoing connections requires a free port, and the
port gets occupied for the lifetime of the connection + TIME_WAIT (2
minutes).

The port range used by the kernel is specified
in /proc/sys/net/ipv4/ip_local_port_range, and you You can safely use
1024 65535 which gives you 64.5K available ports which should be able to
sustain a constant load of 5K connections/s.

To go above that you need to either improve how the kernel assigns ports
to outgoing connections allowing it to make use of multiple IP
addresses, or modify Squid to "manually" assign the local ip:port
manually when making outgoing connections.

Another thing which significantly improves the situation is to make sure
you have support for persistent connections enabled in your backend
servers (and Squid). This significantly reduces the amount of
connections made by reusing server connections for multiple requests.

Regards
Henrik
Received on Tue Mar 27 2007 - 07:36:34 MDT

This archive was generated by hypermail pre-2.1.9 : Sat Mar 31 2007 - 13:00:02 MDT