How To Speed Up A Magento Website?

magento speed optimization

You should never ignore your website speed, even in case if it has been successfully operating for years, has been presenting both high ratings/profits, and has been popular among the users from such ecommerce giants as the USA, Germany, the UK and Australia. Speaking about Magento loading speed, we can stay that websites built on this open-source ecommerce platform presents a variety of useful features such as: high scalability and flexibility, system safety and reliability. However, Magento performs all these advanced features by means of a great number of files and large databases, as well as a bigger amount of requests on page load. As a result, it makes Magento slower.

Why do we need to optimize Magento speed?

When Magento flexible architecture and scalability make it the best choice for large ecommerce solutions, increasing Magento speed continues to be a challenge for many developers. The slow page loading can have a significant influence on overall user experience, not just cause SEO issues. Take a look below, you can see the requests made per second by some of the platforms. The higher amount of requests indicates a system that works faster.

 magento requests

We can see that Zen Cart is slowest, but Magento also does not present the good results and has considerably more requests than the other systems. However, it is not a reason to refuse to use Magento, because it is still one of the most secure platforms in the online market. And our development experts know how to settle this issue and speed up your Magento website. Let’s look at how they did it working with Hardware.nl website. 

Hardware.nl is German largest dealer of electronics. There you can find a wide range of PCs, monitors, printing devices, storages, software, etc. This online store is popular not only in the home country, but also in the UK, France, Australia, the USA and other countries.

So, we will start from analyzing the initial website performance metrics for the Hardware.nl:

What can influence a website loading speed?

There are several factors, which can slow down website loading on a client browser:

DNS Lookup

Each website has human readable Domain Names (for example hardware.nl), which correspond to specific IP addresses (like 73.122.214.71). The IP address turns to a server that presents Google website data. And the time needed to convert the human readable URL to its accordant IP address slow down your website loading.

Latency

Latency is an amount of connection time needed for user to send some data or a request across the network to the server. It has a significant effect on the website loading duration. The request waits in a queue for the server. The latency time can be reduced if the server affirms the request and sends necessary data back to the user’s browser within the shortest possible time. However, sometimes, this process turns out to be really time-consuming and slow down the pages’ loading.

Time before loading data

When server receives a request and confirms it, it doesn't mean that the recipient will immediately get data sent back. There is still some time used to process data and transfer it to the requester.

User’s Side

Of course the page loading depends not only on the server operation. The user’s browser has to parse, load and convey the server response. And this process is influenced by internet connection speeds, and even by a user’s bandwidth.

Magento Performance Testing

Before starting to analyze the Magento speed optimization, we decided that it would be much more reasonable to discuss how to estimate the current Magento store loading time. To do it, we decided on three specific measurements. They are simple, but informative enough to test Hardware.nl speed. 

Now, we would like to present you a brief overview of these metrics:

Time To First Byte

​Time to first byte (TTFB) is a metric that helps estimate the responsiveness of a server. It measures the amount of time taken for connection to the server and downloading the contents of a store page.

DOM / DOMContentLoaded

DOM is an abbreviation for Document Object Model. It means the document structure, in our case the structure of a web page. The DOMContentLoaded event is triggered when the initial HTML document was loaded and parsed (we do not speak about style sheets, images, and subframes loading). Another event that is called load, we use to mark a completely loaded page. The biggest mistake here is to use load instead of DOMContentLoaded that would be much more suitable. Try to avoid it!

The Whole Website Loading time 

We are not going to dwell on this issue because it is simpler than may seem. The whole Website Loading time is a period, which starts from the time you enter “hardware.nl” in the browser address bar and continuous till the landing page is completely loaded.

Hardware.nl Testing

To test the Hardware web store loading speed, our team used Apache Benchmark. And below, you can find the received results:

Document Path:    /3com/3c12065-rfb.html
Document Length: 115430 bytes
Concurrency Level: 10
Time taken for tests: 290.460 seconds
Complete requests: 100
Failed requests: 0
Total transferred:  11511600 bytes
HTML transferred: 11466000 bytes
Requests per second: 0.33 [#/sec] (mean)
Time per request:    29046.016 [ms] (mean)
Time per request:  2904.601 [ms] (mean, across all concurrent requests)
Transfer rate:   38.45 [Kbytes/sec] received
Connection Times (ms) min mean [+/-sd] median max
Connect: 0 0 0.0 0 0
Processing:       23825  29200  1292.4 29247   32069
Waiting:  23795 28149 1365.4  28106 30890
Total:   23825   29201 1292.4  29247 32069

Percentage of the requests served within a certain time (ms)

%   50% 77% 70% 75%  80%  85%   88% 95% 100%
ms 29247  29015  28292  30891 30019  30136  30730  32060   32060 (longest request)

After that, we concentrated on our three main performance metrics, which we mentioned earlier: Time to First Byte (TTFB), DOMContentLoaded, and full site load time. Please, look at the results that we found:

 Magento test results

According to Apache Benchmark testing, 11 seconds were needed on average for a full site load. Such speed could be normal in 2000. But, now, in 21st century it can be recognized as a lagging because it is too slow!

What steps did we take to speed up the Hardware.nl online store?

The whole process of website speed optimization was divided into 5 stages:

1. Our developers upgraded Magento from 1.12.x to 1.13.1.0 version.

The upgrade allowed to enhance the website security and improve its performance. The 1.13.1.0 version was realized with all bugs fixed and let us provide the website with new features. However, here it is important to mention Onepage Checkout optimization. Earlier, it took, considerably, more time to return shipping rates, payment methods, and order review steps. The update made this process much more faster.

2. We moved to redis for caching in order to improve performance.

One of the basic methods of optimizing Magento is through caching. Really effective caching running makes Magento faster. The advanced key-value store “redis” is used as caching backend to run caching entries efficiently enough. Redis store has a simple data storage structure. Now, we keep cache data in redis. It cuts the access time and allows us to use a cluster of frontend servers. All frontend servers can call the redis server and get the same cached data. So, we are able to enhance server capacity without any problems.

3. Our team modified some of Magento core libraries. It lets us work with PHP 7.0.

As you know, Magento uses PHP version 5.6. Also, you should know that 7.0 version is noticeably faster. As Magento doesn’t support PHP 7.0 out of the box, we decided to modify some of the core libraries to change it. Of course, the latest PHP version can let us improve performance. However, it also plays an important role in speeding up the website.

4. Also, we installed and configured Solr Search Engine with our Magento website. 

Unfortunately, Magento offers an imperfect search system. And many huge stores with a wide products' catalogue (our Hardware.nl online store falls into this category) suffer from it a lot. To change this, a lot of developers decide to install Apache Solr. It makes the process of searching faster. Consequently, it helps visitors to find the products they need. And we did it too.

5. We changed flat indexer operation.

You should know that Magento has a very complex architecture. All retailer’s data (including catalog data, prices, users, stores, etc.) is stored in a number of database tables. To optimize storefront performance, Magento locates data into special tables by means of indexers. All of them are there to make things run faster.

There are different kinds of indexing in Magento: Catalog Search Index, Product Prices, Catalog URL Rewrites, Category Products, Stock Status, Product Attributes and many others. However, here, we would like to stay on the flat indexation. We are sure that you know how it works. If not please go here! In our case, Hardware.nl has the great volumes of data. To speed up the flat indexer, our developers run it in many streams over a range of products.  

As a result,  instead of indexing 80,000 products one at a time, we can index 1,000 products individually, but have 80 threads running which considerably reduces indexing time.

Indexing (especially the 'Catalog URL Rewrite' was taking over 2.5 hours to complete). Now, it  takes less than one minute!

Testing Hardware.nl After Changes

So, when everything was done, we decided to test the results. We chose the same page for testing. And now, we would like to present you what we got:

Document Path: /3com/3c12065-rfb.html
Document Length: 117485 bytes
Concurrency Level: 10
Time taken for tests: 5.040 seconds
Complete requests:  100
Failed requests:   0
Total transferred: 11902200 bytes
HTML transferred:   11825200 bytes
Requests per second: 17.36 [#/sec] (mean)
Time per request:  603.993 [ms] (mean)
Time per request: 60.388 [ms] (mean, across all concurrent requests)
Transfer rate:  1889.35 [Kbytes/sec] received
Connection Times (ms) min mean    [+/-sd]  median max
Connect:    0 0  0.1    0 0
Processing:  466   581 103.8     592 842
Waiting:   456 557 102.7 581   807
Total:  466  581 103.8    592 842

Percentage of the requests served within a certain time (ms)

%   50% 66% 75%  80% 90% 95% 98%  99% 100%
ms 585 650 669 702 733 748  818 829 829 (longest request)

Then, we decided to compare Time to First Byte, DOMContentLoaded, and full page load times from first and last testing. Take a look below:

 magento time to first byte

Magento DOMContentLoaded results

Magento full page load results

And the last is a comparing the averages received after all tests:

magento comparison of averages

Just to sum up! We increased our speed by the following factors:

  • Time to First Byte 17.5x faster
  • DOMContentLoaded 2.8x faster
  • Full Page Load 2.6x faster

As you can see, DOMContentLoaded and full page load are affected by a client’s internet bandwidth, when TTFB depends on server and system. Such dependence shows why TTFB enhanced about seventeen times over, when other two measurements only improved doubly.

Conclusion on Magento Website Speed Optimization

The practice showed that it is really possible to speed up Magento website. We could optimize Hardware.nl loading speed by upgrading and introducing three other changes in its operation. We hope that our guide will help you to substantially reduce your page load time. If you follow our example, please leave a feedback! Tell us where you succeed and where not. And do not hesitate to ask questions, our Sam Ecommerce Magento development experts will be happy to help you!

Read more about Magento here: 

Comments (2):
Posted on Wednesday, September 14, 2016 by :
God, I feel like I sholud be takin notes! Great work
Posted on Wednesday, September 14, 2016 by :
I really cod'lnut ask for more from this article.
Leave a comment:
*Your comment will be published after approval by site administrator.