Question

How can I find out why my CPU Is spiking to 100%?

Posted January 28, 2014 48.1k views
I have one droplet that has 7 WordPress installs on it. Most sites get very little traffic so resources are not an issue. However, every so often the CPU spikes to 100% and stays there. The only thing I can do is log into the website and power cycle the machine. https://cloudup.com/cXgNTHGW6cT How can I find out what's causing this?
6 comments
  • I have the same problem with a tiny apache2 in my droplet.

    I have just a simple apache2 and I am building a PHP webapp. I have seen this happend to me twice already while in VI in last 3 months. We should be atleast able to know why such things in droplets.

  • It’s reassuring I’m not the only one with this ongoing issue. I have a single WP install on a 512mb Ubuntu droplet. I get random 50–100% CPU spikes, sometimes twice a day, once in awhile never. This cripples logging in via ssh, or visiting its http address. No pattern found in the error and slow logs. Can’t tell if it’s DigitalOcean, ServerPilot, or a plugin.

    When debugging WP, there are no errors. I have WP Super Cache dump its cache every midnight, NOT when a post/page has been updated. There are no other scheduled processes performing like external backups—I haven’t been able to get that far.

  • I’m facing the same problem with a 512MB droplet. This is what I get: http://imgur.com/MPBepxY

  • i am facing the same problem twice. First I thought it was problem with my script but its working fine on another server. No way to detect why this is happening.

  • I too had this problem (with smallest droplet 0.5 GB RAM + ISPConfig 3), So I tried digging into the problem, I used “htop” to monitor the process that was eating the CPU out, I saw “amavisd ” was the only culprit.

    So I searched the interwebs and found similar problem being reported so I disabled the “amavisd” By this command “systemctl enable amavisd.service” and commenting out the “Example” line inside the fiel “/etc/freshclam.conf”.

  • Show 2 more comments

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.

×
Submit an Answer
40 answers

I believe that all of those reports of “out of memory” are related to lack of virtual memory. Digital Ocean droplets don’t come with swap partitions enabled by default, so the kernel just kill the process when it’s not possible to allocate more RAM for it

I had problems with a long-running Java process I developed and the solution was pretty simple.

Check the links below to enable it on Ubuntu or CentOS:

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-centos-7

by Justin Ellingwood
Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.
Are you able to SSH into your droplet when the CPU spikes to 100%? If so, run top after you connect—the processes will be listed by CPU usage.
When I try to SSH in, it just sits there and waits for an opening to connect. Which doesn't seem to ever happen.
Hmm. Can you access your droplet via the remote console (https://cloud.digitalocean.com/droplets)?
I never tried that one. Basically since the server is overloaded, connecting to it any way probably isn't going to happen.
The console is already running on your droplet, it's like hooking up a monitor and a keyboard to your server and making them available to you through the browser. Give it a shot, there's a high chance you'll be able to log in.
Thanks. I'll try that next time as long as it's not 4am. :)

Hopefully it'll be a while before this happens again, but then again, it could be a day or two.
Sadly, that didn't take long. It was just down. Looks like it's out of memory.
https://cloudup.com/csxDE5gA9fB

I wasn't able to do anything but see the message above.

Now I need to figure out what's taking up so much memory as my sites aren't that popular that they should be eating up so much memory.
The only solution I can find is to abandon the droplet. There is something seriously wrong and no clue how to find out what. The droplet currently has 5 sites running on it, one is static HTML and the rest are WordPress. Combined they maybe get 100 hits a day.

When the server spikes the CPU graph goes through the roof and I can't terminal in, I can't use the virtual console, I can't do anything but force it to shutdown or reboot.

When I am able to get into the virtual console, all it says is "out of memory" and it's trying to kill processes. But it never lets me log in or do anything.

All I can come up with is it's out of memory. Even though the sites get very little traffic, 512 seems to be to little. Even if this is the case, it's strange how it can go one week and be fine. Then crash three times in the next week.

I did find this in the messages log: mysqld invoked oom-killer. That seems to be when the server stops responding. Googling that I came up with these:
http://serverfault.com/questions/362506/oom-killer-killing-things-with-plenty-of-free-ram
http://askubuntu.com/questions/161521/why-does-my-server-freeze-everyday-at-the-same-time

Long story short, I have no idea what's going on still.
I have the same issue, this seems to be an issue on DO's side.
Previous 1 2 3 4 Next