The Golden Master List of Magento Performance Enhancements

Want to learn something new? Check out my most recent Egghead course:

Build a Twelve-Factor Node.js App with Docker - WATCH NOW on!

Cheers -Mark

Mon, 02/13/2012 - 15:30

Submitted by markoshust Mon, 02/13/2012 - 15:30

There are lots of tips, tricks and hacks on how to enhance Magento. A lot of them are good. Some are entirely wrong! And most do not have each and every update you must make to every single one of your sites in order to get it to achieve the fastest possible load times. This is a list to remedy that situation.

Remember, all of these updates only apply to production environments. Feel free to post comments, updates and suggestions and I will keep this list up to date as much as I possible can. Hopefully, in time we can achieve a golden master list of performance enhancements!

Verified, Tested & Recommended for all installs
Verified & Tested. Recommendation varies based on application.

Magento Configuration

  • Enable Caching
    System > Cache Management > Select All > Enable
    This one is an absolute no-brainer and provides one of the best performance enhancements you will get in Magento. This caches the XML layer in Magento, along with some other information, to speed up PHP processing time.
  • Merge JavaScript and CSS Files (Not needed if using Fooman Speedster module)
    System > Configuration > Advanced > Developer > Javascript Settings & CSS Settings
    Combines the many css and js files defined in Magento's XML layer into one large file for each (one for js, one for css). It speeds up your site because it reduces the number of http connections needed in order to fetch this data through a web browser.
  • Compilation
    System > Tools > Compilation > Run Compilation Process
    This option compiles all Magento installation files and creates a single include path. Remember to disable this module before upgrades. The compilation process may need to be ran again when new files are released. Recommended for high-volume websites or sites that are not often updated as it reduces PHP processing time and TTFB.
  • Disable Logging
    System > Configuration > Advanced > Developer > Log Settings > Enabled: No
    This is disabled by default, but be sure to double-check it is disabled on production environments, as this setting can drastically slow down your website if enabled.
  • Enable Gzip
    This is a must-have tweak. It decreases page size by over 30%, and takes a base Magento home page PageSpeed from a 32 to a 69! Make sure to enable the deflate module in your Apache configuration, then comment out the appropriate lines in the mod_deflate.c directive of your ~/.htaccess file.
  • Minify JavaScript
    Install the Fooman Speedster module
    The easiest way to minify your JavaScript is to install the Fooman Speedster module. This does everything you need to make sure all of your JavaScript is minified. It also merges your CSS and JavaScript files into one file each, so this replaces option #1 on this list.
  • Enable Far-Future Expires
    Add ExpiresActive On and the following lines after the ExpiresDefault directive in your ~/.htaccess file
    These few lines add expires directives to your images and some other files. This tells the web browser to cache the contents for a period of time on these items, cutting down HTTP requests and load time for future visits. This is also a must-have and often overlooked tweak!!! These few lines took a Magento site with a few of the above tweaks from a PageSpeed of a 70 to an 83! Also note, the default ExpiresDefault line should remain commented out to prevent long-term caching of dynamic PHP files.
            ExpiresActive On
            ExpiresDefault "access plus 1 week"
  • Enable Flat Catalog/Index
    System > Index Management > Enable All
    System > Configuration > Catalog > Frontend, set Use Flat Catalog Category/Product to Yes
    If you have a large amount of products on your site (>10,000), this update decreases load times on searches, product listings, etc. I can't see this ever slowing down your site, even with only one product, so no reason to not tackle this easy one.

Server Side

  • Install "enough" memory (2GB minimum)
    Even if you have very little traffic, ie. less than 100 visits per day, plan on running a minimum of 2GB of memory. Anything more, plan accordingly. Once you hit about 16GB RAM, you will be hitting peak efficiency, and are better off scaling horizontally rather than vertically (more server nodes VS. working with current resources).
  • Run Lightspeed VS. Apache
    For the most part, Lightspeed web server is a direct drop-in replacement for Apache. Virtual Host configurations stay the same, htaccess rules work, and just about everything else including modules and plugins work out of the box without any additional configuration. Lightspeed has a much lighter footprint than apache, as do many other web servers such as Nginx and Lighttpd, but Lightspeed involves little to no additional knowledge of server configurations or etc.
  • Install APC
    Install APC with the command line pecl install apc
    Also add the following cache handle to your app/etc/local.xml configuration file


    Just installing APC, with no configuration, whatsoever, decreased page load time by about 20% on my clean Magento install, and decreased TTFP by about 30%! APC is one of the best bytecode compressor's for PHP, and has been tried and true on many Magento installations so far, so there is no need to look elsewhere.

  • Enable KeepAlive's
    Add the following lines to your Apache configuration file
    KeepAlive On
    KeepAliveTimeout 2

    Apache KeepAlive keeps the TCP connection open between the client and the server, allowing multiple requests to be served over the same connection. This removes some overhead with sites serving up a lot of concurrent HTTP requests.

  • Disable open_basedir
    Add the following line to your Apache configuration file
    php_admin_value open_basedir none

    The open_basedir parameter is a security feature that restricts filesystem lookups, but can hurt performance on applications with a large filesystem footprint like Magento. Disable it to lower lstat lookups. Find out more about this setting by reading this article by Nexcess.

Client Side

  • Use a CDN
    This could fall under a Server Side upgrade, but the results are really drastic on the client side. A Content Delivery Network can improve your data cache, reduce latency, and increase redundancy for your web site. But the simple reason to use it is that it speeds up your website instantly. Ashley Schroder has a good article on integrating Magento with Amazon Cloudfront that makes it very simple to get up and running with a CDN, and Nexcess has a good article on setting up a CDN with Magento using their own CDN network.

Database Related

  • Enable the Query Cache
    Add the following lines to your /etc/my.conf file

    This caches a certain amount of MySQL statements so they do not need to be run again. Easy mod for a nice enhancement!

  • Run MySQLTuner

    This perl script monitors your current MySQL install and provides recommendations and suggestions for tweaks to your my.cnf file. Very informative stuff here!


  • Coming soon! Please submit your recommendations below.


Actually, you need to make sure compilations are disabled whenever APC is turned on. One will conflict with the other. Otherwise great list! Thanks!

As far as I know, they are compatible with each other. Magento Compiler just changes the include path to one directory (include/src) -- it doesn't do any real compression.

> Enable Flat Catalog/Index > System > Index Management > Enable All > System > Configuration > Catalog > Frontend, set Use Flat Catalog Category/Product to Yes If you have a large amount of products on your site (>10,000), this update decreases load times on searches, product listings, etc. I can't see this ever slowing down your site, even with only one product, so no reason to not tackle this easy one. *Except* when you have a lot of websites, then !@#%^ think called flat tables explodes into hundreds or more tables in DB. Just finishing *cleaning* Magento core code of flat table support for the website with ~100 webistes (with qute a few translations per website). Also there a few very nasty silent bugs in flat code that can easily make code pull *all* products when filtering by some attribute. As usual, Premature optimization is the root of all evil -- DonaldKnuth First profile, then if really needed turn them on, re-run ALL tests you have (full regression/unittest suite) then profile again, check SQL logs ... and maybe, maybe in the end turn that option on after confirming that it will decrease time enough to pay for increased testing time.

Thanks for pointing that out. That is definitely a rare case for Magento (100 stores, translated...). Sites like these do need to take extra precautionary measures when applying any of the above suggestions.

As most of the Magento database is stored as innodb, it's imperative that you provide shedloads ( metric or imperial - it doesn't matter! ) of innodb - related resource. Once the database is configured properly, and most queries are served from memory, then the MySQL load on the system can almost be forgotten, it's so small. ( There are also possible gains to be had by upgradeing to the latest 5.5 MySQL - I've migrated over to Percona - but only consider that when you're chasing the final 1%! ) I'd also look into replacing apache with a lighter weight web server - nginx is my personal favourite. This also requires migrating PHP to fpm mode, which also shows great gains when coupled with a decent cacher like APC - the cache is shared between processes, and that makes the contents far longer lived, which is also good. Finally, look at putting var/session ( and possibly var/cache ) onto a tmpfs - backed filesystem. This does seem to speed a lot of things up - especially on VPSes - often by 20+% ... in fact the only time I've seen it not make a difference was benchmarking a 16 core / 32GB Dell server running just the demo store! This does also mean that server sizing becomes more important... I personally recommend a minimum of 2GB memory to get a Magento site running well - mind you generalisations are always pointless but it's a good starting point.

I actually keep a ./www/ and ./www-disk/ structure. ./www/ is a tmpfs (completely in RAM), and ./www-disk/ is the non-volative version. A cron job regularly updates ./www-disk/ from ./www/ And the system runs scripts to populate the ./www/ mountpoint at startup. I utilize 6GB or RAM for the ./www/ filessystem, and keep 6GB for the system. It makes a very noticeable performance increase.

Mark, could you please add a small note in "Compilation" step which is compilation process will drop in Magento 2.0 version!

Hi Oguz, Yes, it will drop out of 2.0 version. However, all of my blog posts and etc. are geared directly for 1.x. Lots will change in 2.x. Thanks, Mark

Hi! That;s a good checklist i must say. My suggestions? Well, I've followed the steps from this article and they helped me a lot. Hopefully, you'll find them useful too, though you've already mentioned some here.

By the way, I presume you mean Litespeed, not Lightspeed, which is a caching module for Magento? Unless I am mistaken..

*LiteSpeedDisable unused modules as well before running the compilation proccess.Enable some sort of log_* table (et al) cleaning, e.g.: Varnish and take advantage of ESI in your template files!