Magento 2 Performance Issues

Reason for Slow

  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.

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 speed from 50s down to 2s.

Go to Stores > Configuration > Advanced > Developer > Javascript Settings and CSS Settings 

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

3. Server resources Magento 2 is a complex system. Especially in developer mode it requires powerful hardware.Avoid virtualization. Make sure you allocate at least 2G of RAM to M2.

When you are in production mode

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 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

 System > Cache Management