Forum Moderators: phranque

Message Too Old, No Replies

What exactly is a connection?

How to tune Apache parameters for performance?

         

too much information

3:40 pm on Jun 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know this doesn't seem like a serious question but I'm starting to hit my limit on Apache Connections more frequently and when it happens it causes my collection of sites (three currently) to go down until I have the hosting company clear out my connections.

But what exactly is a connection? Is it one page hit, or one page hit plus a few seconds, or one connection for the page hit and one for each image hit?

What I'm trying to determine is if it's a fluke event that I can prevent in the future by reworking my content or if it means my traffic is reaching a level where I need to consider upgrading my hosting package.

jdMorgan

4:05 pm on Jun 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A connection is a TCP/IP connection -- This is separate and/or "above" page and image requests. These HTTP page/image requests are made using TCP/IP. Basically, HTTP is the Web protocol layer, and TCP/IP is the internet connection protocol.

An analogy is that you dial a client's phone number and he answers and says "Hello." this establishes a connection (TCP/IP). You then discuss a business contract, bartering back and forth (HTTP). If you then conclude your business dealings and begin to talk about playing golf next weekend, then the "TCP/IP connection" is a keep-alive connection, and you have used it to conduct two HTTP transactions (contract discussion and golf discussion). The alternative, if your phone system did not support keepalive, would be to hang up after discussing the business contract, and then call him right back to discuss golf.

OK, that analogy is a bit of a stretch, but I hope it illustrates the basic idea.

My first guess, based on your statement about having to have the host "clear" your connections is that you have set the timeout on persistent connections (keepalive) to a value that is too high/too long.

See the Apache core directives KeepAlive, KeepAliveTimeout, and MaxKeepAliveRequests. Shorten the timeout to half its current value and/or reduce MaxKeepAliveRequests slightly, and see if that helps.

Basically, a non-keepalive connection contains one HTTP request - One request for a page or an image, etc. If keepalive is enabled, then the connection persists and can be used for another page/image request once the initial request is satisfied. This eliminates the overhead of having to set up a new TCP/IP connection for each HTTP request, but leaves the connections active even after the entire page has finished loading. These persistent connections are then closed only after the timeout period. In some cases, they're left active for several minutes, which can be a real waste if your pages load fast and most of your visitors are using DSL, cable, or fast optical connections.

I'd suggest setting the keepalive timeout to no more than four times your average page load time, just to account for occasional internet slow-downs. However, there is no single "correct setting" and finding the right setting is largely a matter of experimentation and testing.

Jim

too much information

7:56 pm on Jun 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Awesome reply Jim! Thanks for the detail, it does explain quite a bit and it looks like I might need to upgrade my hosting to allow more simultaneous connections.

I've already had them cut my timeout twice now which I guess is good news because it means that my traffic is growing pretty well.

kamikaze Optimizer

1:47 pm on Jun 24, 2008 (gmt 0)

10+ Year Member



Hi JP: Using Apache/2.2.9 with cPanel, what file would I mod? httpd.conf does not seem to have any settings.

jdMorgan

6:20 pm on Jun 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



With cPanel, it's not likely that you're allowed this level of control... Sounds like a shared hosting set-up.

Apache httpd.conf can "include" other configuration files, such as conf.d, etc. You'll have to take a look around and see if you can find any such includes and the files that they refer to .

Jim

kamikaze Optimizer

7:31 pm on Jun 24, 2008 (gmt 0)

10+ Year Member



Thanks, I did find it in includes. I have root, I was only mentioning cPanel as the means in which it is configured.

This server is Apachi only, SQL is on another server which is cross connected.

I am looking for a way to maximise my hardware (2 dual core 3.2 xeons and 4GB Ram), as I am locking up Apachi when I max out connection.

Any suggestion here?

this is our current settings:

KeepAlive On
Timeout 15
MaxKeepAliveRequests 64
KeepAliveTimeout 15
StartServers 14
ServerLimit 650
MaxClients 600
MinSpareThreads 10
MaxSpareThreads 20
ThreadsPerChild 64
MaxRequestsPerChild 1000

Thanks

[edited by: kamikaze_Optimizer at 7:35 pm (utc) on June 24, 2008]