I have an EC2 Instance (micro) running a cakephp API. This instance serves quality validation before deploying into production.
On this instance, we have 5 cronjobs that run once each minute. Those cronjobs, 98% of the time run a Mysql Query and terminate, since there's nothing to do. So basicly, 98% of the time, every minute 5 mysql queries are executed.
Those cronjobs are configured using CloduWatch Events > Rules, which contain the 5 cronjobs set as Documents. Here's an example of one of our documents:
{ "schemaVersion": "1.2", "description": "CronjobNumberOne", "parameters": {
}, "runtimeConfig": { "aws:runShellScript": { "properties": [ { "id": "0.aws:runShellScript", "runCommand": [" . /opt/elasticbeanstalk/support/envvars && /var/app/current/bin/cake cronjob_number_one > /var/log/cronjobs_php 2>&1"] } ] } } }
Everytime the cronjob rule is active, the cpu usage of our Ec2 instance increases, and keeps rising untill the Ec2 instance dies. Here's a graph to see what happens:
CPU increase over the past week, untill today.
I've installed SAR to check the usage of the CPU over the minute, and here's what is happening:
As soon as I turn off the event of the cornjobs, the cpu lowers to normal values.
I've checked the logs folder, and there is no error or anything like that.
Has this happened to anyone? Any clue on how can I fix this problem? Thanks for your help!
PS: We have another product, which instead of cronjobs by command line, we have 'cronjobs' that make a HTTP request to an enpoint.. We have over 30 'cronjobs' at production and cpu usage is nowhere near this one.