Jump to content

Keep alive


Recommended Posts

A few months ago I moved onto a more powerful server. I made the move in mind that my website can get fairly busy, sometimes reaching 1,500 members during a 30 minute period. I've noticed my site performs slightly better when keep alive is enabled, however, this is only the case until my site gets busy. Once I'm averaging say 250-300 users per 5 minutes or less, the site grinds to a halt. Thats until I turn keep alive off.. I then notice pages load fine and the site can handle 1,500 with no problem at all once keep-alive is off. That leads me to suspect keep alive isn't set up correctly... would the server limit and max clients numbers be causing these issues? They are only set to the default right now.. Start Servers 5 Minimum Spare Servers 5 Maximum Spare Servers 10 Server Limit 256 Max Clients 150 Max Requests Per Child 10000 Keep-Alive On Keep-Alive Timeout 15 Max Keep-Alive Requests Unlimited (I edited this from 100, to see if it'd help, it didn't) Timeout 300 Is keep alive set up correctly for a busy site? If not can someone advise what I should alter.

Link to comment
Share on other sites

What does the keep-alive timeout mean?

If I set it to 2, does that mean after 2 seconds the next click will be a new connection. What benefit is there of having it enabled with a timeout of 2, instead of off altogether?

Sorry I don't know alot about it :P

Link to comment
Share on other sites

Well, Its exactly what it says on the tin.. If you enable keep alive, It means it will keep that connection open for a set amount of time meaning they dont have to force a re connect if they visit again, It can be good for latency.

It can speed things up but can become a hog if the server is very busy depending on the setup. Having it on with apache DSO would be like removing a tail from a fish.

Link to comment
Share on other sites

So if it set keep alive timeout to 2 seconds, it keeps the connection open for 2 seconds? I haven't set it that low before because I didn't think it would be much use if that was the case..

My server uses apache but FastCGI not DSO.

Link to comment
Share on other sites

Um... really sorry for going off topic, but starting with off topic...

GARY!! YOU ARE!!! NOT YOUR!!!

I'm sorry, I was going to forgive given on mobile and all... but it was twice. Just bugging the crap out of me.

On topic...

Keep alive has a good and bad, it depends on the situation. And from what it looks like, I might recommend you to keep it (keep alive) off.

Keep alive is great if there are many small quick things. Imagine sending 100 tiny things. Then keepalive is great b/c it doesn't need to create 100 new connections. But like Gary said, keepalive on heavy things like php (dso - optimized for php) are actually really bad. Because keepalive has a blocking property. It does not release it's resources in the event that the client comes back. So if you have heavy things and keepalive is on, you waste huge amounts of resources that could have been spent serving other clients. Another issue comes with keepalive if you have a high count of unique users. Then we just simply hoard lot of resources for a long time.

So, rule of thumb is:

heavy and/or few (like php): off

light and/or many (like simple images): on

site is too busy?: off

Obvious problem is that there's only 1 setting rolleyes.gif and both usages. /gg?

Solution? Well, we can separate those usages. And that's where stuff like nginx comes in. Serve static with nginx, apache/mod_php can do the processing. Or for a non-self solution, stuff like CDN to handle the statics rather than yourself. Then there are more complicated solutions like load balancing with special rules too (but we can safely ignore that for now).

Now onto values of keep alive.

Values like 2 seconds are actually good enough because when you load a page, all the images, css, js, etc are requested in sequence very fast. often lot less than 1 second unless something is blocking. Values like 15 are obviously safer, but the problem I mentioned becomes drastic when the values become too high. The user's actual clicking of "next page" rarely benefits from keep-alive because there's just too much of the time gap.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...