Search code examples
amazon-web-servicesamazon-ec2cpu-usage

AWS EC2 t2.small Instance CPU utilization spikes to 100% at regular interval every day


My EC2 t2.small instance CPU Utilization goes to 100% every day at the same time, roughly between 21:25 and 21:30 server time.

enter image description here

I have checked syslog and apache log and found nothing unusual during that time. Also, I have checked my cron jobs and system cron jobs and found no daily cron jobs running at that time (/etc/cron.daily is scheduled at 6:25 and executes correctly at that time according to logs).

Any ideas what could cause this behavior?

OS: Ubuntu 16.04


Solution

  • After a lot of search, logging, trial and error, I have found apache2 was causing this. For some reason, the process hangs at 100% on some occasions, specifically when performing SSL test on ssllabs.com. Found this line in Apache error_log:

    [ssl:error] [pid 29110] [client 64.41.200.104:58242] AH02042: rejecting client initiated renegotiation

    Again, after some trial and error, the solution that fixed the issue was to update the SSLCipherSuite apache directive in /etc/apache2/mods-available/ssl.conf

    Here is the value I used: SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256

    After this change, the problem never repeated. I hope this will help someone else in the same situation.