9

I'm currently running Magento 2.2, php7, Apache2 on an Amazon AWS EC2 c4.large instance, but even the t2.micro instances are usually fine when I'm using it as a development server.

For some reason every once in a while when I run setup:upgrade after updating one of the setup files in one of my custom modules or after installing a third party module my server will become extremely slow, staying at 100% cpu usage whenever I try to load a page, the page loading takes 1 minute+, and will stay at 25% cpu usage when not loading pages. It only affects the magento website where I called setup:upgrade, pages on other magento installs on the same server will still load at normal speed.

Sometimes the problem is fixed by removing the module I just upgraded, restarting the server and then reinstalling the module without any changes to the code, sometimes a second setup:upgrade fixes the problem, and sometimes it seems the only way I can fix it is by completely reinstalling Magento 2 and the modules.

I have had this occur on Magento 2.1.6, 2.1.8, 2.1.9 and 2.2, all kinds of different combinations of themes and modules that none else seems to have any problems with, on default, developer and production mode.

EDIT: Important note
If you are having this issue and like me are certain you never disabled your caches, there is an acknowledged issue as of right now (Magento 2.3) where running composer update occasionally disables all of your caches. So even if you think your caches are enabled, it's worth to double-check.

  • c4.large CPU 2 RAM 3.75 - this is absolutely normal load. if you have some code issues or in developer mode. – MagenX Oct 22 '17 at 13:26
  • My problem is that there are no code issues and even in developer mode I don't think it should take minutes for a single page to load in the exact same configuration that it takes less than half a second to load on a micro server. 99% of the time there are no issues and everything is extremely fast, but seemingly randomly the entire installation breaks down and nothing loads anymore until it's reinstalled with no changes to the code whatsoever. – Kaascroissant Oct 22 '17 at 20:35
  • Check with production mode, in develoeper mode js and css created on the fly so it will take time to load. – Sunil Patel Oct 25 '17 at 7:02
  • I know, but production mode still has the same problem, and when the problem is not occurring developer and default mode are still loading pages very fast, just occasionally after running upgrade the entire server is slowed to a crawl regardless of the mode. – Kaascroissant Oct 25 '17 at 9:24
  • any sollutions? Facing the same... – Jilco Tigchelaar Dec 7 '17 at 17:35
15

TL;DR: Just switch on the config caches.

Longer story:

I've had the same issue and have been playing around a bit.

Steps to reproduce (in developer mode):

  1. cache:disable
  2. setup:upgrade
  3. reload frontend or backend in a browser

When reloading and monitoring with htop, the system 'spams' some PHP processes, totally utilizing all CPUs. This is when I realized that it must depend on some cache settings. And I started to switch off some of them. After switching off the config caches, the problem re-appeared instantly.

After switching off every cache except the config cache, everything runs fast again.

  • 2
    I feel extremely stupid right now because I have been struggling with this a very long time, but it never occurred to me to check if the cache was on. I never disable the cache myself, but for some reason all caches were disabled. Thank you! – Kaascroissant Jun 15 '18 at 18:46
  • 3
    I've noticed in default mode if you run setup:upgrade magento caches are disabled – Dominic Xigen May 22 at 21:19
3

If you updated using composer then it's likely that you cache is disabled. This applies to versions up to 2.3.1. Simply enable it by using the following code in the Magento root folder.

php bin/magento cache:enable

1

I have the same situation as you, I run:

php bin/magento setup:static-content:deploy -f

to force M2 to deploy the static data in developer mode in order to skip the long wait.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.