TCP tuning for a server with very short HTTP connections
Hello everybody.
I run a server that currently handles about 25-30 HTTP requests per second and seems to have reached it's limit even though the CPU is 70% in IDLE.
The server is running Apache 2.2.3 on Debian 4 and 99% of the requests are routed through FastCGI to a dedicated process written in FreePascal. This process is handling dynamic requests with 30 threads. Requests are handled in about 50ms average.
The HTTP requests come from lots of different clients that maybe generate 5 requests and then aren't seen anymore.
That's why Apache's KeepAliveTimeout timeout is set to 2 seconds, as to avoid lots of unnecessary open connections.
Those 2 seconds seem to be a key point because consecutive requests within those 2 seconds are handled immediately, while requests after longer intervals take at least 5 seconds (the FastCGI process however reports only 4ms processing time!).
That makes me think that I have to do some TCP tuning of my Linux server or perhaps Apache because it seems to me that the server's connection limit or anything like that has been reached.
"netstat" shows about 2000 connection, about the half of them being in TIME_WAIT state.
I tried with "sysctl -w net/ipv4/tcp_max_orphans=500" but that didn't change anything.
Can somebody please give me some advice how to further analyze and perhaps improve the situation?
Lots of thanks in advance!
PS: CPU is an Athlon X2 Dual Core 5600+ running at 32bits.
|