Question

How to set droplet auto reboot when cpu usage above 90%

Hi, i need help. My droplet’s CPU usage sometimes go above 90% and stay like that. This make my website timeout. Is there any way to set auto reboot droplet when CPU usage go above 90%?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
December 10, 2019
Accepted Answer

Hi @mazelanrahman,

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.

  1. You have a lot of trafic to your website
  2. You are being targeted by bots which take all of your available workers.

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.

Upgrade

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.

Regards, KDSys

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel