magento e commerce performance optimization

25
Magento eCommerce Performance Optimization Ashish Purohit Ranosys Technologies Pte Ltd 30 Apr 2013

Upload: ranosys-technologies-pte-ltd

Post on 25-Jun-2015

1.423 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Magento e commerce performance optimization

Magento eCommerce Performance Optimization

Ashish Purohit

Ranosys Technologies Pte Ltd

30 Apr 2013

Page 2: Magento e commerce performance optimization

What we will discuss today?

What is Magento?

Comparison with other eCommerce platform

What people think about Magento?

Performance optimization

Tools and utilities

Page 3: Magento e commerce performance optimization

What is Magento?

Open source rich eCommerce platform developed on PHP Zend

framework

First stable release in 2008 by Varian now known as Magento

Comes in three variant

Community edition

Magento Go – Magento hosted solution

Enterprise edition

Acquired by eBay in 2011

More than 4 million downloads after first stable release

Flexible Extendable Modular Upgradable Scalable

Page 4: Magento e commerce performance optimization

Comparison with other platform

Page 5: Magento e commerce performance optimization

Comparison with other platform

Magento is leader in this domain.

Page 6: Magento e commerce performance optimization

What people think about Magento?

User experience is leggy.

Page 7: Magento e commerce performance optimization

Truth behind it

Magento is resource intensive

Magento is based on EAV database model means to retrieve a single

information we need to go through many queries and tables.

Giant XML trees in memory and then "querying" those same trees for

information. This takes both memory (storing the trees) and CPU (parsing

the trees). Some of these (especially the layout tree) are huge. Also,

unless caching is on, these tree are built up from files on disk and on

each request.

Magento uses its configuration system to allow you to override classes.

This is a powerful feature, but it means anytime a model, helper, or

controller is instantiated, extra PHP instructions need to run to determine

if an original class file or an override class files is needed. This adds up.

Page 8: Magento e commerce performance optimization

Solution

Identify the server resources available. – Type of hosting server, Web

server, RAM, CPU etc

Product catalog – Number of categories, products etc

Number of expected simultaneous users

Understand critical parameters for making optimization strategy

Optimization methods are available/ applicable depending

upon the nature of web server and Magento store

Page 9: Magento e commerce performance optimization

Optimization through Magentoconfiguration

.htaccess configuration

Web server and browser configuration

MySQL configuration

Solutions

Page 10: Magento e commerce performance optimization

Optimization through Magento configuration

Use flat catalog navigation.

Using this, we address EAV data model issue for running multiple

queries.

When enabled, it store products and category information in

one table for each.

It is recommended to use flat category navigation in all

Magento website

Flat product navigation will be helpful when you have more than

1000 SKUs

Page 11: Magento e commerce performance optimization

Optimization through Magento configuration

How to enable flat catalog navigation?

System->Configuration->Catalog {Frontend option}

Page 12: Magento e commerce performance optimization

Optimization through Magento configuration

Merge JS and CSS files.

Using this option, we address issue of multiple HTTP requests.

When enabled, it merge all JS and CSS files and reduce HTTP

requests.

Important: While enabling this feature you may face issue of

Javascript confliction when multiple JS frameworks used.

Page 13: Magento e commerce performance optimization

Optimization through Magento configuration

How to merge JS and CSS files?

System->Configuration->Developer {JS, CSS settings}

Page 14: Magento e commerce performance optimization

Optimization through Magento configuration

Compile Magento.

Using this option, we address issue of loading large framework in

background by running through multiple directory structure.

When enabled, it merge various PHP files into one large file and

store them on location “includes/src”. Therefore instead of

reading multiple directories on entry point it will look at only

location.

It improves Magento performance by 25-40%.

Important: Once enabled, you can’t upgrade Magento store

and modify any core settings including core files. If you want to

do then decompile Magento first and modify it.

Page 15: Magento e commerce performance optimization

Optimization through Magento configuration

How to compile Magento?

System->Tools->Compilation

Page 16: Magento e commerce performance optimization

Optimization through Magento configuration

Disable Magento logs

Using this option, we address issues consuming more CPU cycle

and diskspace.

When enabled, Magento stops writing logs for any error or

exception. If any time needed for debugging then we can

enable it again.

Page 17: Magento e commerce performance optimization

Optimization through Magento configuration

How to disable logs?

System -> Configuration -> Advanced -> Developer {Log Settings}

Page 18: Magento e commerce performance optimization

Optimization through Magento configuration

Enable Magento cache

System -> Cache Management

Helps in loading website faster

Page 19: Magento e commerce performance optimization

.HTACCESS tweaks

Enable gzip compression

<IfModule mod_deflate.c>AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascriptBrowserMatch ^Mozilla/4 gzip-only-text/htmlBrowserMatch ^Mozilla/4\.0[678] no-gzipSetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

</IfModule>

Use header expires

<IfModule mod_expires.c>ExpiresActive OnExpiresDefault “access plus 1 month“ExpiresByType image/x-icon “access plus 1 month”ExpiresByType text/html “access plus 1 month”ExpiresByType image/plain “access plus 1 month”ExpiresByType image/css “access plus 1 month”ExpiresByType application/x-javascript “access plus 1 month”ExpiresByType application/x-shockwave-flash “access plus 1 month”

</IfModule>

Page 20: Magento e commerce performance optimization

.HTACCESS tweaks

Enable Apache KeepAlive and disable EtagFileEtag NoneKeepAlive OnMaxKeepAliveRequests 100KeepAliveTimeOut 5

Page 21: Magento e commerce performance optimization

Web server and browser configuration

Use Varnish Cache.

Use PHP cache accelerator like APC, eAccelerator, Xcache.

Use CDN to deliver static contents of your websites.

Do not use too many external sources for images, iframes.

Install only minimum required modules on server.

Deploy on Nginx or Litespeed server.

It is recommended not to use Magento on cheap hosting.

Page 22: Magento e commerce performance optimization

MySQL configuration

Increase InnoDB buffer pool - Magento uses InnoDB storage engine

which, uses memory pools to cache tables data, indexes to reduce

disk I/O. Less disk I/O means faster access to data, indexes etc. The key is to assign as much memory as possible for in-memory cache.

innodb_buffer_pool_size = 512M

Multithreading - Innodb can use multiple cores of server processors to

give concurrent connection. The key is to use this ability to boost concurrent connections. Magento recommends to calculate

“innodb_thread_concurrency” value by equation

innodb_thread_concurrency = 2 x [# of CPUs] + 2

Page 23: Magento e commerce performance optimization

MySQL configuration

Enable query cache - MySQL can cache results for queries and return

it from cache, when identical query is done. For example queries

running for home page will be almost identical for another home

page view. Enabling the cache can save a lot of rework on MySQL

end.

query_cache_size = 32M

Enable sort buffer

sort_buffer_size = 4M

Page 24: Magento e commerce performance optimization

Performance measuring & optimization tools

Magento speed testerURL - http://www.magespeedtest.com

Speed monitoringURL - http://mon.itor.us/

URL - http://www.pingdom.com/

Fooman Speedster – For combining, compressing and caching JS

and CSS files.URL - http://www.magentocommerce.com/magento-

connect/FOOMAN/extension/457/fooman-speedster

Page cache – with full page cache which is by default not

available in community edition of Magento.URL - http://www.magentocommerce.com/magento-

connect/pagecache-powered-by-varnish.html

Page 25: Magento e commerce performance optimization

Q&A

Email: [email protected]

Linkedin: http://sg.linkedin.com/in/ashishpurohitin