100% CPU when doing 4 or more concurrent requests with Magento

Currently I'm having trouble with a server running Magento, it's unbelievably slow.

It's a VPS with a few Magento installations on it used for development, so I'm the only one using them. When I do 4 request all 2 seconds after each other I'm finished in 10 seconds. Slow, but still within the limits of my patience. When I do 4 "concurrent" requests, however (opening 4 tabs in a row, very quickly) all four cores go to 100% and stay there for like a minute.

How is this possible?

I know that there are a lot of possibilities here, so any tips on how to make an Apache/PHP server go faster are also welcome.

It used to go a lot faster before, and I've also tried APC, but it kept causing problems (PHP errors, something with memory pools) so I've disabled it.

By the way, the Magento cache is off and compiling is also off. I know this makes Magento slower than usual, but I don't think a 60 second response time is normal for any Magento installation.

Virtual hardware:
4 Cores and 4096MB RAM
Swap is never used (checked with htop) 100GB disk space, of which 10% is in use

Software:
Debian 6 DirectAdmin and apache custombuild PHP 5.2.17 (CLI)

If you need more info, please tell me how to get it, because I probably don't know how. I do know how to use the command line in linux and the usage of quite a few commands, but my experience with managing a server is limited.


Magento is horribly slow when you disable caching.. more so on a vps since it has to parse a ton of XML files. The way it renders a page makes it very easy to add new things all over the page but it also calls for some massive sql queries and also loading xml files.

So you disabling cache means magento has to read those xml files on every request coming in. So each process is now competing for cpu and disk IO. On a vps disk IO is where your bottle neck will be 90% of the time. So 4 concurrent processes all asking to read a lot of xml files causing a lot of CPU wait on the apache processes.

if you do a strace on one of the apache processes as it renders a page in magento you will see all the xml it has to render.

I haven't touched magento in over 2 years but it was a nightmare to run a site with traffic so my company at the time ended up building their own software.


Generally, it is recommended to follow 2x rule: 1 core = 2Gb RAM, 2 cores = 4Gb RAM, 4 cores = 8 Gb RAM. Yes, you said that swap was not used, but maybe increasing RAM is the option. Tip: To track CPU and Memory load history (not just current) I recommend using Performance Monitoring extension by PotatoCommerce.