Subject: How can we make more use of memory for TCP properly?

From: Kumiko Ono <[email-masked]>
Date: Tue, 13 Jun 2006 17:46:34 -0400

Hi all,

Although I tried to find similar topics in the maling list, I found no 
useful clue. If I overlooked, please let me know the pointer.

I need to increase the value of sysctl_tcp_mem[2] that limit the total 
amount of memory allocated for TCP in order to maintain a number of 
simultateous TCP connections at a server, especially as a TCP server, 
like a web server.

Accorting to TCP man page, the kernel calculates the values of 
sysctl_tcp_mem depending on available physical memory at boot time.
I added 2GB RAM to a machine that had 2GB, and then it has 4GB RAM now. 
However, the value of sysctl_tcp_mem[2] has not changed from 196608 
(pages). The machine is running at Linux 2.6.16.5 i686 Intel(R) 
Pentium(R) 4 CPU 3.06GHz.

When looking through the tcp_init() in tcp.c, I found the value are 
determined with the tcp bind hash size, which reaches a upper cap of 
65536. I understand this upper cap is derived from the maximum of local 
port numbers, which are related to the behavior of TCP client, not that 
of TCP server.

When I manually increased the sysctl_tcp_mem to the double, 393216, and 
tried to establish over 30K TCP connections, the server hung up without 
any error messages of syslog.

Could anbody tell me how to make more use of memory for TCP connections 
properly, without replacing the machine to 64-bit arch.?

Regards,
Kumiko