Russ Thompson on 17 Jan 2012 12:49:10 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Tuning Apache/PHP memory use...


Paul,

Is Apache currently exhaustion of all physical memory?  Honestly going in the route of caching is very desirable, assuming you have some memory to spare.  Apache has built in caching through modules (afaik) mod_mem_cache and mod_disk_cache.  However the preferred method is generally Squid or Varnish.  It will certainly improve load times and performance.

I'm also not familiar with your application, so it's a bit difficult to judge.

Here is a script I'm developing (functional) on Github that provides detailed information regarding Apache usage (by reading the /proc file system and using awk to translate the data).  It's a simple bash script with some awk mixed in.  It will provide information about memory, IO etc.

https://github.com/vigeek/Apache-Statistics/blob/master/apstat.sh

If all physical memory is exausted, then adjusting the vm.swappiness won't help much.  Are you using innoDB storage engine? If so what is your innodb buffer size?

-Russ


On Tue, Jan 17, 2012 at 3:39 PM, Paul Walker <starsinmypockets@gmail.com> wrote:
I'm running ubuntu 10.04...

nginX is tempting but, given the burden of migration, I'll probably look for other solutions first... 

How can I determine what swapiness is ideal (as currently, Apache is exhausting all available memory)?

On Tue, Jan 17, 2012 at 3:34 PM, Russ Thompson <vigornj@gmail.com> wrote:
Paul,

Which flavor of Linux are you running?

I tend to dislike swappiness @ 60 (default), I prefer it to favor memory heavily therefore set this to 0-20 depending on the application.

-Russ


On Tue, Jan 17, 2012 at 3:32 PM, Paul Walker <starsinmypockets@gmail.com> wrote:
The swappiness is set at 60.


On Tue, Jan 17, 2012 at 3:30 PM, Russ Thompson <vigornj@gmail.com> wrote:
Paul,

The value's in mySQL should be tuned based on real world results, the problem today is there are too many copy and paste my.cnf configurations floating around.  Those values should be tuned based on the output from 'show global status' you can wildcard as well such as 'show global status like '%cache%'.  I typically look at those numbers and calculate cache hit rates, then adjust accordingly.

What is your VM swappiness set to? sysctl -a | grep -i swappi

Varnish works particularly well for Caching.  I'm personally not a fan of using Apache at all for PHP, if you're using PHP nginX is the way to go.  This is a very popular trend with many PHP shops migrating to nginX.

-Russ

On Tue, Jan 17, 2012 at 3:24 PM, Paul Walker <starsinmypockets@gmail.com> wrote:
I'm running a linode VPS that's serving about 8-10 medium/low traffic Drupal sites via Apache 2.2.  I'm running into a memory bottleneck: Apache opens ~8 running processes that each swell to nearly 100MB of (virtual) memory each; stuff starts getting swapped to the swapdisk, and everything grinds to a halt. I've set the mysql and apache settings to those recommended by the linode faq: 

mysql
key_buffer = 16K
max_allowed_packet = 1M
thread_stack = 64K
table_cache = 4
sort_buffer = 64K
net_buffer_length = 2K
Apache
StartServers 1
MinSpareServers 3
MaxSpareServers 6
ServerLimit 24
MaxClients 24
MaxRequestsPerChild 3000
I'm thinking that I may need to institute some sort of caching so that Apache is serving static pages and not calling the PHP scripts on every request, but I'm not sure what strategy is here. Has anyone come up with a good strategy for limiting Apache and PHPs memory usage in a similar situation?

Any help appreciated!

Paul


___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug



___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug



___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug



___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug



___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug


___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug