3

We have an issue with a dedicated server load.

We have 16 processors with 4 core @ 2.40GHz, if I understood correctly cat /proc/cpuinfo output.

Unfortunately, I don't have access to free -m or vmstat.

But from top I got that we have 24 GB.

And snapshot from top about processes: Top

As far as I see, memory is not used at all. But the cpu is used heavily. Apache consumes most of CPU.

Another useful piece of information:

Every 1.0s: ps u -C httpd,mysqld,php                                                                                                                                                                                                                                                                                                           Tue Mar 27 10:48:19 2012

USER         PID %CPU %MEM    VSZ   RSS TTY  STAT START   TIME COMMAND
root        7476  0.0  0.1 446808 37880 ?        SNs  Mar06   0:43 /opt/zone/sbin/httpd -D SSL -D SLOT_ID0 -f /etc/opt/zone/apache/ssl_httpd.conf
mysql      36061 41.6  2.1 1113672 529876 ?  SNl  Feb20 21503:48 /opt/zone/sbin/mysqld --basedir=/opt/zone --datadir=/srvdata/mysql --user=mysql --log-error=/srvdata/mysql/dn79.err --pid-file=/srvdata/mysql/mysqld.pid --socket=/tmp/mysql.sock --port=3306
root       37257  0.0  0.0 424056 16840 ?        SNs  Mar22   1:03 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       52743  0.0  0.1 447100 30360 ?        SN   10:40   0:00 /opt/zone/sbin/httpd -D SSL -D SLOT_ID0 -f /etc/opt/zone/apache/ssl_httpd.conf
http       52744  0.0  0.1 447100 30360 ?        SN   10:40   0:00 /opt/zone/sbin/httpd -D SSL -D SLOT_ID0 -f /etc/opt/zone/apache/ssl_httpd.conf
http       52745  0.0  0.1 447100 30360 ?        SN   10:40   0:00 /opt/zone/sbin/httpd -D SSL -D SLOT_ID0 -f /etc/opt/zone/apache/ssl_httpd.conf
http       52746  0.0  0.1 447100 30360 ?        SN   10:40   0:00 /opt/zone/sbin/httpd -D SSL -D SLOT_ID0 -f /etc/opt/zone/apache/ssl_httpd.conf
http       52747  0.0  0.1 446956 30324 ?        SN   10:40   0:00 /opt/zone/sbin/httpd -D SSL -D SLOT_ID0 -f /etc/opt/zone/apache/ssl_httpd.conf
http       52980 69.1  1.8 852468 458088 ?   RN   10:41   5:02 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       53483 47.0  0.8 615088 221040 ?       RN   10:43   2:05 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       53641  1.8  0.2 446580 54632 ?        SN   10:45   0:03 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54384 81.2  0.9 625828 229972 ?       RN   10:45   2:14 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54411 47.7  0.5 535992 142416 ?       RN   10:45   1:09 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54470 41.7  0.4 512528 120012 ?       RN   10:46   0:54 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54475  0.1  0.1 437016 41528 ?        SN   10:46   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54486  1.5  0.2 445636 53916 ?        SN   10:46   0:02 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54531  2.5  0.2 445424 53012 ?        SN   10:46   0:02 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54549  0.0  0.0 424188  9188 ?        SN   10:46   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54642  0.0  0.0 424188  9200 ?        SN   10:47   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54651  0.0  0.0 424188  9188 ?        SN   10:47   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54661  0.0  0.0 424188  9208 ?        SN   10:47   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54663  6.9  0.2 449936 58560 ?        SN   10:47   0:03 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54666  6.0  0.2 453356 61124 ?        SN   10:47   0:02 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54667  2.8  0.1 437608 42088 ?        SN   10:47   0:01 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54670  1.5  0.1 437540 42172 ?        SN   10:47   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54672  2.1  0.1 439076 43648 ?        SN   10:47   0:01 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54709  0.0  0.0 424188  9192 ?        SN   10:47   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54711  1.0  0.1 437284 41780 ?        SN   10:47   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54712 11.8  0.2 448172 54700 ?        SN   10:47   0:02 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54720  0.0  0.0 424188  9192 ?        SN   10:48   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54721  0.0  0.0 424188  9188 ?        SN   10:48   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54747  9.1  0.2 443568 51848 ?        SN   10:48   0:01 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54782  1.8  0.1 438708 37896 ?        RN   10:48   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54784  0.0  0.0 424188  9180 ?        SN   10:48   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54785  0.0  0.0 424188  9188 ?        SN   10:48   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54789  0.0  0.0 424188  9188 ?        SN   10:48   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54790  0.0  0.0 424188  9188 ?        SN   10:48   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54791  0.0  0.0 424188  9188 ?        SN   10:48   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0
http       54792  0.0  0.0 424056  8352 ?        SN   10:48   0:00 /opt/zone/sbin/httpd -f /etc/opt/zone/apache/httpd.conf -D SLOT_ID0

Webalizer shows following: Webalizer

What can be done in the following situation? The application is Magento.

Jevgeni Smirnov
  • 492
  • 1
  • 6
  • 22
  • Do you have APC installed? If not, that will make a big difference. After that, if I remember correctly, Magento likes having a caching reverse proxy in front of it. Check what caching headers it is supplying before you implement that. – Ladadadada Mar 27 '12 at 07:58
  • I think you have 4 processors each with 4 cores giving 16 cores total? – Jeff Ferland Mar 27 '12 at 14:23

4 Answers4

5

You are barking up the wrong tree. Seemingly it's Apache consuming the CPU; in reality there's mod_php which has to serve your Magento pages.

And the latter is your answer: Magento sure is a heavy beast. Don't try to optimize Apache at this point, concentrate on your Magento setup. Do not disappoint if you don't succeed. Many have tried that in Server Fault, not many have succeeded (from what I have seen). A heavy piece of software is a heavy piece of software.

Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78
  • I will try to profile the php code then. – Jevgeni Smirnov Mar 27 '12 at 08:14
  • mod_php is the very worst way to run Magento. It turns Apache into a very inefficient php interpreter, hogging memory and processor cycles. If you must run Apache, then fastCGI is a must in a high load environment as it runs the PHP interpreter as a separate process. Another way out is to move using LiteSpeed and lsphp5. Either method returns the httpd server to doing what it does best, serving out files. You will also need to run APC cache or similar and get a full page caching module if you want Magento to really function well. Don't waste your time till the server is properly configured. – Fiasco Labs Mar 27 '12 at 15:29
  • FastCGI and FPC. Ok, TY; – Jevgeni Smirnov Mar 28 '12 at 05:15
1

In addition to Janne Pikkarainens answer, I'd like to suggest the following:

  • use tmpfs on magento cache folder
  • Make sure all magento caching is enabled (html, xml etc etc)
  • store sessions on tmpfs unless you have multiple backends
  • use apc as fast_backend (and optionally memcached as slow_backend)
  • consider using varnish to cache some or part of pages.

More on Varnish and magento:

Commercial Varnish plugin that use ESI and another solution using AJAX calls.

3molo
  • 4,340
  • 5
  • 30
  • 46
0

Do you have APC installed? If not, that will make a big difference.

After that, if I remember correctly, Magento likes having a caching reverse proxy in front of it. Check what caching headers it is supplying before you implement that.

Ladadadada
  • 25,847
  • 7
  • 57
  • 90
0

Find whoever configured the server and shoot them?

HTTP tuning would fill a large book. But looking at the information you've provided...

Big iron is a waste of time and money for webservers - you get much better performance / availability / value from multiple low-end machines.

Why is httpd running at an abnormally high scheduling priority? Why is your ssh session running at a lower priority than the sshd?

You're apache processes look as if they have a rather large footprint - have you stripped out the modules you're not using? However it looks like your biggest problem is the amount of CPU being used by Apache - PHP likes CPU. And magento is particularly CPU hungry.

However really the load isn't too bad considering the amount of hardware you've got. Yuo say you've got 16x4 processors, but the top screenshots only shows 6 processes using a significant amount of CPU. Are you trying to reduce the load or increase the performance? Front end or back end?

Putting a reverse proxy in front of Apache will help with performance (assuming you've got caching and compression setup correctly for the content) - IMHO Varnish or nginx are very effective. Both provide ESI support - but you'll need some changes to Magento to support this. In addition to handling the serving of static content with less effort, the proxy can free up the httpd resource sooner and complete the process of sending the page across the network with less effort.

Where are you storing your session data? If it's the default handler then you might want to move this onto memcache (the couchbase implementation has a number of technical advantages).

Check your APC stats to make sure it's got enough memory to cache the majority of the code.

symcbean
  • 19,931
  • 1
  • 29
  • 49
  • All the stuff you say is very sensible, but just for lulz try sometimes to install Magento + XDebug and run the profiled page loads to KCacheGrind or similar software. See how heavy Magento is. Then see how essential it is to have frontend-proxies and at the same time cry how when you realize you can't cache most of the requests at all, since this is very dynamic stuff. – Janne Pikkarainen Mar 27 '12 at 11:26
  • Janne: Unless using the proposed ESI or AJAX approaches. – 3molo Mar 27 '12 at 12:15
  • Them who's never run Magento don't understand its need for heavy iron especially once you break the 8000 product level. Server optimization (mysql/httpd) only goes so far and in the case of Magento, it's what you do after putting it on a 4 core system with what would be considered to be too much memory for any other php app. – Fiasco Labs Mar 27 '12 at 15:32
  • @Janne: please explain how to make a single PHP script run on more than CPU – symcbean Mar 28 '12 at 08:39