In Magento 2, it's quite common you'll run the Magento 2 cronjobs, the way these cronjobs work is that the cron looks at a table called cron_schedule for which tasks it should execute, it's a common thing to do in systems by having a "queue"-system, however, the way Magento 2 queries the table cron_schedule results in the cron getting slower and slower over time.
Luckily the fix is rather easy and can be fixed with executing a simple SQL query from time to time (can be done using cron as well).
DELETE FROM cron_schedule WHERE scheduled_at < date_sub(now(), interval 1 hour) AND status IN ("success", "missed");
What the query will do, is to remove rows in the table that was scheduled more than 1 hour ago and has the status "success" or "missed".
The issue lies in how it queries the database, it will cause massive CPU usage and unneeded queries.
We recommend using something like https://github.com/magemojo/m2-ce-cron for Magento 2 installations.
Do not run Magento cronjobs more than once per 15 minutes, regardless of what Magento recommends. We suggest running the cronjob every 30 minutes, which is 48 times a day. All Magento jobs ran more frequently will be changed to a 15-minute interval.
Comments
0 comments
Please sign in to leave a comment.