Magento slow? No way!
Thursday, 11 March 2010The Number One reason why some people dislike Magento is performance. The e-commerce application runs considerably slower than Joomla! - at least when it's put to use without any modifications. But is this right? Is Magento really slow? Or is it just that we don't know how to properly tune Magento?
Ignorance causes bad performance
A lot of times when we meet people with such an opinion, we ask a bit further and discover that they have never heard of the Magento Cache (which indeed can be enabled). Or they expect to earn thousands each year, but only can afford $10 a year on hosting.
The problem here is that Magento is a flexible but complicated application, and you need to invest time for the least to put Magento to good use. A good performance requires your effort.
Performance tricks on the web
On the web there are already many different pages which explain you how to maximize the Magento application. These tricks range from the obvious (enable caching) to the occult (put images on tmpfs-filesystems).
But a lot of these tricks are based on operating system settings, while in a shared hosting environment (ouch, I mentioned something bad) you don't have control over a lot of these settings. It makes sense: Shared hosting is based on the fact that resources are shared among different applications, so all these resources need to be configured in such a way that they are optimal for all applications. Optimization contradicts this, because it is configuring resources for one specific application: Magento.
We like it fast
But something obvious is missed here: While the optimization of the webserver makes sure the PHP-scripts of Magento are run as fast as possible, we all know that the experience of surfing depends on another more basic principle: Bandwidth.
The more time a webpage needs to load, the less we will like it. This is true, even if you are connected to the Internet with a some kind of Star Trek-like Internet connection: The speed of your connection just changes your expectation standards. If you need to choose between a standard Magento webpage and the Google Search homepage, you will like Google more because it loads faster.
Optimizing CSS and images
The obvious thing here is that a smaller webpage (with less bytes) loads faster in the browser and is there for more to be liked. There are general two techniques to get a smaller webpage: Make the files smaller (or use less files) or make the distance between the webbrowser and the webserver smaller.
Making the files smaller involves compression techniques (gzip, mod_deflate) but also indexation of JPG or PNG files. A lot of the websites we inspect use images which are not optimized, while this could reduce the total size with 30% or 40%. There is a huge gain here. But other techniques involve combining CSS-stylesheets to one single file, so that the browser only needs one HTTP-request to fetch it. This could be done statically (copy-and-paste) or dynamically (using a PHP-script). In fact, a PHP-script is already used to accomplish this for the Magento JavaScript.
CDN (Content Delivery Network)
Another winning concept is the usage of a CDN. The distance between webserver and browse also determines how long the visitor must wait before the webpage is loaded, and this distance can be shortened by using a CDN: The webserver that is the closest to the visitor is serving the content. Things like hops and QoS are involved here.
While a CDN could be used to deliver the entire Magento site, in most cases this is too expensive and too complex. An alternative is to only deliver static content through the CDN, while other content is delivered by the original Magento webserver. To put a CDN into use you will need to find a way put all your static files (CSS, JavaScript, images) onto the CDN itself, plus a way to alter all links pointing to this content (HTML coming from Magento).
Our testing results
We have done some testing ourselves with all the performance techniques mentioned above, and we found that Magento becomes lightning fast. With the right tuning it even becomes faster than the average Joomla! template with example content!
Our intention is to release various performance articles within our Magento Tutorial section: The subjects will primarily focus on webdevelopers with knowledge of Magento theming and a bit of PHP. Besides this, we will also release a Magento Checklist with which you can check for yourself if you have done everything to run a fine Magento shop.
