Improving the Load Time Performance of Magento Community
One of the main things new-to-Magento merchants are likely to need to address as is how quickly you are able to deliver your store’s content to the customer. The performance of Magento is something which has been discussed extensively since Magento was first released and if you have looked into the subject in any depth you have probably come across some of the countless resources on the subject.
This is an attempt to simplify the area of performance in Magento and tell you that there are three main areas you need to address to get a really snappy, fast store.
So the most obvious question to ask is what makes Magento slow? The simple answer is PHP – let me explain. Magento is a hugely capable and versatile application which can be used straight out of the box for virtually any online store setup you can imagine. It is also a fully fledged framework in it’s own right and the tools it offers can be easily leveraged to extend your store’s functionality in any way you like (as demonstrated by the countless extension available). This is great as it gives you a really capable, solid and flexible tool to run a store – but brings with it a down side. Giving this kind of breadth of functionality and scalability means there is significant complexity involved and as Magento is built using PHP, more complexity means more lines of PHP code.
A single line of PHP code is quick to execute but does take a finite amount of time, so when you are talking about an application like Magento which has millions of lines of code in total, you can begin to imagine how the time taken to build and deliver an entire page to a browser can make the whole process seems pretty slow.
The key point to make is that the main, and in fact only significant bottleneck with regards to Magento performance is the time it takes the server to execute a line of PHP code. While addressing other other areas such as using NGINX/LiteSpeed over Apache, MariaDB/Percona over MySQL, and various configuration tweaks to the server software can yield a minor improvement in performance, these kind of steps are really best left until you have done all you can to address the performance of PHP.
I mentioned above there are only three areas you need to look at to improve the performance of your store. The first is your hosting and server setup. Make sure your hosting is sufficiently highly specced to be able to run Magento well with no caching enabled. Remember that the store will only ever run as fast as the server it is installed on allows. What hosting package you go for is highly dependant on your particular install and the amount of traffic it will see so there is no generic answer here. My advice would be to approach a hosting company who preferably specialise in Magento and get advice from them on a good package for your store. They should also be able to deliver an environment which is well configured and suited to running Magento. Having said that steer clear of shared hosting – however you work it Magento will never run well.
As part of the hosting and server setup moving to PHP7 can also give a real boost with performance comparable to HHVM. Magento 1 only needs some relatively minor changes to allow it to run under PHP7 and Magento 2 works out of the box. Also worth looking at is opcode caching. This stores compiled PHP scripts to memory and so removes the need to load and parse the script (which takes time) the next time it is used. From PHP5.5 opcode caching is built in using Zend’s opcache so it’s certainly worth enabling this. If you are not using PHP5.5 APC is a good choice for an opcode cache.
The second area you should look at is Magento caching, specifically full page caching. While Magento 1 CE does have caching built in, it doesn’t ship with a full page cache – Magento 1 EE and Magento 2 both have it built in. While a full page cache doesn’t actually improve PHP performance, it does mean drastically fewer lines of PHP code need to be executed to build and deliver a page to the browser, and this in turn yields a significant performance gain. There are a wide rage of full page caching options available so pick the best one for your store and budget and once installed you should see a significant reduction in the time it takes the server to deliver a full page of HTML to the browser.
The third area you should look at is the number of requests per page. While a full page cache will greatly improve the performance of the slowest, first request to the server, all image, JS and CSS files are then requested after this. Individually each request is relatively quick, but combined they take a fair amount of time to complete which increases the total page load time. Magento has merging built in which will combine the stores JS and CSS into single files so enabling this is an easy step you can take to considerably reduce the number of requests per page. You should however also look at the number of images you use to see if this can be reduced. It’s a good idea for instance to combine a number of smaller images into a single sprite, and you can also leverage CSS3 for things like rounded buttons where historically you would have needed an image.
I hope this quick article gives you some useful information on steps you can take to improve the performance of your Magento store.