Book Image

Instant Magento Performance Optimization How-to

By : Nayrolles Mathieu (USD), Mathieu Nayrolles
Book Image

Instant Magento Performance Optimization How-to

By: Nayrolles Mathieu (USD), Mathieu Nayrolles

Overview of this book

The optimization of an attractive commercial website is a non-trivial task that demands time and knowledge. Optimization is a critical point for all growing businesses because a misconfiguration could make you lose money, a lot of money. If your server is overloaded, a browser that wants to turn into a buyer will not be able to, and you will lose customers. "Instant Magento Performance Optimization How-To" is a practical, hands-on guide that provides you with a number of clear, step-by-step exercises to help you reach a high performance level for your Magento stores and keep your customers satisfied.This book looks at tweaks and tips used to boost your Magento Performance, and breaks down the confusion that surrounds the subject.You will learn how to compress your pages, styles, and scripts by almost 80%. We will also take a look at controversial optimization settings such as Magento core compilation or enabling all caching systems. You will discover new applications that improve performance. If you wish your e-businesses to grow and want to keep your customers satisfied, you definitely need this book.
Table of Contents (7 chapters)

Keeping your connections alive (Should know)

In this recipe, we will use the Apache module KeepAlive to speed up the display process of a web page containing a lot of images.

How to do it...

On a shared hosting environment, it's highly probable that your host has already done this. To check this, use the Network tab of Google Chrome Developer tools and look at the Response header; you should find a line like the following:

Keep-Alive: timeout=15, max=200

If this line does not appear, locate the apache2.conf file (for us it was under /etc/apache2/) on your web server and modify the following lines so it looks like the following:

KeepAlive On
KeepAliveTimeout 15
MaxKeepAliveRequests 200

This setting can improve the load time by 50 percent for HTML files with a lot of images.

Using the web stressor Apache Bench, we will make 300 requests for a category page (we use the sample data provided by Magento), and display 30 of them per page. That means 30 images to display, plus the basic theme images.

The URL to do the test is http://YOUR-STORE/index.php/electronics.html?limit=30.

In order to run this, benchmark yourself. You can run the following command on Linux:

sudo ab -n 300 -c 5 http://YOUR-STORE/index.php/electronics.html?limit=30

That means 300 requests with five concurrent users.


Min (milliseconds)

Max (milliseconds)

Median (milliseconds)


KeepAlive off





KeepAlive on





As you can see, the improvements aren't much but we have to assume that we can't see the full power of this setting by stressing our server ourselves. Nevertheless, according to the Page Speed, YSlow, and other tools that aim to optimize websites, this feature is a must-have. Of course, results can change widely considering your hardware.

How it works...

The idea behind the KeepAlive mechanism is to use a single TCP connection for a set of multiple HTTP requests and responses. The aim of this technique is to economize the opening and closing time required for a TCP connection. Indeed, your server will open only one connection and send responses for many requests through it.