Based on the experiences from two of the biggest Magento projects we have delivered to date we will explore how to plan and deliver a Magento site that can support even the biggest traffic requirements.
What do you need to know about your users before you begin planning. How can you make accurate predictions about how your site will perform. Where are your efforts best invested to ensure that your site stays up and that your users spend money. What technology can we use to increase site performance and capacity. What services can help us support peaks in traffic and how do we know it is working.
What lessons have we learned and how did our plans perform over the duration of a business critical promotion period.
Planning for and dealing with high trafﬁc volumes
on your Magento store
WHO AM I
• Alistair Stead ~ @alistairstead
• Technical Assurance Manager @ Ibuildings UK / Session Digital
• Lead Magento projects for:
• Warner Music International
• Your client has a sale every year on the same day.
• They have a loyal customer base who know about the sale.
• They have sent over 5 million email advertising large savings.
• The sale prices and products must all go live at 08:00 on sale
Thats a lot of people waiting at the door!
WHAT ARE THE EFFECTS OF
HIGH TRAFFIC VOLUMES
• Initial site slowdown as requests are queued.
• Eventual failure to respond to requests.
• Inaccessible servers for any service
• No effect just business as usual.
WHERE SHOULD WE FOCUS
• Optimising code factors such as DB queries or poorly thought
• Reduce the page weight by optimising or removing elements.
• Reduce the number of HTTP requests.
HOW DO WE FIND
BOTTLENECKS IN THE CODE
• Cache Grind (WebGrind, CallGrind) http://bit.ly/Hwﬂ42
• XHPROF http://bit.ly/HweQXM
THEN WE NEED TO START TO
EXPAND THE TECHNOLOGY
• Lightweight faster servers (Apache, Nginx, Lighttpd)
• Gateway caches (Varnish, Squid, Hardware cahing)
OFF LOAD REQUEST TO
• CDN (Content Delivery Network)
• Split the load using sub-domains to other servers
MONITORING UNDER HIGH
• Many monitors and top
HOW TO ESTIMATE TRAFFIC
• Acceptable response time.
• Number of requests.
• Number of concurrent requests.
C = (N*L) * (R / T) * D
• C = Number of concurrent connections to handle based on the estimated trafﬁc volume.
• N = Total number of unique users.
• L = Average user journey length in requests.
• T = Total time in which the trafﬁc will visit the site.
• R = Average time of one request to be served by the system.
• D = Deviation in trafﬁc pattern.
266 = (40,000 * 10) * (2 / 3600) * 1.2
PROFILING UNDER LOAD
• Apache Bench
Web Web Web Web Web Web Web
Planning for your next big promotion
HOW TO DEAL WITH THE
• Have a plan for even the most unexpected events.
• Even if you have agreed not to change content plan a solution.
• Consider temporarily revoking the clients access to the admin.
• Delay import, export and indexing until later.
PLAN FOR CACHE
• The default magento cache will expire approx. every 6 hours
• If this happens during a trafﬁc peak your CPU will melt.
• Temporarily set a far future cache expiration date.
Trouble is on the way!
• Don’t assume this will not happen, it will!
• Have a plan of how to deal with it.
• Better yet create an architecture that can support the trafﬁc
with a completely cold cache.
• Under normal events your very unlikely to consider this.
• Adding many more servers can start to expose network
• Read the ﬁne print from your hosting company.
• Do not assume the capacity of switches conﬁrm it!
ALTERNATE CACHE BACKEND
NO CACHE BACKEND
NO CACHE BACKEND
LOG TO AN ALTERNATE
• Logging in Magento is key to some admin functions.
• But this results in many DB queries per page request.
• Exception logging is ﬁle based and not suitable to be shared
• global/log/core/writer_model Specify a more appropriate log
• Image cache and generation
• SOA (Service Orientated Architecture)
• HMVC (Hierarchical MVC) http://bit.ly/HwpqOj
Don’t wait for any of these issues on promotion day!
• Email: [email protected]
• Skype: astead-ibuildings
• Twitter: @alistairstead
WE ARE HIRING!