1

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
fire
  • 113
  • 1
  • 2
  • 5

4 Answers4

2

Magento is a resource hog. If you don't have all of magento's caching turning on it will be slow on a server with 5x those specs.

So make sure you enable all the caching.

Also magento is a memory hog even when caching is turning on so you might be lucky to get 5 concurrent connections with 512meg of ram.

I was a sys admin for a company that started with magento and then built their own solution cause it was cheaper to build our own platform then use magento and toss hardware at it to scale.

Mike
  • 21,910
  • 7
  • 55
  • 79
1

Depending on how your Apache/PHP setup is arrnaged, it will be PHP code that is taking the CPU time not Apache itself (if you run via modPHP then PHP's CPU use is counted in Apache's, if you ust CGI/FastCGI PHP process should be listed seperately in top's output).

I know nothing of Magento (their support routes would be a better place to ask for help specific to their scripts) is it possible there is some misconfiguration that is causing it to try do far too much work - double check the documentation to see if it has any hints about optimising CPU use.

It could be that it is running a once-every-now-and-again task that precumputes a pile of stuff which it then caches for later use, in which case the problem may not be present in later requests.

It could also be that your VPS is overloaded CPU-wise, so what would take a second or less given dedicated access to a CPu core could be taking 10 because your VPS is fighting with others for use of the CPU. I've seen many VMs crammed onto one dual core machine whcih is fine when most of the VMs are relatively CPU-idle (which is common with web/sql machines, as they spend most of their time waiting for network or disk I/O rather than doing busy work with the CPU, but far from always the case).

Have you tried comparing the performance on a copy of the install running a VM on one of your own machines? If it performs well there than it woudl indicate something is underspecified with your VPS, if it is slow on your (presumably otherwise unloaded) local VM then the problem is more likey to be fuond in the scripts or their configuration. You could also try run a simple CPU benchmark to see if the VM is "CPU-slow" - I suggest a single process single threaded test as it looks like what-ever is keeping Apache busy is one process/thread (overall vCPU use being a 10-20% depending what you count while that Apache process is listed at ~80% inplied it is using one virtual CPU and the rest are more-or-less idle).

David Spillett
  • 22,534
  • 42
  • 66
1

Your apache config places rather sever limits on the amount of traffic this site will handle.

As Mike says, Magento is very big and slow.

Since it's httpd using up the CPU, I presume that PHP is running as mod_php. Make sure you're allowing plenty of memory for the PHP to run, and use an opcode cache. Also make sure you're doing all the usual stuff for tuning your application.

symcbean
  • 19,931
  • 1
  • 29
  • 49
  • I have now installed APC cache and it's still running slow. How would I assign more memory to PHP specifically? – fire Jan 26 '12 at 16:40
1

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

Ben Lessani
  • 5,174
  • 16
  • 37