All about Magento E-commerce Store.......MagentoForum: SPEED UP MAGENTO WITH SIMPLE CONFIG TWEAKS

Thursday, July 28, 2011

SPEED UP MAGENTO WITH SIMPLE CONFIG TWEAKS


At Ionata we've been using Magento for quite a while now and the more sites we added, the slower our server seemed to become. Magento is quite a big chunk of software and can take up a lot of resources. However after doing some research and carefully tweaking our server configurations, we were pretty amazed to find performance gains of several hundred percent only by changing some settings.
In this post you'll find a summary of settings that can boost the speed and responsiveness of your Magento installation. Optimisation can be done for PHP, MySQL, Apache and Magento itself.

OPTIMISING PHP

The bottleneck here is the memory limit for PHP scripts. Older PHP versions came with a fairly low memory limit of 8 or 16 Megabyte. Edit your php.ini file and look for the following line:
memory_limit = 8M 
Try setting this to 128M if it is not already set. If you don't have access to thephp.ini (which is likely on shared hosting) you can also try setting the parameter from within a PHP file:
ini_set('memory_limit', '128M'); 
A third option is to change it from the .htaccess file in your Magento directory. Add the following line:
php_value memory_limit 128M 

OPTIMISING MYSQL

Very big potential for speed gains offers MySQL. Since database applications like Magento often use the same SQL queries over and over again, MySQL offers a query cache that is set with the have_query_cache andquery_cache_size parameters. The cache is disabled by default, but enabling can result in massive speed improvements. There is already an excellent article atCrucial Web Hosting about the importance of query caching and how to enable it, so I'll skip the details here and recommend you check it out.

OPTIMISING APACHE

Magento offers an option to enable ZIP (Deflate) compression for Apache. You can imagine that a big part of a typical Magento page (as the user can see it) actually consists of text: HTML, CSS and Javascript. Text files offer excellent compression ratios, so it only makes sense to run Apache with compression enabled to reduce the amount of data that needs to be transferred to the user. You can enable it from Magento's .htaccess file. Look for the following section:
<IfModule mod_deflate.c>  ############################################ ## enable apache served files compression ## http://developer.yahoo.com/performance/rules.html#gzip      # Insert filter on all content     ###SetOutputFilter DEFLATE     # Insert filter on selected content types only     #AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript      # 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> 
Uncomment the important lines so it looks like this:
<IfModule mod_deflate.c>  ############################################ ## enable apache served files compression ## http://developer.yahoo.com/performance/rules.html#gzip      # Insert filter on all content     SetOutputFilter DEFLATE     # Insert filter on selected content types only     #AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript      # 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> 

OPTIMISING MAGENTO

Last but not least there is potential to improve Magento itself, by enabling the built-in caches. Under System > Cache Management you should make sure that all caches are enabled. Usually caches should be disabled completely during development, but on a production server it is essential to enable all of them. Server load would otherwise increase significantly.

No comments:

Post a Comment