An Action Plan for Speeding Up Magento 2 – Culprits and Solutions Explained
Judging by the number of available Magento performance optimization tips, retailers should not be bothered with slow-loading websites. However, they often don’t see a positive result from applying random techniques without determining the core problem. With our input, we aspire to create a big picture and explain why many online retailers keep on struggling with speed issues given that Magento 2 is not slow by default. As optimizing Magento performance is a task for a Magento support team, we won’t delve into much technical detail now. Rather, we intend to focus on developing an action plan for businesses starting from detecting a speed problem to understanding its root cause and envisaging a solution.
What are wake-up calls
The figures say that an ecommerce company selling $100,000 per day potentially loses $2.5 million a year due to a seemingly minor one-second page delay. Surely, this impels retailers to question: “Should I be worried?” Here are the cases when they should.
- Low Google ranking. Though not as weighty as the page relevancy, website speed is one of the factors Google uses to rank websites. And this is hardly surprising as Google’s algorithm evaluates websites in terms of the overall user experience they provide. Thus, poor performance can frustrate the entire SEO strategy developed for moving the web store up in search results.
- Poor sales KPIs. If the efforts put into promoting a business, attracting and retaining customers don’t pay off, and the rates for traffic and conversions remain troubling, it makes sense to check the speed. Potential customers may come but be impatient to wait until the website loads and leave without meaningful engagement.
- The gut feeling of bad customer experience. If a retailer browses through their own website and senses a hint of irritation at slow loading pages, potential customers most likely also do. Moreover, if the website loses in speed to competitors, the time is to face up to performance optimization.
How to ascertain the speed problem
There are website speed test tools to translate guesses into precise figures. In our practice, we have been working with GTmetrix but can expect other options to be quite similar (Pingdom or WebPageTest are possible alternatives).
For a one-time performance check, retailers enter their URL, let the system run through their website and get a performance report with page load time, detected bottlenecks and optimization recommendations. Of course, the recommendations are not targeted specifically for each website but generated based on best practices. This part so far is free of charge.
Fee-based services include regular performance monitoring (scheduled daily, weekly or monthly) and setting up email alert notifications in case of detected issues. There are several pricing packages for that depending on the number of URLs a retailer wants to monitor, custom filters in reports (for example, a user can filter website pages where monitoring or alerts are enabled) and more.
One speed problem – several possible reasons and relevant solutions
In case a speed problem exists, retailers must first understand that optimizing Magento performance is not about changing a few general settings. It starts with identifying and addressing the reasons for slow performance. There are three critical aspects to consider.
1. A server aspect
Server response time is a fundamental criterion for assessing website performance. Having clicked a website page in a browser, a user initiates some sort of interaction between the browser and the website hosting server. The browser starts with a request message to the server asking to send back a copy of the page. The server makes tens or hundreds of queries to the database to assemble the page and responds with a set of separate website files called data packets. These are page components like text blocks, imagery, or banners. Now, the browser needs to bring all the packets together into a complete website page and display it to the user. In the worst-case scenario, this process takes up to several seconds.
Problem #1. Caching dynamic content
Using caching is a proven way to optimize the performance of websites with static content. It implies that the server stores and delivers a current version of website pages and, therefore, doesn’t need to make multiple queries to the database. Given that Magento offers to set full page cache, it may seem the best way to optimize the website performance. However, the technique appears to be fraught with difficulties on ecommerce websites where dynamic content is used extensively.
Speaking of a typical online shopping journey, a customer visits seven key page types – a home page, a product listing page, a product details page, a shopping cart, checkout, my account, and a content page (e.g., a blog post). All of them may have content that changes in line with a customer’s actions. Let’s say a home page features new arrivals displaying different items upon each page refresh. A product details page has a block with recently viewed products. The checkout page has a saved shipping address and an order relevant for this exact customer. A simple solution would imply designating blocks with static content as cacheable and ones with dynamic content as not cacheable, but Magento 2 doesn’t allow for that. The question arises – is it possible to apply full page caching and speed up an ecommerce website?
Solution #1. Magento UI components
Magento itself offers a solution for caching dynamic content. When building dynamic parts of a page, developers use UI components (either available out of the box or custom). These components support JavaScript elements running in the browser. Thus, with full page cache activated and UI components added to the page, the process of browser-server interaction look as follows. Upon the browser request, the server retrieves the cached HTML page and JavaScript examines the response and updates only dynamic parts.
Problem #2. Physical distance
The data travels between the browser and the server via physical networks. Naturally, the greater this distance is, the longer the data transfer takes. Let’s say when a shopper in Paris opens a website with its server located in New York, the data has the whole Atlantic Ocean to go through. In this regard, companies must factor in their target audience when choosing the server location.
However, ecommerce businesses may find it hard to follow this recommendation. Offering the possibility of international delivery, they have potential customers scattered all over the world.
Solution #2. A Content Delivery Network
Instead of relying on one server, retailers can set a network of strategically located servers (called a Content Delivery Network, or CDN) to cover the key regions where their visitors come from.
The network consists of an origin server and a certain number of edge servers. As the name implies, the origin server is the primary data source where all the website files are hosted. It caches the content and sends it to edge servers. As a result, a browser request always starts by going to the nearest edge server and checking whether the page has been cached. The two possible scenarios may follow:
- If the edge server has a page cached, it delivers the response to the browser, thus reducing latency and accelerating page load time.
- If the edge server doesn’t have a page cached, the request proceeds to the origin server and gets the data retrieved from there.
2. A code aspect
The open-source nature of Magento tops the list of “pros” in choosing this ecommerce platform. Retailers who find the default functionality not enough for their business and opt for a customized solution either purchase third-party box solutions or engage experts providing Magento services to build the required functionality for their business. However, it’s in no way the quality of custom code is guaranteed. And low-quality code results in heavy queries going from the server to the database.
Solution. Code assessment
If the cooperation with the current Magento development or support team has resulted in website performance issues, the time is to grow suspicious. By engaging third-party experts to conduct full code audit of the website, retailers get the second opinion about the quality of all the modifications made to the out-of-the-box Magento application including custom code, theme, and third-party modules. The purpose of code assessment is to identify Magento performance killers and dangerous core logic changes. With an audit report in hand, retailers may plan and negotiate remediation activities.
3. A visual aspect
A strong focus on visual presentation is specific for ecommerce websites (online shoppers hardly expect and welcome tons of textual information). Naturally, retailers make multimedia a central part of their content strategy. But as much as rich imagery contributes to customer experience, it increases web page weight and can lead to slow loading times.
Solution. Image optimization
By optimizing images, retailers strike a balance between delivering high-quality images while keeping their smallest possible size. There is a number of solutions available to automate this task. Retailers can search for a native Magento plugin or an image optimization tool that works with Magento (ImageKit as one of the possible options).
Keep evolving and keep monitoring Magento performance
The action plan for speeding up a Magento application would be incomplete without one more recommendation. An ecommerce business doesn’t stand still – it evolves, new goals and challenges appear and, as a result, an underlying ecommerce solution gets transformed. Constantly monitoring the website performance is important as newly released functionality can negate all the efforts put into performance optimization. In Magento, there is the Performance Toolkit that allows testing the way new customizations affect the website performance.
To conclude, we want to stress once again – effective optimization of Magento performance starts with auditing a website and determining a reason for its slow response time. Thus, ecommerce companies save financial and time resources spent on practicing random optimization techniques and develop a good understanding of a required solution instead.