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)

Installing a PHP accelerator (Become an expert)

In this recipe we will learn how to improve performance of any application written in PHP by creating a brand new caching system. This recipe is relevant only if your server stands on a dedicated server and you have a root access to it.

How to do it...

  1. We will install Alternative PHP Cache (APC) on our Unix-based server. In order to install this caching system on our server, we will need to import several packages, as done in the following command line:

    sudo apt-get install php-pear php5-dev apache2-threaded-dev make
  2. When all these packages are successfully installed, we can go ahead and install APC by using the following command:

    sudo pecl install apc-3.1.4
  3. Then you have to create a file named apc.ini under /etc/php5/conf.d/. Add the following content in the newly created file:
  4. Create a file named info.php that contains the following code and upload it:

    <?php phpinfo(); ?|
  5. Open local.xml under /app/etc/ and locate the following line:

  6. Then add the following lines after the previous line:

  7. Restart your web server.

The Alternative PHP cache should now be installed on your server; you can check if it's working correctly by browsing to the info.php file. If there is an APC section, it means that everything is done correctly.

Using the same web stressor, the Apache benchmarking tool, we will compare the performance when our PHP accelerator is on and when it is off.


Min (milliseconds)

Max (milliseconds)

Median (milliseconds)


APC off





APC on





Another relevant improvement! Indeed, median time to complete a request was reduced by almost 40 percent. So your server can now handle 3.54 requests per second, which is almost a 60 percent improvement!

How it works...

PHP accelerators are extensions made for improving the performance of any application written with PHP. The main aim is to cache the PHP byte code in order to skip all the parsing and compiling processes when a processor executes PHP scripts. The cached code uses the shared memory so that it can be executed from there. On an average, the improvements that come with a PHP accelerator vary by two or seven.