views:

6492

answers:

12

Is Magento usually so terrible slow?

This is my first experience with it and the admin panel simply takes ages to load and save changes. It is a default installation with the test data.

The server it is hosted on serves other non-Magento sites super fast. What is it about the PHP code that Magento uses that makes it so slow, and what can be done to fix it?

+4  A: 

You can try this - not guaranteed to work but has helped a lot of people:

http://inchoo.net/ecommerce/magento/boost-the-speed-of-your-magento/

Sam
Thx Sam, actually I already had come across it via Google, although those changes in the .htaccess file did not seem to speed things up too dramatically.
mr-euro
+23  A: 

I've only been tangentially involved in optimizing Magento for performance, but here's a few reasons why the system is so slow

  1. Parts of Magento use an EAV database system implemented on top of MySQL. This means querying for a single "thing" often means querying multiple rows

  2. There's a lot of things behind the scenes (application configuration, system config, layout config, etc.) that involve building up giant XML trees in memory and then "querying" those same trees for information. This takes both memory (storing the trees) and CPU (parsing the trees). Some of these (especially the layout tree) are huge. Also, unless caching is on, these tree are built up from files on disk and on each request.

  3. Magento uses its configuration system to allow you to override classes. This is a powerful feature, but it means anytime a model, helper, or controller is instantiated, extra PHP instructions need to run to determine if an original class file or an override class files is needed. This adds up.

  4. Besides the layout system, Magento's template system involves a lot of recursive rendering. This ads up.

In general, the Magento Engineers were tasked, first and foremost, with building the most flexible, customizable system possible, and worry about performance latter.

The first thing you'll want to do to ensure better performance is turn caching on (System -> Cache Management). This will relive some of the CPU/disk blocking that goes on while Magento is building up its various XML trees.

The second thing you'll want to do is ensure your host and/or operations team has experience performance tuning Magento. If you're relying on the $7/month plan to see you through, well, good luck with that.

Alan Storm
Thank you for the extensive explanation. Magento is indeed very powerful while allowing for flexibility. I initially thought it was simply the DB writes stalling due to some badly written SQL, but I do realise now that there is much more going on behind the scenes that initially expected. As a note: caching was disabled due to products being added by the shop owner. When cache was on he complained of products not appearing forcing me to disable caching while the shop was being set up. It is being hosted on a dedicated server, but it seems I will have to move Magento to its own exclusive box.
mr-euro
I profiled it a while ago with XHProf. The XML parsing took a huge amount of time - I think you are spot on with this list.
Morgan Tocker
+5  A: 

Further to Alan Storm's recommendations on caching, there's two things I'd specifically recommend you look into related to caching:

- Make sure caching is in memcached, rather than on disk.

I look after a couple of magento installs, and once you get any sort of load on the system, memcached starts to perform much faster. And its dead easy to change it over (relative to doing other magento stuff at least!)

Good starting point is here: http://www.magentocommerce.com/boards/viewthread/12998/P30/ - but if you've not used memcached at all before, its worth looking at some general info about it as well.

- Enable template/view caching.

This is a good article: http://inchoo.net/ecommerce/magento/magento-block-caching/

There are good ones on the magento site too (google magento block caching), but its down at the moment.

To add my two cents to the block caching, I'd advise you create your own blocks in /app/code/local, extending the core ones and defining the cache parameters, name them xxx_Cache and then update your layout to use these blocks instead of the core ones. This way, you avoid losing your changes or breaking the system when you upgrade magento.

benlumley
Thx for the points. I will have a look at memcached which I have not used in production before. Good idea about cloning the blocks too.
mr-euro
I second what benlumbey said, I don't use memcached as I'm running windows server , but I store the /var directory in a solid state drive and that has made a big difference for me.
Rick J
@rickj - yeah, anything to make ./var folder faster definitely helps, i've tried using tmpfs before memcached as well, and got a decent boost off of that too.
benlumley
+2  A: 

If you haven't seen it yet, Magento and Rackspace teamed up to create a white paper on performance tuning Magento. It's excellent. http://www.magentocommerce.com/whitepaper

Laizer
Thanks for the update, I will read it in-depth later.
mr-euro
A: 

We had a similar experience with speed. This extension was born out of a lot of sleepless nights creating a solution for our clients. It serves up to 100x more requests and creates faster Magento server response time (up to 90%) than default slow Magento installations. Plus you use less servers, perfect if you're using Magento Enterprise.

http://www.magentocommerce.com/magento-connect/TinyBrick/extension/3287/lightspeed

Eric
A: 

There are many reasons why your Magento shopping cart could be running slow but no excuses for there is a variety of ways to eleviate the problem and make it pretty darn fast. Enabling Gzip by modifying your htaccess file is a start. You can also install the fooman speedster extension. The type of server used also will determine the speed of your store. More tips and a better explanation here http://www.interactone.com/how-to-speed-up-magento/

Thomas
A: 

Magento is very slow because the database design is not very good. The code is a mess and very hard to update and optimize. So all optimizations are done via cache instead of code.

On the other hand. It is a webshop with a lot of tools. So if you need a flexible webshop just buy a very powerfull server and you will be ok.

developer
A: 

When I first installed I had pages that were taking 30 seconds to load. My server was not maxed out in ram or processor, so I didn't know what to do. Looking at firebug's net panel it was loading about 100 files per page, and each one took a long time to connect. After installing fooman speedster and the gzip in the htaccess loads times were down to 3 seconds, like they had been on other shopping carts on my server.

Scott
A: 

Here is a Magento Caching Plug-in that decreases page load times to .5-.1 of a second and increases transaction rates 10-100x.

http://store.delorumcommerce.com/catalog/product/view/id/3/category/3/ http://store.delorumcommerce.com/catalog/product/view/id/2/category/3/

Matt
A: 

I've created a blogpost "101 ways to speed up your Magento e-commerce website" on how to get the maximum out of your Magento store.

http://blog.guidojansen.nl/2010/05/18/101-ways-to-speed-up-your-magento-e-commerce-website

Let me know if you have more tips so I can add them to the list!

Guido Jansen
A: 

Switching from Apache to LiteSpeed helped us a lot. In addition to: Editing MySQL's settings, installing Fooman Speedster (module to compress/combine js and css files), and installing APC. Magento has also posted a white paper on how to get the best performance out of the enterprise edition, but it is equally applicable to the other versions: http://www.magentocommerce.com/whitepaper/

Jonathan
A: 

Hi mr-euro,

I'm more involved in the managed server optimization in my company (www.nbs-system.com) but I may have a few tips for you. First, you can look at the code more closely using the code tracing feature of Zend server. It will allow you to see where and when the things get dirty.

I totally share benlumley's consideration regarding the cache. Most of the sites we host doesn't even have the block caching enable. This cache has to be explicitly called and not "assumed". So if you code hasn't yet took part of this mecanism, it's something you definitly want to try. If you have a EE version, you can get the Full page up in order to get the best of the beast.

A reverse proxy will also help a lot. It'll cache the static ressources, significantly lowering the pressure on the php interpretation stack of your front servers.

Don't forget to write the sessions & magento cache to a RAMdisk, this will also definitly get you to another level of performances.

There's still a lot to be said here but I'm running out of time. If you need more, you can contact me phu [at] nbs-system.com. You have to know that a good site, well coded in a 1.4.1 CE version, running on a 2x5650 Xeon + 16 Go server and having a Rproxy on top can take up to 50 000 uniq visitor a day with smooth pages to everybody.

Philippe.

kameo