Why Magento 2 Is Slow? And How to Make it Fast

Magento is one of the most popular and widely used ecommerce platforms in use today. Among all the ecommerce CMSs available in the market including Shopify and Woocommerce etc., Magento is the most robust, most flexible, and the best performance oriented alternative out there. That is perhaps why Magento 2, the latest version of the famed CMS, is the number 1 choice for most ecommerce startups and online store owners.

However, not all good things are perfect. Magento 2 has a few gripes, and one of the most common among developers and Magento 2 users is that it is slow.

Now some people (like the Magento developer at our office) say that it’s unfair and uncalled for accusations. Maybe it is, but we listen to the users and our readers who have complained of the same problem and want to know why is it such a case with Magento 2. Here are some examples of the type of questions people ask in Magento forums and groups:

Hi friends my client site (Magento) loading speed is very slow how i can increase its loading speed. Please give me suggestion to overcome this issue. 

And,

Is Magento usually so terribly slow? This is my first experience with it and the admin panel simply takes ages to load and save changes. It is a default installation with the test data. The server where it is hosted serves other non-Magento sites super fast. What is it about the PHP code that Magento uses that makes it so slow, and what can be done to fix it?

You can find such queries and complaints from users in many Magento forums. However, here’s the thing that not everyone who uses Magento 2 knows:

Magento 2 Isn’t Slow by Default

Believe it or not, that’s the real case, and most people face the issue of slow interface and high loading times due to malpractices and not knowing how to optimize their website properly. When you don’t meet the basic requirements of running a store on Magento 2, do not use the right extensions, and do not enable the right plugins, your store is bound to land on a turtle’s back. Most crawling websites are due to these issues because a default Magento store is robust and runs smoothly. Even the admin panel faces no trouble in running, so the questions is…

How Do I Ensure That My Magento 2 Runs Swiftly?

You must know the basic requirement of running a Magento 2, and most importantly, you must be aware of the best practices that allow your online store to run in a manner that does not make you want to punch your screen.

Let’s have a look at the ways you can ensure that:

Server and System Requirements

Server and System requirements are the most important factor in speeding up your Magento 2.

Server Requirements: Since Magento is a powerful store, it is highly recommended to host your Magento store on a dedicated server or a VPS. Avoid shared hosting for Magento.

System Requirements: Here are the Magento system requirements:

Operating System Linux distributions such as RedHat Enterprise Linux (RHEL), CentOS, Ubuntu, Debian, and so on.
Composer To develop Magento extensions or anyone who wants to contribute to the Magento 2 codebase, composer is needed. It is highly recommended to use the latest stable version of composer.
Web servers
  • Apache 2.2 or 2.4
  • In addition, the apache mod_rewrite module must be enabled. mod_rewrite enables the server to perform URL rewriting.
  • nginx 1.8 or later.
Database
  • MariaDB and Percona
  • MySQL 5.6
  • Magento 2.1.2 or later versions are compatible with MySQL 5.7.
PHP Magento 2.0

  • 7.0.2,
  • 7.0.6–7.0.x,
  • 5.6.x
  • 5.5.22–5.5.x

Magento 2.1

  • 7.0.2
  • 7.0.4
  • 7.0.6–7.0.x
  • 5.6.5–5.6.x
Required PHP extensions
  • bc-math
  • curl
  • gd, ImageMagick 6.3.7 (or later) or both
  • intl
  • mbstring
  • mcrypt
  • mhash
  • openssl
  • PDO/MySQL
  • SimpleXML
  • soap
  • xml
  • xsl
  • zip

PHP 7 only:

  • json
  • Iconv
SSL A valid security certificate is required for HTTPS.
Mail server Mail Transfer Agent (MTA) or an SMTP server.
Redis Version 3.0 for page caching and session storage (the latter supported by Magento version 2.0.6 and later only)
Varnish Version 3.5 or latest stable 4.x version for page caching
Memcached Latest stable version for session storage with either memcache or memcached PHP extensions (latest stable version)

These are some of the requirements mentioned on the Magento DevDocs. If you wish to know more, you can check them at these links below:

For Magento 2.0.x:

Magento 2.0.x technology stack requirements.

For Magento 2.1.x:

Magento 2.1.x technology stack requirements.

Update Magento Version

Magento is releasing new versions every now and then with performance improvements and other tweaks and it is highly recommended that your store has the latest version. Here is how to update your Magento 2 store.

Enable Varnish Cache

Now enable Varnish Cache to improve the loading speed of Magento 2.

Click on System under Advanced tab, then explore the Full Page Cache section and change Caching Application field to Varnish Caching.

Varnish cache

Configure Memcached

Memcached is a free and open source distributed memory object caching system which helps speed up Magento stores by decreasing the database load. To learn how to configure it, you can check the configuration of Memcached with Magento 2.

Enable Flat Categories and Products

The read speed of a database is one of the most important reasons in slowing down Magento 2. To resolve this problem, enable Flat Catalog.

Go to the admin panel of your Magento store and navigate to Store → Configuration. Then click on Catalog under the Catalog tab. Explore the Storefront section and change the fields Use Flat Catalog Category and Use Flat Catalog Product to Yes.

flat categories and products

Optimize Javascript and CSS

Another reason behind the slow speed of a Magneto 2 store is Javascript and CSS. To resolve it, minimize the Javascript and CSS.

Click on Developer under the Advanced tab. First, explore the Javascript Settings section and change the fields Merge JavaScript Files, Enable JavaScript Bundling and Minify JavaScript Files to Yes. Then explore the CSS Settings tab and change the fields Merge CSS Files and Minify CSS Files to Yes.

optimize javascript and css

Content Delivery Network

Set Up CDN to speed up your online store!

Click on Web under the General tab. Then explore the Base URLS (Secure) section and add HTTPS URLs.

Content Delivery Network

Use lightweight theme

Always try to use a lightweight theme for your Magento store. A light theme helps in improving the loading speed of Magento 2.

Bug-Free Extensions

Always try to use a bug-free third-party extension on your Magento 2 store. This goes without saying, but many people tend to use extensions without checking or confirming if it might contain bugs or not.

Images Should be Fully Optimized

Lastly, images should be optimized. The key points in optimizing the images are:

  • Images must be compressed.
  • The logo of your store should be in PNG or SVG format.
  • Product images should be in JPEG format.

Conclusion

Following the above guidelines can result in a speedy Magento 2 store, so follow them at your own discretion. After all, you don’t want a Magento 2 store that loads up quickly and runs smoothly. Oh wait, that’s exactly what you want. Just remember that the faster and well-optimized your personal development environment is, the faster will your online store will be. For any questions or queries you may have in mind, use the comments section below and let’s discuss.

About Author

Syed Muneeb Ul Hasan is an expert in PHP and Magento, he prefers to educate users in implementing and learning Magento. When not working, he loves to watch cricket.

1 Comment

  1. Hi Syed

    JS Bundling is actually generating JS files to 1mb or more – it is also common practice even with the latest versions to avoid it as best as possible as it is unstable to work with.

    Can you provide any example stores in M2 that get good page results? So far I have not seen a custom M2 site that loads under 9 seconds.

Leave A Reply