Magento Site Performance Optimization: Book Review

I'll first start by saying that the title of this book can be somewhat misleading. The author (Mathieu Nayrolles) has written a previous book with the title 'Instant Magento Performance Optimization How-to' and from his personal website it looks like the original title for this book was to be 'Magento Performance Optimization Volume II' which followed on from that book.
Whilst the optimization techniques in the book are tested on a Magento installation, the same techniques could generally be used on any PHP/MySQL application.

To gain an understanding of Magento's built in caching and code optimization features you would do better to take a look at the original book which covers these topics (which I have not read...).

The book it's self is split into 4 parts

  1. Hardware performance
  2. Different server setups
  3. MySQL optimization
  4. Caching mechanisms

Hardware performance

This chapter takes a look at how changing the computing power, disk type and memory can affect a sites performance.
Benchmarks are run on a default Magento installation containing sample data with the improvements that can be made by upping resources.
It's noted that the tests are run on this default installation but also tested on a production site worked on by the author of the book, however, the results of the benchmarks only seem to be given for the default setup so you have to assume that the tests on the live site gave similar results (and changing the disk type for example on the live site was probably not an option anyway).
The main results here show that just throwing resources at a site does not necessarily result in a cost effective speed boost.

Different Server Setups

The same default site is set up on 3 different HTTP servers (apache, lighthttpd, nginx) to compare out-of-the-box performance, and then each server configuration is optimized for the hardware with explanations for doing so.
Benchmarks are run on the apache server and the nginx server but the lighthttp server only gets a couple. This is understandable when you see that the performance doesn't differ greatly from apache with a clear difference between nginx and the other two.
Instructions are given to set up a basic install of each on a ubuntu box and how to tweak the configs for optimal performance.

MySQL Optimization

This chapter starts with the number of complex queries that Magento performs and how this can affect site performance.
There is some Magento specific information in this chapter with practical advice on how to clear query logs automatically.
General optimization starts with the basics of query caching and moves on to more advanced topics of running multiple databases on a dedicated server using one as a slave to decrease read/write times.
There is a walk-through for 2 scripts which can log database performance and suggest optimizations to your MySQL configuration files.

Caching Mechanisms

This chapter covers a wide range of topics. It starts with the usual server extensions such as APC and memcached then moves on to running Varnish as a reverse proxy and using Facebook's hiphop virtual machine to convert PHP to a higher level language (and the dangers of doing so).
One interesting part here for me was the general performance hit of applications writing cache to files and retrieving those files and comparing them to changes in the database (to see if they need to be refreshed). It explains how to set up a virtual disk using memory so the data is faster to read and write and how to then periodically copy that data to the standard disk as a backup in-case of any server malfunctions.
It also covers some free Magento extensions which offer full page caching (concentrating on one for reasons explained in the chapter) and how to configure it for the best performance gains.


In conclusion, the book has some good explanations on how to set up a server with the best current software and how to configure it to run optimally. The speed gains would work for most PHP applications however, the speed gains might not be so high for some that are less resource intensive (but good practice all the same). Whilst there are some Magento specific tips, I think the first book would be more beneficial for someone just starting to look at the speed of their Magento site.
To follow most of the steps in this book you would need to have at least basic understanding of server configuration.

The book is available in paperback and ebook format directly from Packt Publishing Check it Out