Is Magento 2 slow on localhost? - Paul Meștereagă
Magento 2

Is Magento 2 slow on localhost?

A fresh install of Magento 2 slow on localhost? Here are some steps you can take to make your Magento 2 faster on your localhost.

Paul Mestereaga

February 20, 2020

A fresh install of Magento 2 slow on localhost? This can happen often especially on developer mode and indeed can be frustrating.

Working on production mode while developing in Magento 2 can be time consuming as you need to compile and deploy your static files any time you make updates to the templates, layout or add new dependencies to your classes.

Here are some steps you can take to make your Magento 2 faster on development mode.

Use latest PHP version

Use the latest available PHP version that is compatible with your Magento version to increase performance.

Install and enable PHP OPcache

Make sure you install and enable PHP OPcache. Also because you don’t want to clear the OPcache anytime you modify a PHP file so  to disable timestamp validation add the following line to your php.ini:

opcache.validate_timestamps = 0

Turn off Xdebug

Enable Xdebug only when you really need it because it requires a lot of memory and degrades performance.

For Magento the xdebug.max_nesting_level configuration needs to be set to 200 or greater. Also you can increase the memory available to PHP to get an increase in performance with Xdebug on.

Enable partial caches

In developer mode I found that all caches are disabled, but in your env.php you can set what caches you still want to use:

'cache_types' =>
      array (
        'config' => 1,
        'layout' => 0,
        'block_html' => 0,
        'collections' => 1,
        'reflection' => 1,
        'db_ddl' => 0,
        'eav' => 1,
        'customer_notification' => 1,
        'target_rule' => 1,
        'full_page' => 0,
        'config_integration' => 1,
        'config_integration_api' => 1,
        'translate' => 1,
        'config_webservice' => 1,
        'compiled_config' => 1,
      ),

Use Percona instead of MySQL

Another recommendation from Magento for your localhost is to replace your MySQL database with Percona.

Percona Server for MySQL® is a free, fully compatible, enhanced and open source drop-in replacement for any MySQL database. It provides superior performance, scalability and instrumentation.

Conclusion

As a wrap up for a Magento 2 slow on localhost:

  • Use latest PHP version
  • Install and enable PHP OPcache
  • Turn of Xdebug
  • Enable Partial caches
  • Use Percona instead of Mysql

Magento 2 can be optimized for localhost and make it work faster on your PC. You can check the official Magento optimization guide for development here.

Let me know in the comments section bellow if that was helpful and if you have any other tips on improving Magento 2 on localhost.

Is your Magento slow?

Wondered how you can make your Magento load faster? Wonder no more. Here is a FREE step by step guide that helps you.

Related Posts

How to create a product attribute using Data Patches in Magento 2.3

26 Mar 2020

|

Paul Mestereaga

This is a short tutorial in which we will learn to create a product attribute using Data Patches in Magento 2.3

Declarative schema in Magento 2.3+

16 Mar 2020

|

Paul Mestereaga

In this tutorial we will learn the how to configure a declarative schema in Magento 2.3, perform database operations using declarative schema, create a schema whitelist and create data and schema patches.

FREE!

Magento 2
Optimization guide

Wondered how you can make your Magento load faster? Wonder no more. Here is a step by step guide that helps you.