I'm very close to completing a large magento project and have turned my focus to improving magento's speed. As sort of a preface, I'm more of a front-end developer doing this large project in-house, and figuring things out as I go.

I have development magento on a Media Temple dedicated virtual server with 2GB of ram. I recently had as many as as 600 products and about 25 different attributes on each product (total of about 300 unique attributes) and maybe 50 categories. I deleted all of that in attempt to troubleshoot load speeds around 15s.

However my load times are still long and inconsistent. I reload my home page with Firebug reporting 500ms for a response, and I immediately reload again and it reports over 9s. Is this a server problem or something with Magento itself? How do I go about testing something like that?


You first need to decide what you are testing, whether its just the PHP render time - or the real-world page load time.

In either scenario, using firebug isn't going to be reliable - as your internet connection itself could be the bottleneck or reason for jitter.

PHP Render Time

If you are purely looking to see if PHP render time has improved/changed - then the most accurate way is to use the output from the Magento profiler.

In index.php, uncomment


Then in

Admin > System > Configuration > Developer

Make sure that profiler is enabled.

You'll end up with a tabular output at the bottom of every page (front-end and back-end) breaking down the page load time, measured from the point of Mage::run() starting. The very first line will indicate the total PHP render time (within Mage).

This is going to be your most accurate figure in terms of establishing if your PHP changes are making a difference to page load time, not to mention, it will identify any performance bottlenecks.

PHP Web Server Render Time

The next type of test is to factor in the overheads of the web server itself (but not last-mile connectivity). So for this test to be accurate and not influenced by the 'internet' itself - you should run it on the web server itself.

We use our own utility mage-perftest (more information can be found here) - which can test pure PHP render time, real-world page load time and even concurrency testing.

To test just the PHP web server render time, you would use (replace the URL accordingly)

./mage-perftest -u me-s1.sonassihosting.com -b

This test will give a breakdown of page load time (for just the PHP element of the page, ignoring any JS/CSS/Images). The output looks something like this,

Test Summary
Total files:              1
Total downloaded:         4K
Avg. page weight:         4.00K

Total time:               0.035s
Min response:             0.035s
Max response:             0.035s
Avg. page response:       0.03s

Concurrency/Repeats:      1
Transactions/s            28.57
Test URL:                 me-s1.sonassihosting.com
Success rate:             1/1 (100.00%)

Real World Web Server Render Time

The final type of test is the time it takes to download the entire page (PHP + static content). Again, you can use mage-perftest to do this, eg.

./mage-perftest -u me-s1.sonassihosting.com

Avoid any online testing service like the plague

There are some on-line speed test tools like GTMetrix, Pingdom etc. These are not going to give you any kind of accurate result for granular profiling.

They have their place in terms of testing external network connectivity, but are completely useless as a means of checking actual PHP performance. Stick to on-server/local testing for this.

Other notes

We wrote an article on remote testing and why you should avoid it, http://www.sonassi.com/knowledge-base/magento-kb/why-siege-isnt-an-accurate-test-tool-for-magento-performance/

Running Magento in a VPS is A Bad Idea. Others may disagree - but its not a suitable environment for a Magento store for a number of reasons - and we've answered A LOT of questions down this vein, here are a few

  • Perftest is awesome - is it on Github so I can fork it? – philwinkle May 8 '13 at 16:49
  • I had trouble running perftest, but the profiler provided some interesting information: mage::dispatch::routers_match and mage::dispatch::controller::action::predispatch seem to be a bottleneck, though I'm not sure what the solution there is... searching doesn't come up with much. – andyjv May 8 '13 at 19:43
  • The more pages I open at once, the more time magento spends on mage::dispatch::routers_match, accounting for 22s on a 28s page load. On the same load, there is also mage::dispatch::controller::action::predispatch at 22s, CORE::create_object_of::Mage_Core_Model_Session at 21s and Mage_Core_Model_Session_Abstract_Varien::start/start at 21s. I'm sure there's some parent/child thing going on, but with the routers_match being the longest, I'm assuming thats the parent of the other 20 second functions – andyjv May 8 '13 at 20:32
  • The profiler output is hierarchically inclusive. Ie. Its showing an inclusive total for everything run within that function. So Mage will take the longest as it includes everything, Routers_Match is basically the next function it calls, that everything else is spawned from. Its not the bottleneck, but something it is calling (look further down the table) is. Don't open more than 1 window if you are profiling - that isn't going to achieve anything. – Ben Lessani - Sonassi May 9 '13 at 6:51
  • Below Routers_Match there is: DISPATCH EVENT:controller_action_predispatch at 21.0710, and OBSERVER: log at 21.0565 – andyjv May 9 '13 at 12:05

This is most likely a server issue and not a Magento issue. Depending on what kind of server you use, you can get a load time of under a second. You can even run more sophisticated testing here: http://www.magespeedtest.com/. You can also review speed from other server providers there as well.

I would recommend also using the waterfall report from http://www.webpagetest.org/ and see where exactly your "slowness" can be coming from. It will break it up into parts (like how long it takes to download each css, js, and image file) which can help you to improve the speed.

That being said, even if you optimize the Magento code, css, js, images, and content to the fullest, the server will always be the biggest issue. I would recommend using a Magento Hosting Provider, as they have their servers more fine tuned to help Magento. Personally, I use Nexcess, but others I have heard good things about are Sonassi Hosting, and Peer1.

There are a few articles about how to improve speed, I would recommend reading the white pages on the Magento website.

While it is more geared toward Enterprise, you can still benefit from a lot of the advice. Also, make sure you keep Magento up to date! You shouldn't fall more then two versions from the current release.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.