Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Nov 10, 2010 9:28 pm 
Offline
Senior Member

Joined: Wed Jul 21, 2010 8:04 pm
Posts: 119
What do you guys do about KeepAlive?

I'm using Apache on a Ubuntu 10.04 LTS VPS with 512mb of memory. My website gets a fair amount of hits. Some requests involve multiple files too -- the PHP file, and related image, CSS, and/or Javascript files. I'm trying to maximize performance so I can get the most bang for my buck, and delay upgrading to a larger Linode.

In a situation like this, what do you guys do (enable or disable KeepAlive?), and what do you recommend?


Top
   
 Post subject:
PostPosted: Wed Nov 10, 2010 9:56 pm 
Offline
Junior Member

Joined: Tue Jul 13, 2010 8:28 pm
Posts: 28
The usual rule of thumb is not to have keepalive. The idea is if you have a connection open to a client and you're not sending anything, that's wasted resources. This isn't the general consensus though, some people do argue for it - although even in that case they'll tweak it down to some optimal level.

In the end, it really depends on your situation. You really should look at your traffic and adjust for that.

Also, have you tried caching? That's usually the first thing to do and generally gives the greatest return.


Top
   
 Post subject:
PostPosted: Wed Nov 10, 2010 9:59 pm 
Offline
Junior Member

Joined: Sat Mar 21, 2009 3:45 am
Posts: 48
Apache gets a worse rap that it deserves for memory consumption. That said, it isn't as memory efficient as it should be.

First, if you are running mod_php, then every worker carries memory overhead of having it loaded, whether the request is for a static file, or not.

Second, whether a request is for a static file or a dynamic page, the worker that processed the request is occupied until all the data is sent to the client.

These two issues are combined and aggravated when using keep-alives.

I think the simplest solution: Continue using apache, it works, its well understood, but let it spend its time and memory on servicing requests, rather than feeding data back out to clients. The way you do this is to put nginx on port 80 on your public IP, apache on localhost, and then set nginx to reverse proxy to apache and enable buffering of results.

You can try and set nginx up to handle requests for static files, and only proxy dynamic requests to apache, but I don't think its worth it.


Top
   
 Post subject:
PostPosted: Thu Nov 11, 2010 1:22 am 
Offline
Senior Member

Joined: Wed Jul 21, 2010 8:04 pm
Posts: 119
I haven't tried caching. I don't know that it would work with my site. Stall results would be very bad given its nature.


Top
   
 Post subject:
PostPosted: Thu Nov 11, 2010 10:59 am 
Online
Senior Member

Joined: Fri Jan 09, 2009 5:32 pm
Posts: 634
I leave it on, but turn down MaxKeepAliveRequests and KeepAliveTimeout


Top
   
 Post subject:
PostPosted: Thu Nov 11, 2010 12:25 pm 
Offline
Senior Member
User avatar

Joined: Tue Nov 24, 2009 1:59 pm
Posts: 362
eas wrote:
First, if you are running mod_php, then every worker carries memory overhead of having it loaded, whether the request is for a static file, or not.

Second, whether a request is for a static file or a dynamic page, the worker that processed the request is occupied until all the data is sent to the client.

These two issues are combined and aggravated when using keep-alives.

I think the simplest solution: Continue using apache

... but switch from mpm_prefork + mod_php to mpm_worker + mod_fastcgi (NOT fcgid!) and have for example a hundred worker threads and PHP_FCGI_CHILDREN=25. This way you have only one webserver to worry about.

_________________
rsk, providing useless advice on the Internet since 2005.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group