Site icon GetPageSpeed

Magento 2 Performance Checklist

Magento 2 is good and great, but it is a very large framework with many files. If installed on a misconfigured server, Magento 2 performance can lead to a store that your customer will leave immediately.

Let’s review best practices and software required to run Magento 2 with excellent performance.

1. Use latest PHP 7

Magento 2 is 100% compatible with the latest versions of PHP 7, which is all about performance. PHP 7 performs twice as fast compared to previous versions.

Order professional Magento 2 server setup to get your new Magento 2 store up and running with PHP 7, Varnish and Percona MySQL

2. Use Varnish

We are really excited that Magento 2 supports Varnish out of the box. You absolutely must use it if you want lightning fast performance. Here is our fine tuned Varnish VCL for Magento 2.

Make sure to set your TTL setting to highest possible, e.g. 2 weeks.

3. Use HTTP2 and its Server Push

Magento 2 doesn’t support HTTP 2 server push but you can make it. This should be coupled with a server side solution (Varnish VCL or nginx) to track down repeat visitors in order to avoid unnecessary pushes.

4. Build your own CDN

Cloudflare provides simply inconsistent results. You may be getting as much as 600ms for a cached asset in Cloudflare, tested from the same location (e.g. LAX). That is instead of expected max of ~100ms.

So if you’re after the consistent performance for your user and you know particular locations they mostly originate from, it’s time to setup your own CDN. The DYI CDN solutions can be found online:

Route53 by Amazon is another GeoDNS provider.

5. Use Redis

You can still use Full page cache Redis cache even with Varnish configured. This is an additional caching layer, but it never hurts to have more.
What’s great is that the new Magento supports full page cache in the Community edition for free! There is no longer a need for a third party full page cache plugin.

Follow this instructions to configure Redis cache in Magento 2.

Use Memcached

Get additional performance gain by storing sessions in RAM. Due to some incompatibility in configuring session store to Redis, we recommend to use Memcached for storing Magento 2 sessions.

Starting with Magento 2.0.6, there is no issue in storing sessions in RAM with Redis. Here is how to configure Magento sessions to be stored in Redis.

By default Magento 2 search is slow. No need to worry, as you can leverage the open-source Sphinx search engine which will not only index your products and provide very accurate results. It will also increase the speed of searches a lot! We recommend Advanced Sphinx Search Pro for Magento 2 for implementing Sphinx support in your Magento 2.

Medium or large servers will benefit from ElasticSearch installation instead.

7. Improve product image display performance

The default M2 installation uses very slow AJAX-ified image loading. For performance reasons, we recommend using Magic Zoom Plus plugin. Just check their demo to see how faster it is! And it works without Javascript.

While we’re at at it. Make sure to setup Magento 2 cron jobs properly!

8. Magento 2 Settings

Ensure optimal Magento 2 settings in the admin area or through command line.

9. Disable unused modules

Example:

 n98-magerun2 module:disable Dotdigitalgroup_Email

10. Pre-generate URLs

On a large store, you can fix URL issues as well as “warm-up” the URL cache after importing a large set of products, by using this plugin.

So if you have a problem with messed up URLs (products displaying wrong URLs), run:

DELETE FROM catalog_product_entity_varchar where attribute_id =(SELECT attribute_id FROM eav_attribute WHERE attribute_code LIKE 'url_key' and entity_type_id=4 );

Then run URL regeneration.

11. Fix sessions

Magento 2 with Varnish has a bug resulting in dozens, hundreds, or thousands of extraneous session files.
Until this is resolved, you may want to set up a cron to clean those unneeded session files. Otherwise, they will contribute to a slower session start.

find . -type f -name "sess_*" -exec grep '"remote_addr";s:9:"127.0.0.1"' {} \; -exec rm {} \;

The above fix applies to sessions stored in files.

We recommend storing sessions in Redis.

Make sure you fix up unnecessary sessions creating by using a module.

12. Dynamic ETags

You can save bandwidth and improve performance by adding conditional GET feature to your NGINX.

13. A better cron

Magento default cron tasks implementation is errr.. bad. You can use an alternative cron module here

14. Enable DNS cache

Magento 2 makes use of some external APIs and sure enough, this results in many DNS lookups produced by it. You can speed up your checkout experience, and squeeze out more performance from it, by enabling DNS cache. Here is how to enable DNS cache on your server.

15. Stay away from bad themes and modules

Be sure to stay away from the Argento theme or at least disable SEO modules that it comes with. There is a serious issue.

16. Enable Flat Catalog

Advice from here:

Using Flat Catalog instead of managing catalog data in many tables by the EAV will help you to speed up your product collection.
In order to enable Flat Catalog, navigate to Stores ➡ Settings ➡ Configuration in the Admin panel. Then select Catalog on the left panel under the Catalog tab. Expand the Storefront section and scroll down to Use Flat Catalog Category and Use Flat Catalog Product. Select “Yes” in both sections.

17. Maintain your database

Magento 2 does not scale well when your database is growing. Reason? Bugs!
Make sure to clean up your huge Magento 2 database.

18. Reduce session locking

Session locking is a problem, especially with AJAX requests, which do not even need locks.
Resolve session bottleneck in Magento AJAX Requests by using a special module.

Install and enable it, using clearmage2:

clearmage2 --install getpagespeed/magento2-session-unblocker --enable IntegerNet_SessionUnblocker

19. Schedule your maintenance

Don’t do upgrades, fixes, and other things at a random time. If you are not experiencing serious issues, or simply want to do a maintenance upgrade, do it on a rare schedule. E.g. updating once a month, on the 7th day, is a fine schedule.

The purpose of reducing maintenance windows serves well both the customers and performance. A maintenance results in having to clear cache completely. It takes many days, and for some store weeks to fully warm up / refill the cache. An efficient cache is the one that is not cleared often!

20. Clean up unused media

Over time, the media file directory can grow huge. To clean it up, use EAVCleaner.
Furthermore, the image cache (thumbnails), grows over time with unused image’s thumbnails. Do image cache clearing around once in 1 year:

n98-magerun media:cache:image:clear
# flush cache especially FPC, so that Magento can dynamically recreate thumbnails upon access
n98-magerun cache:flush
# prewarm cache for your visitor's convenience and faster pages
php bin/magento catalog:image:resize

21. One Step Checkout module

Traditional checkout processes often require the customer to navigate through multiple steps (billing, shipping, payment method, order review, etc.). A one-step checkout simplifies this into a single page, reducing the time it takes for a customer to complete a purchase. This can lead to a faster overall checkout experience, which is critical for reducing cart abandonment rates.

We recommend One Step Checkout Pro module

Exit mobile version