pixelfreak
pixelfreak

Reputation: 17834

EC2 Micro Instance CPU spikes to 100% at regular interval every day

enter image description here

I know Amazon throttles micro instance if it uses up certain number of CPU time, but I don't think this is the case. All the spikes appear at around 6:30 to 6:40 UTC. I checked my cron job and there is nothing scheduled for that time:

@reboot ~/path/to/script1.sh >> ~/log/cron.log
0 13 * * * ~/path/to/script2.sh >> ~/log/cron.log

What else could it be?

PS: Notice the CPU Utilization dropdown is set at "Maximum". The graph looks similar for "Average". PPS: This instance is part of a 2-instance load-balanced setup.

Here's what's inside my /etc/cron.daily (the other crons are empty):

apport, apt, aptitude, bsdmainutils, dpkg, logrotate, man-db, mlocate, passwd, popularity-contest, standard, update-notifier-common

Upvotes: 8

Views: 3562

Answers (1)

rhetonik
rhetonik

Reputation: 1868

Usually, Ubuntu AMIs on Amazon have their daily cron jobs under /etc/cron.daily scheduled for morning hours. This schedule is managed using /etc/crontab. Here's how a sample /etc/crontab looks like:

$ cat /etc/crontab 
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

Clearly, daily tasks run at 6:25am. You may want to tweak these settings to move daily tasks to some other time if this is impacting direct delivery of your server(s). Further, you could investigate items under /etc/cron.daily. For me, it looks like:

$ ls /etc/cron.daily/
apport  apt  aptitude  bsdmainutils  dpkg  logrotate  man-db  mlocate  popularity-contest  standard

Out of these, typically man-db and logrotate may take up major CPU time for execution. These are standard tasks and can be tweaked for optimum performance. You may want to look into tuning your logrotate and man-db policies.

Hope this helps.

Upvotes: 10

Related Questions