【问题标题】:EC2 Micro Instance CPU spikes to 100% at regular interval every dayEC2 微实例 CPU 每天定期达到 100%
【发布时间】:2012-12-08 15:09:15
【问题描述】:

我知道如果 Amazon 用完一定数量的 CPU 时间,它会限制微型实例,但我认为情况并非如此。所有尖峰出现在世界标准时间 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:此实例是 2 实例负载平衡设置的一部分。

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

apport、apt、aptitude、bsdmainutils、dpkg、logrotate、man-db、mlocate、passwd、流行度竞赛、标准、update-notifier-common

【问题讨论】:

  • 你有没有试过在那个时候检查日志?
  • 另外,它可能是配置了 cron 以外的东西,或者是自定义守护进程。
  • 您使用的是哪个操作系统?可能是更新的过程b
  • @IgnacioVazquez-Abrams 我确实检查了我的 HTTP 日志,没有什么异常。我还应该检查哪些其他日志?
  • 是的。 vi /etc/crontab 通常在 06:25 运行。如果您有很多文件,那么 updatedb 是罪魁祸首。

标签: linux ubuntu amazon-ec2


【解决方案1】:

通常,亚马逊上的 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 策略。

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2019-05-31
    • 2018-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多