Search This Blog

Feb 3, 2012

Enhancing Magento Performance

I already wrote a post regarding on how to speed magento site. It shows somehow the basic recommendations. Now I’m giving you some of the advanced suggestions which I got from Magento forum and other magento blog sites.

To keep your site loading momentum you must (at least try) to complete the following recommendations. I’m pretty sure that these will boost your site performance. Take note! Magento Team said that "Performance is key" in of their blog post.

There are two types of configuration that you need to consider in enhancing your site performance: server configuration and on-site configuration.

1. Server configuration – Recommendations which primarily done in your site server or in your hosting service provider. Configuration of memory limit, php extensions, cache size, buffer etc…

Here are some of configurations that you need to do / your hosting service provider must do to increase site performance.

a. Swap Apache for NginX or LiteSpeed . Both of them offers boost over Apache LiteSpeed has developed their own PHP LSAPI, which offers all the advantages of suEXEC/suPHP, but with performance better than even mod_php or FastCGI. You can also check Evan blog post regarding on how to compile Litespeed.

b. Check if KeepAlives is enabled in your Apache. It handles multiple HTTP requests through a single TCP connection.

c. Edit your MySQL configuration. To take advantage of your server’s RAM. Please let your hosting company / edit the my.cnf with the following settings:

key_buffer = 512M 

max_allowed_packet = 64M 

table_cache = 512 

sort_buffer_size = 4m 

read_buffer_size = 4m 

read_rnd_buffer_size = 2m 

myisam_sort_buffer_size = 64m 

tmp_table_size = 128m 

query_cache_size = 96m 

query_cache_type = 1 

thread_cache_size = 8 

max_connections = 400 

wait_timeout = 300 


d. Enabling G-zip Compression. When you installed Magento the default .htaccess include the following code which are commented.

############################################

## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter
#SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
#BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
#BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
#BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
#SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary
</IfModule>


In order to enable the gzip compression you must comment out the above code. After commenting, your code must be like this.

############################################

## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter

SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content

Header append Vary User-Agent env=!dont-vary
</IfModule> 


Please take note that before you can do this enabled first the mod_deflate on your Apache Server.

e. Installed APC. It is a free open opcode cache for PHP. The main purpose of this is to provide robust framework for caching and optimizing PHP code. APC default setting allow you to store 32 MiB opcode cache and the user cache combined. For magento sites try increased the APC.shm.size to 128Mib just a safe tweak to make your site perform better.

f. Use CDN (Content Delivery Network). This is most applicable for those sites which target international audience. The theory behind CDN is to make a copies of your site data on various network nodes in which when users access your site the “smart route” technology distributes your content from the server closest to the user. The closest the server the faster the site loads.

2. On-site configuration. These are the things that you need to do in your site in order to meet optimum site performance.

Yahoo performance rules gives a complete guide on how to speed up to your site. You can also try to run y-slow and page speed to benchmark your loading page and follow the recommendations they give. Some of the best practices that you need to do to your site are:

a. Combining / minifying and removing unused CSS and Javascript. If the site is up and running and no more updates that needs to be done – minimize your CSS. Avoid also putting Inline CSS and javascript – as much as possible put them on external file. But don’t forget to combine those external files. The lesser the files the better.

b. Used Fooman Speedtester. Great plugin that helps in caching images, css and javascript files. It is free, so you can give it a shot anytime.

c. Remove duplicate Scripts

d. Optimized CSS Sprites and Images. Used of CSS sprite and optimized images are best practices when it comes of using web images.

e. Avoid 404’s and empty source.

View the complete list here

Tips


To avoid loss of data, please make sure that apply the above recommendations on DEV site or back up your entire site first.

0 comments: