You can write a script to check for your load and reboot your droplet however I wouldn’t recommend it. If your CPU gets higher than 90 % it means two things, you either need to upgrade or something is not correctly set and it’s causing you this load.
Let’s start with the second assumption.
What is causing this load
I see you are using Apache. Usually when the website just hands and loads endlessly it means your Apache Workers are full. Apache Workers are like slots each user on your website can take. For instance if you have 200 Apache Workers, there can be up to 200 visitors at the same time. When they get full, every request after them just hangs on a white page until a slot has been freed.
There could be two reasons behind this behavior.
- You have a lot of trafic to your website
- You are being targeted by bots which take all of your available
You can confirm this theory when you experience the issues. You can check how much IPs are connected to your droplet and see from which countries they are. Usually if your website is suppose to have UK visitors, having IPs from China or Russia means they are not legitimate and you can block them. If this doesn’t solve your problem, you’ll need to turn yourself to see if something else is causing this issue like RAM being full by a service you are running of some sorts.
Alternatively, if the traffic is only from expected countries and it’s legitimate, you might need to increase your Apache Workers limit. This can be done from your Apache configuration file. Once you’ve changed your limit, just restart Apache.
Please note increasing the limit may again require you to upgrade your droplet which brings us to the next solution.
As mentioned already, either way you might need to Upgrade your droplet. It’s possible your website/application just got too popular and it outgrowed your droplet.