Apache – Apache Uses Up a Lot of CPU for Small Website

apache-2.2centostop

I have a CentOS 5.5 VPS server with 512MB RAM setup.

There is 1 website hosted on it through Apache/PHP/MySQL which is built in Magento, a popular ecommerce framework.

When I browse the website, it takes about 10 seconds to load and running top shows me the following:

I understand that Magento is a relatively heavy piece of software and it does a lot of processing, but this is ridiculous for one website.

It's not yet launched but my concern is when it does and a few people browse the homepage at the same time, it could cause problems.

I am not a server guy so don't really know what to do in terms of configuration. 512MB of RAM should be plenty to run this 1 website.

My Apache config is below, any suggestions would be great!

Timeout 120
KeepAlive Off
StartServers       2
MinSpareServers    2
MaxSpareServers    7
ServerLimit       25
MaxClients        25
MaxRequestsPerChild  500

Best Answer

Its fairly obvious where your first bottleneck is there. Look at your TOP output, specifically 8.7%wa - you are I/O bound. So what you think is CPU usage, is your HDDs struggling to serve up data fast enough.

This is extremely typical of a VPS where IO is a shared resource, so someone else's activity is going to severely impact your performance.

Magento isn't big and slow and can perform just as well as any other web app - but if your server is slow, then it certainly isn't going to help.

Have a read through this http://s.onas.si/xg4h for some tips on configuraton

But the other answers are correct that whilst you can still have fast page load times with 1 user, you almost certainly will not with any number higher than that.

I wrote a pretty good breakdown on how Magento will behave on a VPS here https://serverfault.com/a/367861/113375