The project we inherited is having very strange issues. Basically, the MySQL DB CPU is running at 95%+ basically at all times, even when there's seemingly no activity in the app. It doesn't happen right away. Only once users actually get into the app, but then it keeps at 95% CPU even once there's basically no activity.
We've confirmed this behavior in our UAT / Staging server as well. Basically at 3% CPU until users are in it for a while, then 95%+ CPU on the DB indefinitely even though it doesn't seem as though that many queries are running at a time.
One thing I notice is that there will be 150+ active sessions / connections and a look at the MySQL processes will reveal a dozen processes trying to use 8%+ of the CPU for some reason.
We suspect some kind of task fires off and keeps running in a loop. I'm watching for Laravel jobs via php artisan queue:listen but nothing appears.
It's been a while since I've worked in PHP but it seems to be a bit painful to get in-depth logging information. One of our theories is that some process is running in an infinite loop and requesting the same data from the database over and over and over again.
Is there a way to tell current Laravel code executing, or PHP code executing in general? Is there a way to get an active trace of all PHP executing in the application, especially Laravel code?
Given the scope of this project we inherited, and the fact that it's already in Production, narrowing down exactly what task is causing these queries to run will be next to impossible without some kind of tracing tool. Otherwise we would have to add manual debugging to probably hundreds of code files, which I would very much so like to avoid having to do.
Any advice on how I can gather some evidence or traces as to what the heck is going on?