You should be able to optimize both apache and mysql to get better server load average. What type of hardware are you running on? Have you looked through the cPanel doc's? That is usually your best ticket on where to find out the "tips and tricks"
Well, when these spikes happen the website is unresponsive and the server breaks, I get high CPU usage, server remains without memory and it requires manual intervention. I just want to show a page when the cpu load is higher than x (or a similar mechanism).
bestssdhost thank you very much!
Is there a more "global" solution? It's a pain in the *** to implement this code in every client's website.
Rather than using such custom solution, I suggest to use solutions like CloudLinux or 1H HIVE manage server resources. Ofcourse using them needs to add a few more $ ; but that will be a worth for shared hosting.
Is there an option for apache to limit the maximum of http requests/second that will accept?
Apache doesn't provide such an option; but you can set maximum number of connections it can handle. Also you can place some restrictions via mod_qos.