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.|
- 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.
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.
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.
Install the Fooman Speedster module
- 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 220.127.116.11 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.
- 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
... ... apc yourdomain_com_
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.
- 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.
- 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
wget http://mysqltuner.com/mysqltuner.pl perl mysqltuner.pl
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.