KeepAlive – On or off?


Doing a quick install of wpmu on a server for someone. Sitting here looking at a top and noticed that all the httpd child processes are still running, even though nothing is happening with the site. A quick question to the folks who do our tech support gives me back a "We set KeepAlive to off as a default on your boxes".

I can see it as a plus if one would leave the processes running if this was the only processes running on the VPS.

A quick google shows me this as well.

Anyone else care to weigh in? Looking at a CentOS with I believe 256 megs. Running currently 151 megs used but with nothing really happening. (Again the site isn’t active.) A top shows mostly httpd’s taking up the memory although none of them are causing and processor usage.

edit: Hmmm, While I was writing that, I was waiting for a updatedb to run so I could run a locate and find the httpd.conf file. KeepAlive is off with a max time of 15 seconds. I think I’ll have to debug this but I’ll leave this here is anyone else wants to weigh in on leaving it on or off.

  • Ovidiu
    • Code Wrangler

    well, first of all it can’t be off with max 15 – its either off or on with 15s :slight_smile:

    ok, enought of being a smartass, to my knowledge keepalive is defined as:

    Essentially KeepAlive keeps each listening connection alive for a short time to receive a potential followup request. Assuming that a client wishes to make several requests to your server it can do so en masse without having to make multiple distinct connections.

    A possible solution here is to allow KeepAlive, but only for a few seconds. This means that any client which requests another page quickly will receive it, but if it doesn’t then the listening will stop – allowing your server to handle another connection instead.

    I guess its up to you to find the balance, i.e. does the site receive so many visitors that having keepalive on does make sense?

    Maybe lower the keealive timeout setting? lower it from 15s to i.e. 10 and make some tests. Go visit a page with a lot of objects on it, i.e. a picture gallery and see if all elements load or if you get timeout errors.

  • Barry
    • DEV MAN’s Mascot

    I’m running nginx on a new server (512megs) and with Keep alive on, Monit kept informing me that my php processes were constantly eating up all available memory and needed to be shut down and restarted.

    So I switched it off over the weekend and Monit has been quiet ever since. If anything the sites seem more responsive than before.

    But that’s from a definitely "non-expert" point of view.

  • Ovidiu
    • Code Wrangler

    well, not necessarily upgrade, but I’d have another look at your children or worker settings. how many are run at startup, etc,etc. whats the max number of children/workers?

    mod_Php has the drawback you must chmod folders 777 to be able to update / isntall new stuff while running suPhp or fastCGI + suexec gives you the option to change the owner/group the webserver is running as making it more safer to share a server with other sites (which might be a bad idea if you are running modphp and have done a chmod 777)

    but fastCGI is usually not recommended (depending on how many instances are running at the same time) for low volume sites…

  • Barry
    • DEV MAN’s Mascot

    but fastCGI is usually not recommended (depending on how many instances are running at the same time) for low volume sites…

    Well, here’s hoping for a high volume site :slight_smile:, that’s the intention anyway :slight_smile:

  • drmike
    • DEV MAN’s Mascot

    OK, getting out of memory errors by the ton and nasty notes from the vps admin about using burstable memory all of the time. I did some more googling and came across this:

    This is now our prefork settings:

    <IfModule prefork.c>

    StartServers 3

    MinSpareServers 3

    MaxSpareServers 3

    ServerLimit 50

    MaxClients 50

    MaxRequestsPerChild 1000


    Regular timeout got lowered to 6 I believe from 12 as well,.

    any other ideas?

  • Ovidiu
    • Code Wrangler


    if you have a look at top, how big are your apache processes?

    I am asking because your max is 50, so i.e. if your apache processes are an average of 15MB that would mean a max usage of 50*15=750MB!!!

    And seeing you have a max of 256MB available, the rest would either be swapped out and thus slowing down your server like hell or being processed in burst memory…

    I don’t know the rules of your burst memory and its availability, but if I were you I’d lower the max to something more reasonable…

    Keep in mind your server also runs mysql and possibly also acts as an email server? Anyway, other processes also need ram so don’t give evrything to apache .-)

  • drmike
    • DEV MAN’s Mascot

    Yup, thought of that this weekend. Thanks. Project is kind of a three way triangle and I have little access. And there’s no swap file. Not sure why. I did ask about it previously and got back a "It’s not needed" for this project.

    I think as soon as it’s setup, I’ll sneak out of there.



  • drmike
    • DEV MAN’s Mascot

    Had a thought: Since this is a VPS, would it be worth it to install memcache or a different caching program? Already running wp-super-cache in half mode.

    Any suggestions for that?

    Sitting at about 61 megs used right now. Have content to add in later this afternoon after a proofread.

  • Ovidiu
    • Code Wrangler

    I think memcache is a size too big, but it depends on what you expect this wpmu install to be hit with.

    I personally am a eaccelerator fan.

    there is a wordpress object cache plugin out there I can recommend: and a modified wp-suepr cache that uses eaccelerator as the back end:

    but usually you’ll do just fine with donncha’s suepr cache plugin.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.