how to speed up your magento site
DESCRIPTION
Dilhan Maduranga - Software Engineer (PHP) & Prasad Kodithuwakku - Tech Lead (Training & Consulting)TRANSCRIPT
© 2014 Netstarter
● Many Features
● Complex Architecture
● Flexible Development
Performan
ce
© 2014 Netstarter
How to Speed up your Magento
Site
© 2014 Netstarter
Databas
e
© 2014 Netstarter
Case Study (3rd Party
Project)Product Listing Page Is REALLY Slow,
Client is Unhappy,
SEO issues
Default Magento Client’s Magento
System
response time
TTFB
(without FPC)
0.9 s 7 sec
© 2014 Netstarter
His Questions● Is it a problem of Magento ?
● 150,000 Products now, is it a problem ?
● Do we need additional CPU and RAM or
Bandwidth ?
● Any issue with the configuration ?
● Someone has Hacked our System ?
1
Query
© 2014 Netstarter
Data Types….
INT, TINYINT,VARCHAR etc….
INT column to store value from 1-10
VARCHAR to store Integers
What is the Rationale then ?
© 2014 Netstarter
Spaghetti Query
How can I do this with a single
query?It’s not always better,
Why?
• Difficult to do changes
• Cannot use Mysql cache
• Mysql poor performance with some
queries© 2014 Netstarter
Spaghetti Query (Contd.)• Hide dangerous issues - Better to Divide
and conquer
What is the Rationale then ?
© 2014 Netstarter
Use of IndexesUse Indexes with a plan, mistakes that we do..
● Define no indexes, or not enough indexes
● Defining too many indexes
● Running queries that no indexes can be used
○ SELECT * FROM table WHERE column LIKE
‘%test%’
What is the Rationale then ?
© 2014 Netstarter
Monitor Your Database
● Check the slow query log (in MySql)
● Use EXPLAIN in Mysql to Check the Query Execution
Path
● Rebuild Indexes : OPTIMIZE TABLE tbl_name
© 2014 Netstarter
Tools
● pt-index-usage
● pt-query-digest (Slow Query)
There are many other…..
© 2014 Netstarter
Achievement
• Listing page now loads within 1.5
seconds
• 85% Gain
© 2014 Netstarter
eCommerce Site
Performance• Site performance directly affects
conversion rate
• eCommerce sites has a lot of contents
and interactions
http://venturebeat.com/http://venturebeat.com/2013/03/26/speed-bump-load-times-at-top-2000-e-commerce-sites-down-22-in-one-year-infographic/http://www.yottaa.com/blog/bid/286821/eCommerce-and-Website-Performance-A-Look-Into-the-Industry
© 2014 Netstarter
Backend Caching ● Keeps prepared data
● Minimizes database queries (Reduce database
load)
What Default Magento Provides…
● Magento Cache
● Enterprise Edition comes with built in Full Page
Cache (FPC)
● Default caching engine is the SLOW File System
http://cdn.turnkeye.com/media/wysiwyg/services/performance/performance.png © 2014 Netstarter
Optimized Caching Alternative 01:
Memcached
http://memcached.org/
● Free & open source
● key-value based object caching
● Configured as 1st level fast cache for Magento
Limitations
● Doesn’t support tag based caching
● Database is used as the 2nd level cache
● No replication method implemented
© 2014 Netstarter
● Free & open source
● Magento officially recommend Redis
● For Enterprise 1.13.x and Community 1.8.x Redis is
built in.
Why it is so Good?
● Supports tag-based caching/cleanup
● Can work without DB (core_cache/core_cache_tag) tables
should stay empty
● Supports on-disk save and master/slave replication.
http://redis.io/images/redis-logo.svghttps://www.byte.nl/blog/wp-content/uploads/Redis-caching.jpg
Optimized Caching Alternative 02:
Redis
© 2014 Netstarter
Getting the Good of Both -
Netstarter Way● Cache and Full Page Cache - Redis
○ Supports Tag based caching
● User Session Storage - Memcached
○ Key/Value storage system fits sessions
○ Little bit faster than Redis
© 2014 Netstarter
Op-Code Caching
● Accelerates PHP execution
● No side effects other than extra memory usage
● Recommended for Production environment
Which Op-Code Cache?
● APC (Alternative PHP Cache)
● Xcache
● Zend OpCache Bundled with PHP 5.5.0 and later
© 2014 Netstarter
Content Delivery
Network (CDN) • A network of distributed servers deliver content
based on the geographic locations of the user
• Reduce the load on the main server
© 2014 Netstarter
General Tips
Further Quest for Performance● Proper Server settings
● Enable Magento Flat Catalog
● Varnish Cache - A Reputed Cache backend
● Host in the country where your customers are
● Minify and Merge Js and CSS
● Enable Gzip Compression in htaccess.
● Minimize redirects
● Have the site W3C compliant. Errors slow down the
browser
● Optimize images for web
● Use CSS Sprites
© 2014 Netstarter
Keep in Touch
● Check your page load with Magento
Profiler
● AOE Profiler will be a better option
● Use other web page optimization tools
● Use a server performance analyzer New
Relic
© 2014 Netstarter
Take Away
Design Develop Test
- for -
Performance
© 2014 Netstarter
Thank
You!
© 2014 Netstarter