Loading..
Processing... Please wait...

Product was successfully added to your shopping cart.



Magento 2 slow - reasons and 3 simple fixes

Magento 2 might be slow. I see complains about M2 performance on various forums and StackExchange Q&A site too often. How do you make it fast? After all this new version should be more optimized than the old one...

I myself struggled with that problem for some time. Here is what the reasons for slowness could be:

 

 

Magento 2 slow because of:

 

  1. It is in developer mode with CSS/JS merge/bundle/minify enabled.
  2. It is running on slow hardware.
  3. Some 3rd party extension breaks performance.
  4. SSD not used.
  5. Full page cache and other caches are turned off.

 

Now let us deal with every one of the above problems separately. First I tell you what to do if magento 2 slow in developer mode.

PS: Here is how to find out what M2 mode you are in:

cd magento_main_folder
php bin/magento deploy:mode:show

 

When you are in developer mode

 

This mode is needed when you are just getting your site ready for production. But wait time of 30s could be very frustrating and annoying. Here is 3 simple fixes you could try to speed up magento2:

 

1. Disable CSS & JS merge / bundle / minify

 

That trick alone helped me reduce TTFB from 50s down to 2s.

Go to Stores > Configuration > Advanced > Developer > Javascript Settings and CSS Settings and make it look like this:

Disable CSS/JS merge | Magento 2 slow in developer mode Disable CSS/JS merge | Magento 2 slow in developer mode

What happens here: in developer mode Magento 2 will have to locate and merge CSS/JS files on every page request! Turning this behavior off we greatly reduce page load time.

Here is a my stackexchange answer that proofs this tip works - Why is Magento 2 local developer mode site with nginx and xdebug enabled is super slow? (check out comment section)

Many people complains Magento 2 is slow on localhost. Disabling CSS/JS merge/bundle/minify might help in that case.

 

2. Move to PHP7

 

While magento 2 works great on php 5.6 a move to php7 alone can improve performance by 25%.

All major hosting companies support PHP7. If you are maintaining your own VPS or dedicated server spend some time and install php version 7.

 

3. Server resources

 

Magento 2 is a complex system. Especially in developer mode it requires powerful hardware. If you run M2 on an old notebook you borrowed from your grandma expect no magic.

Avoid virtualization. Make sure you allocate at least 2G of RAM to M2.

SSD disk is a must.

Use cheap VPS like linode - for only $10 you can setup a decent Magento 2 environment. I run M2 on $10 linode myself with great success. See m214.goivvy.com

PS: Magento 2 runs OK on MacBook Air 2014+.

 

 

When you are in production mode

 

What happens when have a magento 2 slow site even in production? That might be terrible and could lead to sloppy conversion rate. People tend to hate slow checkouts :)

No worries I have been there and I have again 3 simple fixes to boost performance.

 

1. Audit your 3rd party extensions

 

Magento 2 is greatly extendable with plugins and modules. But unlike core functionality that was coded by Magento Core Team a.k.a gurus and experts 3rd party extensions are developed ( in most cases ) by average programmers. With average skills. One poorly written module could slow magento down big time.

Get a list of all plugins you installed and disable them one by one. See if it affects performance in any way. Identify a bottleneck and contact vendor for assistance.

Go ahead and install a fresh Magento 2 with sample data on the same server. Compare its speed to your production site. If a default M2 is as slow as your customized magento store then go to step 2. If it is significantly faster then you know you have an extension that slows you down.

 

2. Server hardware makes magento 2 slow

 

You can simply find it out if you install a fresh M2 on the same server and compare its performance to your production site. If you don't see a difference then obviously your hosting plan is not suitable for magento2. Sign up for better hosting and secure more CPU/RAM power. Don't be cheap here!

 

3. Make sure full page cache is on

 

Did I tell you I have a client once with magento 2 slow problem? He complained a lot about how slow his site was. Long story short it turned out his employee disabled full page cache at System > Cache Management and forgot to turn it on. Simple solution to a big problem. It is never to late to check obvious magento 2 performance settings.

 

Do you know that faster sites rank better in google? Check out 20 steps to speed up magento store. Or contact experts for help.

 

Other articles you might be interested in:

  1. Magento Performance Optimization - 7 steps to faster website
  2. Is Magento 1.9.2 faster than 1.9.1.1 ?
  3. Magento 2 on AWS Debian Jessie 8 Dirty Cheap with Spot Instance
  4. Wyomind plugin to add 250ms to Magento 2 TTFB
  5. Install php 7.0 / 7.1 on Debian 9 stretch

  

Our Magento extensions you might be interested in:

  

If you find this post interesting do not hesitate to sign up for our newsletter and join the 853 people who receive Magento news, tips and tricks regularly.

Thank You!

 

 

3 thoughts on “Magento 2 slow - reasons and 3 simple fixes”