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.

author

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.

Magento 2 from Zero to Beginner Free Online Course

In 10 hours you will have all the basic knowledge so that you could develop your modules without wandering around how to implement stuff.

Related Posts

Magento checkout optimization

15 Dec 2022

|

Paul Mestereaga

Optimizing the checkout process on your Magento eCommerce website is essential for increasing conversions and improving customer satisfaction. A seamless checkout experience can make all the difference in the success of your online store.

3 Things That Kill Your Magento Store’s Conversion Rate

10 Dec 2021

|

Paul Mestereaga

The store receives a lot of traffic, and you market to the right audience. The brand is actively promoted on social media and succeeds in SEO, so the marketing efforts appear to be working.
But what if it doesn’t lead to many sales?

optimize-magento-preview

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.