Thursday, June 19

Top 5 Issues Affecting Mangento Performance

Below are Most common Top 5 Issues, which causes 84% performance Issues. Most of the issues are due to inefficient operations, memory misuse, redundant or useless Looping.

1.    Calculating the size of an array on each iteration of a loop
2.    SQL queries inside a loop
3.    Loading the same model multiple times
4.    Redundant data set utilization
5.    Inefficient memory utilization

Reference : http://info.magento.com/rs/magentocommerce/images/Conquer_the_5_Most_Common_Magento_Coding_Issues_to_Optimize_Your_Site_for_Performance.pdf

Sunday, June 8

Magento Performance Optimization - A Complete Overview



Optimizing the magento speed is always the challenging one. In this article we will go through some of the steps to fine tune your server to allow magento to run more quickly.

1. Apache mod_expires
Whenever the user visits the site , always the web browser keep the cache of the web pages. All the web pages should have content expiry header that tells the browser when the cache will expires. If the header is not set properly always the page will request the content from the source with every page hit. in order to ensure magento set correct content expiry header, we need to add the following block of code in htaccess file.

ExpiresActive On
ExpiresDefault "access plus 1 month"

2. Apache KeepAlive
Apache KeepAlive functionality is used to allow the TCP connection between client and server  to remain open connection to allow multiple request to be served over the same connection. this can be used to decrease the page load time on web pages especially with lots of images, since it removes the over head of having multiple connections opened. to use this functionalities, edit the /etc/apache2/apache2.conf  and find keep alive entries and enabled as follows. 

KeepAlive On
KeepAliveTimeout 2

the timeout parameter is unit of seconds.   

3. GZip Compression
Web pages can be compressed using Gzip between client and server, reducing the amount of data that needs to be transferred. even though the act of compressing and decompressing adds a performance overhead, there is a net gain in reducing the traffic for large pages. to use GZip compression, enable the mod_deflate module in apache and add the following to the vhost for the site.

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

4. MySQL Tuner:
MySQL tuner is a perl script that allows to analysis your database and gives recommendation which variables you should adjust in my.cnf to increase the performance. this can really help to increase the performance without the expensive hardware changes. to install and run this script follow the command.

bash$ wget http://mysqltuner.com/mysqltuner.pl
bash$ perl mysqltuner.pl

In the next articles we will continue the below performance optimization technique.
  • MemCached
  • PHP APC
  • Database Session Storage
  • Query caching