0

I recently setup a new Droplet (most basic one) and running react app with very light express server with pm2 (server has been running 16h with 0% cpu usage and 90mb ram).

I started the server, no issues there cpu was around 3% and I was testing the website, loading videos etc. I left it overnight and once I loaded the stats it was showing that the droplet was using CPU at 100% for the past 10h or so and I could see the spike going within couple of minutes from 3% to full 100%.

Note, my website doesnt have any traffic, nor the domain yet so there was no usage. In fact the bandwidth was at 0mb/s for the whole time.

I just restarted the pm2 server and its seems like the cpu is dropping once again. Why is the droplet jumps to 100% cpu usage for no reason when its not even used?

  • 1
    Why? ... Because of reasons. - I Think you should be asking not what the cause is (you don't provide any useful detail to answer that) but rather **how to investigate** ; which is answered by adding suitable monitoring – Bob Jan 02 '21 at 10:48
  • @HermanB there is nothing to provide here apart what I have wrote already. React app with express server which runs with pm2. Thats it. Since restarting its been running at 3% cpu. I have tested with 10k user load within 30s and it didnt even flinched. So its something internal which is messed up as I dont think spiking to 100% within minutes and running at 100% is smth to do with pm2 itself, yet I am not confident nor knowledgeable enough to be able to answer this. That is why I posted the question – StuckBetweenTrees Jan 02 '21 at 11:36
  • @Hermanb is right though - we can't tell you what your problem is, we can only help you to debug it. Running "top" when the server is at 100% load will likely give you information sufficient to work out what process is eating your CPU. – davidgo Jan 02 '21 at 11:55
  • @davidgo thanks for that! Running top shows that sshd command is at 99% now. Sometimes there are multiple of them with high cpu. I just noticed that it went up again to 100% out of nowhere – StuckBetweenTrees Jan 02 '21 at 12:38

2 Answers2

-1

Seems like updating the node solved the issue. Node on my droplet was 5v behind. Updating it, the server is running for couple of hours with no issues

Edit: After runing for sometime it still spikes up randomly. Seems like sshd command causing the issue and havent found a way to fix it

Edit: Cause: Seems like the node get function whats causing the issue. Removing this request and doing it directly from UI (without calling the back end url) seems to fix CPU issue. Might be a leak somewhere in the node code when piping the request back to UI

  • Adding that I'm having this problem frequently with several DigitalOcean droplets that do not have Node installed and run a single low traffic Wordpress site with Cloudflare proxying the site and hosting cached files on their CDN. 1-2 CPUs and 2GB RAM at minimum. – Jay Oct 03 '22 at 22:32
-1

I had the same problem now I found a solution I hope it will work for you. actually, someone was attacking with a brute force attack on my website so why my website was down and the graph shows CPU 100% usage.

First of all, check which application takes much usage so enter the command "top" it will show the real-time CPU usage. in my case, PHP-fpm was taking 95% usage.

Now you have to check your Nginx log file. "sudo tail -f /var/log/nginx/access.log" it will show the error or bad gateway access details.. now you have to copy the IP address which is repeated a lot of times you have to block it.

You can block IP by using this command "iptables -I INPUT -s 35.186.156.199 -j DROP"

I hope this issue will be resolved.