Get Free Design

Slow Magento?

Common mistakes in Magento 2 setup

Even before Adobe acquired Magento Commerce, Magento 2 became complex and with colossal applications with hundreds of settings and tens of thousands of files with code. On one hand, it results in a bunch of awesome features which comes out of the box with fresh Magento 2 installation. On the other hand, it makes Magento not a kind of “fire and forget” solution and creates a lot of place for miss-configurations and mistakes.

Today we are going to talk about the most common mistakes in Magento 2 setup which could make your Magento slow.

1. Using wrong hardware setup

If you are not using Magento 2 Cloud solution, it adds a couple of things to worry about. One of them is how to arrange proper infrastructure setup. Magento is not one of the cheapest platforms to host and we recommend you to check with and follow Magento 2 Performance Best Practice and select a proper hosting plan for your website.

2. Not using content delivery network

If your business and stores are not focusing only on the local market and have a global customer base, CDN could become a “must-have” tool in your setup. Content Delivery Network arranges global access for media, HTML, CSS, and JavaScript files by storing your data in geographically distributed servers. If you are using Magento Cloud solution, in environment setup, CDN will be provided with Fastly CDN. For on-premise Magento 2 installation, we recommend using the Cloudflare solution.

3. Disabling Magento 2 caches

Magento 2 is a highly extensible and flexible eCommerce solution. The price for this is an extremely complex architecture of data flows and developer configurations. Usage configurations in XML format dramatically reducing site performance. To reduce impact, Magento 2 provides a layer of caching functionality out-of-the-box. Disabling configuration cache altogether with other types of cache could dramatically reduce your website performance.

4. Using built-in full page cache instead of varnish

For some types of Magento 2 caches it is not enough to only keep them enabled. Full Page Cache is one of them. Magento 2 on-premise installation allows you to select between two Caching Application types: Built-in Cache and Varnish Cache. Magento 2 Cloud installation has a 3'rd option available — Fastly CDN. By default, Magento 2 uses Built-in Cache, however, Varnish Cache is more appropriate to use for production applications.

According to Varnish architecture, Magento 2 content pages (Homepage, Category page, Product details page, CMS pages, etc) will be loaded from cache, even without initializing Magento 2 which dramatically decreasing Time to First Byte (TTFB), increasing the throughput of your application and saves server resources.

You can select Varnish as cache application in Admin Panel: Stores -> Settings -> Configuration -> Advanced -> System -> Full Page Cache -> Caching Application.

5. Using flat catalog products and flat catalog category

If you are using the latest versions of Magento 2 you should consider that using Flat tables for Catalog and Product data is disabled.

In older Magento 2 versions Flat Tables are used to optimize the way which Catalog and Product data works. On a low level, Magento 2 stores the price information in a distributed way via the EAV database architectural pattern. Content manager modifies category or product data in Admin Panel and in few minutes, after being transferred to Flat tables via Flat indexer, changes will appear on Magento 2 Storefront.

Nowadays, Adobe does not recommend the usages of Flat Indexes to avoid issues with data synchronization and performance degradation which they could cause.

Data flow with enabled flat tables

You can disable Flats by changing configuration in Admin Panel in: Stores -> Settings -> Configuration -> Catalog -> Catalog -> Storefront.

Magento 2 Flat Tables configuration

We recommend testing the application on a dedicated test environment first, as some 3'rd party extensions could be working only with enabled Flat Tables.

6. Not minifying and merging Javascript and CSS content

To optimize Time to Interactive (TTI) on your website, we strongly recommend enabling minification and merging of CSS and Javascript files. The feature allows to generate a corresponding single file with a light-weight version of content and reduces a number of requests which the browser should process while loading your website page.

You can enable merging & minifying in the Admin Panel: Stores -> Settings -> Configuration -> Advanced -> Developer -> Javascript Settings & CSS Settings respectively.

However, the Developer tab could be disabled if you are using Magento 2 in production mode. In this case, you should change these settings in the server terminal via the Magento 2 CLI application.

php bin/magento config:set dev/css/merge_css_files 1php bin/magento config:set dev/css/minify_files 1php bin/magento config:set dev/js/merge_files 1php bin/magento config:set dev/js/minify_files 1

7. Using Magento 2 Javascript Bundling

The javascript bundling technique allows you to load grouped Javascript files separately for each page and decrease the number of HTTP requests which should be performed on the page.

On the surface, sounds like a good idea, however in practice you receive weakly optimized Javascript files for each page separately, which slow down page loading time.

Therefore, we recommend to enable HTTP/2 on your server to optimise work with many HTTP requests on your site.

If you would like to test Magento 2 Javascript Bundling on your application, we strongly recommend to do it on dedicated test environment with disabled Javascipt minification and merge features.

8. You are not using production mode in the production environment

Magento 2 application could be run in 3 different modes: development, default, and production. However, only the ‘production’ mode should be used for the live website. Development and default modes dramatically decrease site performance and developer mode could show technical details about your application in the case of an error happening on the frontend.

You could check the current mode of your application via server terminal and Magento 2 CLI application:

php bin/magento deploy:mode:show

Posted in Blog on Jun 07, 2021


Share on social networks

  Twitter   Facebook   Google+   LinkedIn

Contact Us

If you want to reach our sales or development team, have any questions, concerns, or just want to chat about Magento, feel free to get in touch via message or call. We are here to help your business grow.