Why Magento 2 is extremely slow?

There are multiple resources available to improve Magento 2 performance and all of them are pretty well documented.

Mode: Magento 2 has introduced modes, being the default one the slowest. Give the developer mode a try and always run your live store in production mode. More info here.

Cache: Varnish is supported out of the box, pretty easy to configure and use.

Redis: Redis is an optional backend cache solution to replace Zend_Cache_Backend_File, which is used in Magento 2 by default. It can be used for session storage and page caching.

Memcache: Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering. In Magento 2 it can be used for sessions.

PHP 7: Magento 2 is compatible with PHP 7 out of the box. There is a lot of research on how PHP 7 affects performance for good.

This is just the start, you should be able to fine tune your webserver and database server but that will heavily depend on your particular use case.

If you don't know how to do that yourself, there are plenty of companies specialized in Magento hosting.

For a pretty solid dev environment my personal recommendation is Paliarush' Vagrant or the VM I got from Magento for the courses. There is an official docker image coming soon.


Magento runs reasonably well even in developer mode. It does need some initial configuration though.

First make sure Magento is set up correctly, assuming your on Ubuntu:

Use the latest build as Magento 2.2+ supports php 7.1 http://devdocs.magento.com/guides/v2.2/install-gde/prereq/php-ubuntu.html

sudo apt-get install php7.1 php7.1-imap php7.1-xml php7.1-dom php7.1-intl

If your running multiple php versions set 7.1 to the default via

sudo update-alternatives --set php /usr/bin/php7.1

Onto Magento

  1. Set to Developer if not already php -f bin/magento deploy:mode:show

    php -f bin/magento deploy:mode:set developer

  2. Check Magento's cache is enabled

    php -f bin/magento cache:status

If not enabled (series of 1's)

php -f bin/magento cache:enable

Enable JS/CSS bundling

Stores > Configuration > Advanced > Developer

*Note the above menu item only shows up whilst in developer mode

Template Setttings

  • Minify HTML = Yes

Javascript Settings

  • Merge JS files = Yes

  • Enable JS Bundling = Yes

  • Minify JS files = Yes

CSS Settings

  • Merge CSS = Yes
  • Minify CSS = Yes

Do a cache flush from here on in after every step flush the cache, this is your baseline for trying to improve the loading time.

php -f bin/magento cache:flush

Advanced bundling

This would be a post in itself follow guidelines from magento devdocs on how to enable this, this could further increase the frontend JS loading making it 3x as fast.

Use Redis

sudo apt-get update
sudo apt-get install build-essential tcl8.5
sudo apt-get install make
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
cd utils/
sudo ./install_server.sh

Edit /www/project/app/etc/env.php

'cache' => 
  array (
    'frontend' => 
    array (
      'default' => 
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' => 
        array (
          'server' => '127.0.0.1',
          'database' => '0',
          'port' => '6379',
        ),
      ),
      'page_cache' => 
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' => 
        array (
          'server' => '127.0.0.1',
          'port' => '6379',
          'database' => '1',
          'compress_data' => '0',
        ),
      ),
    ),
  ),

Use PHP-FPM

apt-get install php7.1-fpm
a2enmod proxy_fcgi setenvif
a2enconf php7.1-fpm
sudo service php7.1-fpm restart
sudo service apache2 restart

Enable opcache in PHP

Edit /etc/php/7.1/apache2/php.ini find opcache.enable

opcache.enable=1

I would also recommend using a Cloud DB such as AWS RDS or other it will save you the headaches of configuring mysql.

If you now enable production mode php -f bin/magento deploy:mode:set production

you should find it's running reasonably well.

Taking it further from here you can add Varnish, Switch to Nginx add a CDN for static files.


I had this problem too on a Macbook Pro (late 2016) with MAMP.

What I wanted to do was to create a Magento 2 theme. I had deactivated all caches and it took like 30s to reload a page (frontend and backend).

I activated all caches with the command "php magento cache:enable" and the site loads very fast. I can still work with Grunt and LESS without deactivating any cache type.