9

My Amazon EC2 micro instance has 100% CPU usage very often. I only have a wordpress installation on it. I'm still in production mode, so no users but I get 100% CPU usage.

Does someone know how to reduce it? I get Amazon Email notifications every hour because of that that lasts over a period of over 300 seconds.

I already moved my database to RDS but didn't solve that problem. It just made it a bit better. Before moving to RDS with my database my Website always totally crashed when loading just one webpage.

My mysqld.log gives a errno 12 error that's why I also did innodb_buffer_pool_size=256M in my.cnf but didn't bring anything.

Would be thankful for every tip.

  • 1
    you need to monitor your instance to see what is going on. You don't say which OS you're using but if Linux then quick and easy it top. Longer term you should consider something else. – Iain Dec 9 '13 at 10:55
  • In linux top command what process is eating up your cpu. Press (Shift+P) to sort processes as per CPU utilization Thanks Sandeep – ZVIK Dec 9 '13 at 11:39
  • Thanks @lian! Yes I'm using Linux. So it is normal that it just very often goes up to 100% CPU? I'm monitoring it with an alarm already and get this annoying alarm notifications via email a few times a day. Do you mean Ec2 isn't worth it, especially not with small packages only when investing a lot? Thanks for your help – Jaba L Dec 9 '13 at 22:08
  • Thanks @ZVIK for your your help! Could you please explain it a bit more in detail. I think I don't understand it right yet. Where can I Press (Shift+P). In the SSH command line? Sorry for my inexperience. Another thing that appears is that my SSH Terminal gets very slow after a while. To type a ssh command and to get a response sometimes takes very long it is very delayed. I think it is because of the CPU usage too. Only by restarting with the commands "sudo service httpd stop/start" and "sudo service mysqld restart" I get it run faster again. But it doesn't last long. – Jaba L Dec 9 '13 at 22:15
  • @Jaba L I suppose there is a memory leak in the code – ZVIK Dec 10 '13 at 2:54
7

Keep in mind, the m2.micro instances are just that--they're small. Any real amount of load will max them out.

As @zvik pointed out in his comments, you should find out what processes are consuming the most memory and/or CPU cycles. He recommended running top, which is a command found on Linux distributions. By pressing Shift-P, it will sort them based on CPU usage. You will need to use this information to figure out where the bottleneck is. For example, if this is running Apache, the default config for Apache may be to launch more processes than the server is capable of.

Try running top and seeing which commands are consuming the most resources.

  • 1
    I checked it and Apache is taking the most of the resources. m2.micro really gets load out so easily. I thought I could use micro for a small production site but that's sadly mot possible at all. Thanks for your help – Jaba L Dec 11 '13 at 0:02
15

Your issue may actually be down to "CPU steal" which happens across Amazon's stack (and as a matter of fact, any virtualised infrastructure). You can read more about CPU steal here.

Essentially, your VM is idle and Amazon is "borrowing" some of your CPU cycles to give to someone else who needs it - this is standard practice for a virtualised environment where physical server resources like RAM usage and CPU cycles are often hugely over-committed.

To check for CPU steal, run top and take a look for the %st value highlighted here:

top command output

If this value is anything other than zero, it means your VM's CPU cycles are being "borrowed".

  • 1
    Thank you @craig-watson very much for your answer. I just checked %st and it is between 0-5%. Thanks for the link too it was very informative – Jaba L Dec 10 '13 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.