Divante.com Blog

Magento has been designed in such a way that everyone can easily open their own online store and customize it to their needs without the need to know PHP or other programming language. Magento developers from Varien (eBay since 2011) actually did manage to create an extremely flexible and configurable system.

The flexibility of Magento is unfortunately also the reason for its slow performance (EAV, modularization and thus heavily developed code). There are some basic tricks to help our Magento software come to life in order to increase conversions. In this article, I would like to show the simplest methods to speed up Magento performance.

Flat catalog

Magento uses the EAV model (you can find more information about EAV here) to store product, category and user data. The advantage of EAV is flexibility; at any given time you can add attributes for the abovementioned types of entities. The consequence of using this type of data model is that in order to retrieve data, e.g. concerning a product, we have to use at least 6 tables, which results in the execution of heavy queries increasing the load on a database. The main area affected by such load is a catalog, i.e. product and category entities. To prevent this type of queries Magento developers have implemented the ability to create flat data structures for categories and products through indexers. In short, we can say that flat catalog creates single tables for products and categories which collect all attribute values assigned for each type of entity. Thanks to that, Magento executes only simple queries while browsing the catalog, which results in higher application performance and less load on the server. To enable a flat folder, in the Magento admin panel to enter System → Configuration, then find the Catalog tab and in the Frontend section set the option Use Flat Catalog Category and Use Flat Catalog Product to Yes.

Unfortunately, flat catalog has its limitations related to the maximum allowable size for a single row in a MySQL table, the value is 65535 bytes. There may therefore be situations in which the use of a flat catalog will be impossible (too many attributes stored in a flat catalog table).

During testing the cache has been disabled so as not to interfere with the test results. In the case of category view, turning on the flat catalog caused 12% reduction in response time. In the case of product view when a single query causes a lot less database queries, the response time was reduced by 8%.

Cache

In the basic installation of Magento, cache system is based on the files contained in the folder var/cache. It is not an optimal solution in terms of speed, but it requires minimal configuration and it’s enough for our installation to be pleasant to use. To activate cache, select System → Cache management and then select each type of cache, select Action: Enable and Submit. A frequent omission after starting a production environment is to leave the cache turned off in Magento. It’s a huge mistake, which is confirmed by the following test results.

Before making any measurements, the cache was warmed up by a repeated entry on the test page. The results are fairly predictable, thanks to the cache system being turned on Magento accelerated a lot. The biggest difference is noticeable when browsing the category view, CMS and product views also accelerated, which increases the comfort of using the store. Apart from the obvious advantages in the speed of loading pages, using cache decreases the load on hardware, so that it is able to deal with operations more important from our point of view such as, for example, making orders.

Combining JS/CSS

Another built-in functionality of Magento is combining javascript and css files. When you enable combining, Magento generates a file, putting in it the contents of all the css/js files loaded on a page. Thanks to this operation Magento reduces the amount of requests which in turn speeds up our website. To enable combining, go to System → Configuration, then go to the Developer tab and turn on the relevant options in the CSS Settings and JavaScript Settings sections.

Combining also advantageously reduces the size of a loaded page.

When we enable combining JavaScript and CSS files, the number of requests falls from 51 to 25, the number depends on the skin and add-ons used in our installation. The size of loaded page is also slightly reduced. An easy way to compress CSS and JavaScript files will be described it in the next section.

Fooman Speedster Advanced

One of the most popular extensions for Magento allows you to compress css and js files. On a test installation of Magento this extension allowed me to reduce the size of a loaded page by nearly 100KB. Installation is very simple, the extension can be found here.

The latest version of Magento

Magento is constantly evolving, being perfected with each new version. In addition to bug fixes and implementation of new functionalities, the developers are working on speeding up the entire system. The effects are really surprising, the following tests were performed on two versions of Magento (1.5.1.0 and 1.9.1.0), in the same test environment and with the same package versions and settings:

  • enabled cache,
  • enabled flat catalog,
  • enabled combining of CSS and JS files .

As you can see it is worth (if possible) to regularly upgrade the system to the latest version, it will definitely have tangible benefits.

Summary

The above methods, simple to implement and use, can greatly accelerate an online store created in Magento. These modifications can be implemented regardless of whether we use hosting or a dedicated server. In the next article I will present another method of improving the performance of our Magento installation, this time it will adopt more advanced methods focusing on the appropriate configuration of our server.

Want to improve your e-business with Divante? Contact us.

Jakub Cegiełka

PHP Developer at Divante eCommerce Software House

Share your comment