Why is Magento 2 so slow? – Top items to review

Pat Kavanagh
February 18, 2019

Magento 2 is a very robust eCommerce platform with a lot of built-in functionality which makes it a popular option for store owners and developers alike. With all the functionality and power, you can sometimes run into performance issues that make navigating your site difficult for customers on the front-end, and even for yourself as a store owner on the dashboard. Thankfully, there are ways to improve these issues!

There are many items to check when doing a performance audit of your Magento 2 store, but here are 5 things we have found to be very helpful to ensure that your store is running in tip-top shape:

1) Magento 2 Modes

Magento 2 has different modes that you can run the site in. There are Default, Developer, and Production. When you begin using Magento 2, it is running in “Default” which has been reported as the slowest mode. For your live customer-facing store, you’re going to want to make sure you’re running in “Production” mode. This ensures your site is using the optimal settings for speed and performance.

 

2) Caching

Magento 2 comes with a “full-page cache” right out of the box which dramatically helps serve your content quickly but for many store owners, the full-page cache alone won’t be enough. You should also look into installing Memcache, Redis, and possibly Varnish cache. Varnish cache has been known to run into some issues running over HTTPS, so if you decide to install Varnish be sure to thoroughly test your store after installing. There is a StackExchange post that outlines these caches and their benefits in a short and sweet manner.

 

3) Flat Catalog

The benefits of enabling “Flat Catalog” are dependant on the size of your store. If you are only selling a handful of products you won’t see a large improvement by enabling this (I would actually encourage store owners who have small stores to look for other eCommerce solutions like WooCommerce as they will be much more user-friendly and easier to manage). For store owners who have hundreds or thousands of products, this feature is crucial. Magento 2 by default separates product and attribute data across many database tables to help become more flexible as you create your store. The issue here is that when you load product data, Magento 2 has to jump across all these tables making your product calls heavy on the database and slowing down your store.

By enabling “Flat Catalog,” Magento 2 creates a new database table and stores all the product data there, creating a single row for each product. If you run into issues getting flat catalog enabled, check all your attribute’s “Used in Product Listing” value and set it to true.

 

4) Optimize Static Files

Magento 2 comes packaged with the ability to minify your static files. If you navigate to your store’s preferences and check out the developer section, you can see a handful of settings that will allow you to minify what you’re sending to the user. If you can not find the “Developer” section within your store configuration, you are likely in “Production Mode.” To bring back developer settings switch to developer mode, make the necessary adjustments, and re-enable production mode.
NOTE: Enabling production mode puts your store in maintenance mode while it compiles the necessary files and settings. Your store’s front-end will be down while this happens, make sure you have a plan to notify your customers that you are doing scheduled maintenance.

You should also be sure to optimize your images before uploading. There are many options out there to help optimize your images, a service we like to use is called “Kraken.” They have a free web interface you can use to optimize smaller images. If you have many, or large, images you need to optimize you should sign up for a premium plan! Not only should you be optimizing your images, be sure to serve images in the correct size for mobile vs desktop. Loading a 1800px wide hero image on a mobile phone is not going to do you any favors.

 

5) Google Bots – Robots.txt

A VERY IMPORTANT piece that many other performance guides are missing out there is reviewing your robots file. If you do not set up a complete robots.txt file geared for Magento 2 Google Bots may end up hammering your site, practically bringing your store to a halt. The link above has some good information and example snippets to add to your store’s robots file and I recommend adding all of the pieces they outline. Two of the more important snippets being the search functionality and the query string (URL filters). Without these two chunks in your robots file, Google ends up crawling every single search result and possible filter combination as an individual page.

This causes problems on a few levels:

1) Search Results: Depending on the size of your store and amount of traffic, you could have anywhere from 10 – 10,000+ search results pages being crawled. If you’re on the 10,000+ side of things, Google will be trying to crawl your site almost indefinitely. This results in your server being spammed with traffic, and this traffic has no money to spend on your store. All this traffic will lead to the server’s CPU spiking, and possibly just running high constantly.

2) URL Filters: Almost every store out there now has some sort of product filtering. A lot of filters today work using the query string and updating the URL so users can share their filtered views with friends, which is great and can help lead to more conversions! But when your store has a ton of filters, there are now many possible combinations of one page’s URL. Without setting a proper robots file for these filters, Google will be trying to crawl each filter combination as it’s own page. Which again, leads to Google being on your site and raising your server’s CPU load.

 

Here are a few other performance guides that we have used and you should check out as well to help improve your Magento 2 store’s performance!

 

 

Solutions Architecture

browse through our blog articles

Blog Archive