EC2 Micro Instance CPU每天定期间隔达到100%

时间:2012-12-21 02:05:43

标签: linux ubuntu amazon-ec2

enter image description here

我知道亚马逊会限制微实例,如果它占用了一定数量的CPU时间,但我不认为是这种情况。所有尖峰出现在UTC时间6:30到6:40左右。我检查了我的cron工作,那时没有安排任何事情:

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

还有什么呢?

PS:请注意,CPU利用率下拉列表设置为“最大值”。该图表看起来类似于“平均值”。 PPS:此实例是双实例负载平衡设置的一部分。

这是我/etc/cron.daily中的内容(其他crons是空的):

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

1 个答案:

答案 0 :(得分:10)

通常情况下,亚马逊上的Ubuntu AMI会在/etc/cron.daily的早晨安排他们的日常cron工作。此计划使用/etc/crontab进行管理。以下是示例/etc/crontab的样子:

$ 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 )
#

显然,每日任务在早上6:25运行。如果这会影响服务器的直接交付,您可能需要调整这些设置以将日常任务移动到其他时间。此外,您可以调查/etc/cron.daily下的项目。对我来说,它看起来像:

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

其中,通常man-dblogrotate可能需要占用大量CPU时间才能执行。这些是标准任务,可以进行调整以获得最佳性能。您可能希望调整logrotate和man-db策略。

希望这有帮助。