Apache/MySQL/Ubuntu stack on AWS EC2 here.
For some reason, my web server spikes to 99% and my server becomes completely unusable. It is insanely frustrating. I don't have to the ability to troubleshoot the issue, because the server is completely unresponsive, and I can't login. I know it's something to do with MYSQL, and that is it. It will slowly increase CPU usage until it gets to 100% and I can't do anything but forcefully Stop and Start the instance via the AWS UI.
My work around thought is to automatically restart MySQL/Apache if the CPU usage reaches a certain point. I was messing with cpu-limit, but I can't figure out how to get this to attach to PIDs already running.
I just want to be able to limit the CPU until it gets to that point, then I can try to read the logs or see what is going on. Thanks for the help.
statfile, which includes CPU usage figures. A version of that data is in /proc/PID/status (human-readable). Seeman procfor details. I would run my script based on theutimeandstimevalues. To limit the CPU, tryreniceor put suspicious processes in a Cgroup (I don't remember, off the cuff, how you can limit CPU this way, but it's not too hard. Tutorials and kernel information are not hard to find).ps -elaccording to the C column to find high CPU users, or trytop's batch mode.