Imagine you’re searching for a product in an online store and the search results just keep loading. What will you do? Skip that website and move to another. Right? Nobody will waste his time in such a situation when different options are available.
Since Magento stores are heavily loaded with product images, customized code, and other third-party tools, they can slow down your store’s performance if not optimized properly. Sometimes, these issues seem minimal, and we neglect them, but their impact can be huge.
In this article, I’ll tell you why speed matters, how you can test your store’s performance, and the best tips and extensions to help you with Magento 2 speed optimization.
Why Does Magento Speed Matter?
If a customer can’t stay for a few seconds, the same thing can happen in case you’re a store owner, and your customers leave, eventually affecting your business. According to Portent, if a website loads faster, it can have better conversion rates eventually, as shown below.
– Source: Portent
A slow website could directly impact conversion rate, convert visitors into customers, and also Search Result Pages (SERPs). In fact, search engines like Google also rank websites higher that are fast enough and offer a good user experience.
According to Magento Performance Toolkit, which compares various configurations, the metrics and case studies show that Magento 2 is more effective than Magento 1.x. And that’s why it’s highly recommended that you upgrade to Magento 2. Some of the key results are:
|Orders||Executes 39% more orders per hour than Magento 1. X|
|Catalog Browsing||Delivers nearly instant server response times on catalog and browsing pages.|
|Add to Cart||Server Response Time is 66% faster than Magento 1. X under 500 milliseconds.|
|Customer Checkout||Guest Checkouts are up to 51% faster and Customer Checkouts are up to 35% faster on Magento 2.|
How to Test Magento 2 Performance?
Testing site speed is the first step to evaluating how serious and where the problem is. Your team should perform speed tests regularly in a maintenance cycle to optimize and speed up Magento.
You can test Magento 2 speed using one of the 3rd-party services like Pingdom Tools, GTmetrix, WebPageTest, or Google PageSpeed Insights. You just need to insert your Magento store URL and run the tests.
Result of Magento 2 Store Speed
To give you a quick overview, here are a few sample results to show you different performance tests.
1. Google PageSpeed Insights
After scanning your website with the speed test tool, let’s move on to Magento 2 speed optimization tips. Although there are many tips that you can find online, these are the highly recommended tips to optimize your Magento store’s speed.
Magento 2 Speed Optimization Tips
Before optimizing your store with the following tips, please ensure it meets the latest Magento 2 system requirements.
- Choose Reliable Hosting
- Update the Magento Version
- Upgrade Package & Database
- Avoid Built-in Cache
- Keep Indexers Updated
- Use Varnish Cache
- Inspect Third-Party Modules
- Enable Magento Flat Catalogs
- Optimize Product Images
- Use Elasticsearch for Instant Results
- Enable GZIP Compression
- Integrate Content Delivery Network
- Clean Database Logs
- Switch to Production Mode
- Enable Advance JS Bundling
1. Choose Reliable Hosting
This is not just a tip, but more of a requirement that you must choose a hosting provider who is fast, secure, and reliable. If you end up with mediocre hosting, your Magento store will eventually suffer from performance and security issues.
Commonly, low pricing attracts us, but it comes with a huge cost in terms of time and effort since we mostly end up fixing our server issues. It’s highly recommended that you choose a managed hosting provider so you can only focus on growing your business.
Besides, there are Magento system requirements you must ensure in your hosting provider and see if your server meets them. For example, PHP 8.x, MariaDB 10.x, MySQL 8.x, Elasticsearch 7.x, Composer 2.x, etc.
– Source: Adobe Commerce
Need a managed hosting provider for your Magento 2 store?
Cloudways Platform is fast, secure, and meets all the Magento 2 system requirements for a fully functional store around the clock.
2. Update the Magento Version
The latest Magento releases offer new features, enhance bugs, and fix bugs to improve your site’s performance dramatically. Thus, the most basic and essential tip for improving Magento 2 speed optimization is to update your Magento store to the latest version.
If you are on Magento 1, it’s highly recommended you migrate from Magento 1 to Magento 2 to experience a better, more reliable, secure, and faster ecommerce solution.
In case you need to be more tech-savvy and find it challenging to migrate Magento 2 to another version, you can also check Cloudways’ free migration Service to get online with faster speed.
3. Upgrade Package & Database
When upgrading to the latest Magento version, component dependency conflicts may be detected with the different packages. Instead of manually fixing them, upgrade the packages and then perform the upgradation.
Usually, this happens to advanced users who have multiple PHP versions installed. To ensure, the first prerequisites of packages must be checked, which leads to the upgradation process being easier.
The minimum requirements of packages are:
|PHP version||>= 7.3|
|Composer||None (composer 2 for Magento 2.4.X)|
|Node.js||Node.js (^12.22.0, ^14.17.0, or >=16.0.0)|
|Memory limitations||At least 2GB RAM|
Note: Magento 2.4.x supports PHP 8.x.
4. Avoid Built-in Cache – Use Redis
Nowadays, Magento 2 speed and performance is a big concern many technologies are integrated with Magento 2 speed optimization, such as Varnish, Redis, Nginx, and even full-page caching solution.
4.1. Use Memcached or Redis
Both are the distributed memory caches that speed up Magento 2 large-scale web applications with dynamic databases. They reduce the load of database requests on servers and deliver cached data if an external data request allows it.
Redis is an optional back-end cache solution to replace Zend_Cache_Backend_File, which is used in Magento 2 by default. For PHP sessions, both caches are the right choice to use. You can configure Redis to handle over 60k session connections per second.
Opting for Redis integrates a high-speed backend cache with full cache tag support and no need for additional low-level file system cache. As a result, the performance is excellent and stable, particularly in high-traffic Magento stores.
4.2. Configure Redis for Session Storage
Following is a sample configuration to add to <your Magento install dir>app/etc/env.php:
'session' => array ( 'save' => 'redis', 'redis' => array ( 'host' => '127.0.0.1', 'port' => '6379', 'password' => '', 'timeout' => '2.5', 'persistent_identifier' => '', 'database' => '2', 'compression_threshold' => '2048', 'compression_library' => 'gzip', 'log_level' => '1', 'max_concurrency' => '6', 'break_after_frontend' => '5', 'break_after_adminhtml' => '30', 'first_lifetime' => '600', 'bot_first_lifetime' => '60', 'bot_lifetime' => '7200', 'disable_locking' => '0', 'min_lifetime' => '60', 'max_lifetime' => '2592000' ) ),
Magento 2 also provides the command to set up and configure Redis, run setup:config:set command and set the following parameters.
bin/magento setup:config:set --session-save=redis --session-save-redis-<parameter_name>=<parameter_value>...
You can check all the details about the parameters and verify that your Redis installation works fine with your Magento store.
4.3. Configure Redis for Default Cache
There are two ways to configure Redis for the page and the default cache. You can manually edit <Magento install dir>app/etc/env.php file or use the command line, which is the recommended method because it also provides validation.
For the default cache, run the following command:
bin/magento setup:config:set --session-save=redis --session-save-redis-<parameter_name>=<parameter_value>...
Specify parameters that are specific to Redis default caching.
For the page cache, run the following command:
php bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=redis.example.com --page-cache-redis-db=1
This command enables Redis page caching, sets the host to redis.example.com, and assigns the database number to 1. You can check all the details on the Magento DevDocs.
5. Keep Indexers Updated
Magento allows you to work with bulk data, reducing the load time. To overcome this, Magento needs to reindex its indexers because the core system updates indexers on every object stored by default. However, the process is imperfect, and you must manually update the indexers.
Magento indexers can be set to two modes: “Update on Save” or “Update on Schedule.” The best mode to set the indexers is to “Update on Schedule.” In this way, they execute the cron job at a specific time that you set. It’s recommended you choose a time when the traffic on your website is low.
For Magento 2, you need to execute the following CLI command on the root directory using the SSH terminal:
php bin/magento indexer:reindex
You can change the indexers mode to “Update on Schedule” by running the command:
php bin/magento indexer:set-mode schedule
You can change the indexers mode to “Update on Save” by running the command:
php bin/magento indexer:set-mode realtime
And here it is in Magento Admin:
- Log in to Magento Admin and navigate to System → Index Management.
- Select all indexers, and from the Actions dropdown, select Update on Schedule.
- Click Submit to set the schedule.
You can also configure the Scheduled Tasks from Magento Admin.
- Navigate to Store → Settings → Configuration → Advanced → System → Cron (Scheduled Tasks)
- Expand Cron configuration options for the group: index and configure the scheduling process accordingly.
6. Use Varnish Cache
Regarding response time with Magento 2, the built-in cache is quite good, with approximately 0.5s, but it is not as ideal as Google recommends. Due to that, Magento 2 supports Full Page Cache via Varnish natively. Magento 2 has a built-in Varnish solution that offers a perfect performance combo with visible results.
In the previous versions, users had to install modules like “Phoenix” or “Turpentine” to integrate Varnish with the Magento platform. With Magento 2, Varnish integration is provided by default, resulting in better Magento 2 performance.
You can enable a Varnish cache to drastically improve your Magento store’s speed performance. Follow the detailed guidelines on how to install and configure the varnish cache.
- Navigate to Stores → Settings → Configuration → Advanced → System → Full Page Cache.
- Click Varnish Caching in the Caching Application list.
- Enter a value in TTL for the public content field.
- Expand Varnish Configuration and configure the information.
7. Inspect Third-Party Modules
It’s highly recommended that you audit third-party extensions installed on your Magento store. For this, turn off every module one by one, clear its cache, and see if this impacts the store’s performance.
Test all the essential CMS pages (home, category, product, checkout pages). If you disable a Magento module and the store becomes faster, you have found the issue.
Immediately contact the extension providers/developers, ask for a refund, and inform them about the issue you faced.
8. Enable Magento Flat Catalogs
All the stored data is saved in an Excel-like Magento database. When the limits are hit, it “spills over the extra data.”. As a result, the store slows down considerably.
You may reduce the impact of the “spilled” data by enabling Magento Flat Catalog Category and Flat Catalog Product. As a result, you will notice an improvement in the store’s performance.
Magento generates and updates flat tables on every indexation. You can enable flat tables by logging into Magento Admin as an administrator:
- Go to Stores → Configuration → Catalog → Catalog → Storefront.
- Select Yes to Use Flat Catalog Category.
- Select Yes to Use Flat Catalog Product.
- Click Save Config.
8.1. Disable Flat Catalog Category
By default, the enabled flat category has been optimizing Magento 2 speed for many years. But in newer versions from Magento 2.3.x and above, Magento architecture has changed completely. That’s why Magento no longer recommends flat catalogs because of indexing issues and the risk of performance degradation.
Before disabling the feature, it is important to check all extensions that are required to work with the flat catalogs.
To disable Flat Catalogs:
- Navigate to Stores → Configuration → Catalog.
- Expand the Storefront section.
- Set No in the Use Flat Category and the Use Flat Catalog Product fields.
On the other hand, flat catalogs still work well with Magento 2.1.x and Magento 2.2.x versions. You can shorten the reading speed of the database by enabling Flat Category and Product.
9. Optimize Product Images
The image size impacts the website’s speed. Hence you need to ensure your images are properly optimized and have a good ratio between quality and size.
In the older technique, the server downloads the content images as the page loads. To overcome this, Magento uses lazy loading, which means loading images after the page is fully loaded, or while the user scrolls through the catalog.
You can also use AWS or a CDN to deliver your content much faster. Check if your images are properly optimized and have a good ratio between quality and size.
- Put the Magento store on production mode.
- Go to Stores → Configuration → Advanced → Developer.
- Click Save Config and Flush Cache on System → Cache Management page.
To enable CSS minification, the following steps are required:
- Enable the Magento store in production mode.
- Go to Stores → Configuration → Advanced → Developer → CSS Settings.
- Set Minify CSS Files option to Yes.
- Click Save Config and Flush Cache on System → Cache Management page.
11. Use Elasticsearch for Instant Results
Elasticsearch provides full-text searching at a very high speed. It offers a fast web content search capability because the indexing service runs on the server instead of searching the entire database for the match.
For store owners running many products, Elasticsearch provides a way to speed up search results and catalog pages. Magento 2.4.x and later versions come up with Elasticsearch pre-enabled with default settings. But for earlier versions, you can configure it by following the steps below:
- Go to Stores → Settings → Configuration.
- Navigate to Catalog → Catalog → Catalog Search.
- Click Elasticsearch from the Search Engine.
- Click Save Config.
You can also refer to this official guide that explains how to configure Magento with Elasticsearch.
12. Enable GZIP Compression
Compression is an efficient way to load the contents faster and speed up your store.
When it comes to Magento 2, the server is handling many requests at a time so configuring GZIP compression is an excellent fit to manage the load time of the CPU and decrease the bandwidth usage.
The key reason is that it reduces the time it takes for a website to download page files and style sheets, eventually reducing your website’s load time. That’s the helpful way for the speed optimization tip.
12.1. How to Enable GZIP Compression
To turn on gzip compression and activate the mod_deflate module of Apache, add the following commands in the .htaccess file and uncomment the appropriate lines as shown below.
Note: The mod_deflate module compresses static resources into smaller files before transferring them to the browser.
13. Integrate Content Delivery Network
It’s recommended to configure CDN for your Magento stores to serve a better shopping experience to your audience.
To enable CDN, follow the below steps:
- Go to Store → Configuration → General.
- Under the General tab, click on Web.
- Expand the Base URLs section and do the following:
- In the Base URL for Static View Files field, enter the URL of the location on the CDN where static view files are stored
- When complete, click Save Config.
14. Clean Database Logs
Despite its market share and performance benchmarks, Magento’s database still needs improvement. One common reason behind this is the space taken up by the logs. The database performance improves significantly when removed because of the decreased lag in process execution.
Note: It’s recommended to take a recent backup before making new changes to the database.
Also, Magento automatically & frequently generates new log files, so removing the old ones should not cause any problems. To set the logs time, follow these steps:
- Navigate to the Stores → Configuration.
- Expand the Advanced → System and open the MySQL Message Queue Cleanup section.
- Set the specific amount of time in New Messages Lifetime to automatically clean the old log files.
- Once complete, click Save Config.
15. Switch to Production Mode
Many developers need to catch up on running the Magento 2 store live environment in Production Mode. Make sure this is a priority on your Magento 2 speed optimization checklist.
Magento 2 has three modes; Default, Developer, and Production. The Production Mode is optimized for performance and ensures a great user experience.
The CLI command to see the current mode is:
php bin/magento deploy:mode:show
Production mode can either be enabled using a single command:
bin/magento deploy:mode:set production
The CLI command to switch to developer mode is:
php bin/magento deploy:mode:set developer
Rr can be broken into multiple steps if desired to give developers additional control over the process:
php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f
16. Enable Advanced JS Bundling
Due to this inefficiency and to build bundles so that each page in our store will only need to download a common bundle, there is an alternative — advanced JS bundling.
It allows you to reduce the number of HTTP requests to the server and decrease the size of JS files, the same as the regular JS bundling. However, advanced JS bundling eliminates the need to load all of the bundles for all pages requested by a browser.
Each page has a certain set of requireJS dependencies. To satisfy the need of each page you don’t need all of the bundles, just a couple of them.
Therefore, to enable advanced JS bundling, you need to define bundles by page types (CMS pages, product, category, checkout) or purpose (shipping features, checkout features, product-related features).
A clean Magento installation allows reaching enough good performance by splitting bundles by page types, but some customizations may require deeper analysis and other asset distributions.
Magento Speed Optimization Extensions
Here’s a list of the best Magento 2 speed optimization extensions that can enhance the performance of your stores.
1. Magento 2 Page Speed Optimization Extension by Weltpixel
Speed is becoming increasingly important for online stores as more people switch to online shopping. A page that loads in over 2 seconds can lose many customers! With the WeltPixel Speed Optimization extension for Magento 2, you can easily implement Magento’s Advanced JS Bundling, reducing page size and loading times.
The extension also helps boost your Google Page Speed Insights (Core Web Vitals) score, which will help with your overall ranking and SEO!
- Free lifetime updates
- 1-month free support, with the option to extend
- Monthly or each time a new Magento version is released
- Open Source (CE): 2.2, 2.3.x, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5
- Commerce on prem (EE): 2.2, 2.3.x, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5
2. Accelerated Mobile Pages by Plumrocket
Accelerated Mobile Pages (AMP) for Magento is based on an open-source project supported by Google and Twitter (ampproject.org). The idea behind the project was to make all mobile pages load faster. This plugin is an open-code solution that makes the website AMP-friendly without additional integration with third-party services.
- This lightweight extension minimizes HTTP requests to speed up page load time.
- Extensions help to automatically generate Google AMP Pages for the Homepage, Category Pages, Product Pages, CMS Pages, etc.
- It allows easy editing of AMP homepage content from the Magento backend.
- AMP extension works smoothly with any native or third-party Magento 2 themes.
- Free technical support is available for the first 3 months.
- Open Source (CE): 2.0, 2.1, 2.2, 2.3
- Commerce using on prem (EE): 2.1, 2.2, 2.3
3. Cron Scheduler by KiwiCommerce
With the help of this Cron Job Scheduler, you can easily set up cron jobs and run them as per your business requirement. You will also get access to cron jobs management options where you can enable, disable and delete them depending on your business needs. If a scheduled cron job leads to a fatal error, the email feature sends an email to the previously configured email address.
- Displays the complete history of cron jobs, their status, runtime results, and other details.
- Tracks for the longest-running cron jobs and kills them if they are no more required.
- Finds the actual load on CPU and RAM due to cron job execution.
- Open Source (CE): 2.1, 2.2, 2.3
- Commerce on prem (EE): 2.1, 2.2, 2.3
- Deferred JS
- Minimize JS code, improve reduce loading and execution time.
- Open Source (CE): 2.1.0 – 2.4.5
- Magento 2 Open Source (CE): 2.1.0 – 2.4.5
- Magento 2 Commerce using on prem (EE): 2.1.0 – 2.4.5
- Magento 2 Commerce on Cloud (ECE): 2.1.0 – 2.4.5
5. Image Optimizer for Magento by Apptrian
Image Optimizer for Magento helps optimize the image formats and reduces the file size without losing the quality. You can easily optimize images by clicking a button or setting up a configurable cron job.
This extension is fully configurable and compatible with Google Perceptual JPEG encoder, Guetzli. However, you need to install Guetzli and configure the extension to use it.
- Use the 64-bit utility option that allows you to run 64-bit versions of utilities.
- Option to set cron expression for scan, reindex, and other Magento optimization processes.
- Convenient Progress Bar that gives info about the percentage and number of optimized images.
- Open Source (CE): 1.5, – 1.9.4
- Magento 2 Open Source (CE): 2.0, 2.1, 2.2, 2.3
- Magento 2 Commerce using on prem (EE): 2.2, 2.3
- Magento 2 Commerce on Cloud (ECE): 2.2, 2.3
6. Full Page Cache Warmer by Amasty
Magento 2 is already well-optimized for high loads and supports full-page caching and Varnish by default. So why use this Full Page Cache Warmer extension for Magento 2? Because it offers the solution for the common problem of cache updating for several reasons. Using this extension, you can automate the cache warming process to make it invisible to customers and ensure a smooth shopping experience.
- Prioritize pages and exclude pages from warming.
- Use the debug to check if the extension works properly.
- Compatible with Magento 2 Varnish Cache and default file cache
- Automate the cache warming processes.
- User-friendly interface.
- Exclude particular blocks from the cache to enhance the selection
- Open Source (CE): 2.4.5,2.4.4-p1,2.4.4, 2.4.3-p3, 2.3.7-p4, 2.3.7
- Commerce on prem (EE): 2.4.5,2.4.4-p1,2.4.4, 2.4.3-p3, 2.3.7-p4, 2.3.7
7. Enhanced Autocomplete by Wyomind
Enhanced Autocomplete extension allows you to improve (and boost) the default Magento 2 search results by displaying relevant results about products, CMS pages, categories, and search suggestions. Visitors enjoy an ultra-fast searching mechanism with the help of an Elasticsearch server.
- It helps to highlight the keywords in the search result.
- Offer search terms suggestions such as “Did you mean?”
- Browse the indexed data directly from the admin panel.
- Capable enough to handle thousands of products easily with ultra-fast indexation.
Open Source (CE): 2.3
Commerce on prem (EE): 2.3
8. Google Page Speed Optimizer by Amasty
Enter the green zone in Google PageSpeed Insights without custom development – use the Magento 2 Speed Optimization solution. Improve store performance to meet Google requirements and simultaneously provide customers with a next-level shopping experience.
- Code Structure optimization
- Improve page speed performance
- Load content faster with fewer bytes to download, such as Images
- Capable enough to handle content without losing quality and compatible with third-party extensions.
Open Source (CE): 2.4.5-p1,2.4.5,2.4.4-p2,2.4.4-p1, 2.4.3-p3, 2.3.7-p4
Commerce on prem (EE): 2.3
Some important things to keep in mind:
- JS Bundling Requires Strict Coding Regime and may not work correctly with 3rd Party Modules. This should be based on Load Tests: Result Comparison with and without this setting.
- Catalog Events Settings are related to this feature’s usage/lack of usage.
- To Update / Enable Frontend Performance Improvements Features please execute:
- php bin/magento config:set dev/template/minify_html 1
- php bin/magento config:set dev/js/merge_files 1
- php bin/magento config:set dev/js/minify_files 1
- php bin/magento config:set dev/css/minify_files 1
Speed is a dominant factor in the success of an ecommerce store. A fast-loading Magento store responds quickly, converts better, and brings happiness to visitors, which automatically leads to increased sales and revenues.
On the other hand, a slow Magento web store would make customers run away from the store, resulting in a loss of sales and a serious hit to the brand’s reputation. This is why Magento developers must know how to optimize Magento performance.
Frequently Asked Questions
- Why is Magento so slow?
- You can find it by the list in the app/etc/ directory.
Magento isn’t actually slow! It becomes slow when it isn’t optimized properly since it was built on heavy architecture with complex design patterns. Ensure you strictly follow the optimization techniques to maximize your Magento store performance.
- Which Mode Is Faster in Magento 2?
- Magento 2 has three running modes: default, developer, and production. Production mode is the fastest one and is used to power live sites. Besides, if you want to tweak the store, you might want to switch to developer mode.
Customer Review at
“Great speed, features, knowledgebase, dashboard, UX and fast, expert support. Very happy!”
Stefan [Management Consultant]
Jyotishina is the Magento Community Expert at Cloudways and has 4 years of experience in web development. She has worked on e-commerce sites since the turn of the millennium and was working with Magento before version 1 was released. She loves to travel and explore new ideas whenever she finds time. Get in touch with her at [email protected]