EC2 微实例每天定时出现 CPU 利用率飙升至 100%。

8

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

还有什么可能呢?

注意CPU利用率下拉菜单设置为“最大”。对于“平均”而言,图形看起来类似。 此实例是2个实例负载平衡设置的一部分。

以下是我的/etc/cron.daily中的内容(其他cron为空):

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


你尝试过检查那个时间点附近的日志吗? - Ignacio Vazquez-Abrams
此外,它可能是与cron以外的其他东西配置的,或者是一个自定义守护程序。 - Linuxios
你使用的是哪个操作系统?可能是更新updatedb的过程。 - neo
@neo 我可以修改 /etc/crontabcron.daily 在其他时间运行,而不是删除 mlocate 吗? - pixelfreak
1
是的。 - neo
显示剩余6条评论
1个回答

10

通常情况下,亚马逊上的Ubuntu AMI每天的cron作业都会在早晨的时间段内执行,这些作业位于/etc/cron.daily目录下,并由/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执行时间。这些是标准任务,可以进行调整以获得最佳性能。您可能需要查看调整logrotateman-db策略。

希望这可以帮到您。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接