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.