Skip to content

Commit

Permalink
Merged PR 59501: Adjust cron group configs
Browse files Browse the repository at this point in the history
## What's being changed

The default cron group configurations. All groups now schedule ahead for 10 minutes, and `ddg_automation_main` and `ddg_automation_subs` have an extended schedule lifetime of 10 minutes.

## Why it's being changed

Adjusting the settings in this way is intended to accommodate merchants who do not run cron every minute. Some merchants run cron every 5 minutes or more, and in this case, with our previous configuration, it was typical for scheduled jobs to be missed, and for there to be delays in syncing and importing.

By scheduling jobs further ahead, we ensure that when cron runs it still finds future jobs to process. This as a problem with only scheduling ahead for 4 minutes; it could mean no jobs were scheduled when cron ran. If cron is run even less often than every 5 minutes, this setting can be adjusted in Configuration > Advanced > System.

By extending the schedule lifetime, we reduce the rate of missed jobs for jobs that run less often. If there is a job scheduled to run every 60 mins, even a 5-minute cron will pick it up because it will never be older than 10 minutes.

## How to review / test this change

- Set cron to run on a random 5-minute interval i.e.
```
1-59/5 * * * * /usr/local/bin/php /www/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /www/var/log/magento.cron.log
```
- Set some jobs to run every minute, others every 5, others every 15, others every 60
- Let cron run and check the cron report at intervals
- Note the pattern of missed jobs
- Confirm that jobs scheduled every 60 minutes are still run close to schedule
- Confirm that jobs scheduled every minute are still run at least every 5 minutes

## Notes

- Missed jobs are only problematic for crons scheduled less often (every 15 mins+). If customer sync is set to run every minute, but cron only runs every 5, we will still see missed jobs. This doesn't matter - customer sync will now effectively run on a 5-minute schedule. As long as one job runs every 5 minutes, it will consume all available work anyway.
- The Abandoned Cart cron group does not have an extended schedule lifetime. It should be seen as helpful for merchants to observe missed AC crons because this clearly indicates that some dropped carts are not being picked up. AC cron picks up modified quotes in a very narrow window, so if possible, the `ddg_automation_ac` group should always be run on a 1-minute cron to maximise the number of cart abandonments that are captured.

Related work items: #253510
  • Loading branch information
sta1r committed Nov 20, 2024
1 parent d8e49e9 commit dfcfeba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions etc/cron_groups.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/cron_groups.xsd">
<group id="ddg_automation_main">
<schedule_generate_every>1</schedule_generate_every>
<schedule_ahead_for>4</schedule_ahead_for>
<schedule_lifetime>2</schedule_lifetime>
<schedule_ahead_for>10</schedule_ahead_for>
<schedule_lifetime>10</schedule_lifetime>
<history_cleanup_every>10</history_cleanup_every>
<history_success_lifetime>120</history_success_lifetime>
<history_failure_lifetime>4320</history_failure_lifetime>
<use_separate_process>1</use_separate_process>
</group>
<group id="ddg_automation_ac">
<schedule_generate_every>1</schedule_generate_every>
<schedule_ahead_for>4</schedule_ahead_for>
<schedule_ahead_for>10</schedule_ahead_for>
<schedule_lifetime>2</schedule_lifetime>
<history_cleanup_every>10</history_cleanup_every>
<history_success_lifetime>120</history_success_lifetime>
Expand All @@ -20,8 +20,8 @@
</group>
<group id="ddg_automation_subs">
<schedule_generate_every>1</schedule_generate_every>
<schedule_ahead_for>4</schedule_ahead_for>
<schedule_lifetime>2</schedule_lifetime>
<schedule_ahead_for>10</schedule_ahead_for>
<schedule_lifetime>10</schedule_lifetime>
<history_cleanup_every>10</history_cleanup_every>
<history_success_lifetime>120</history_success_lifetime>
<history_failure_lifetime>4320</history_failure_lifetime>
Expand Down

0 comments on commit dfcfeba

Please sign in to comment.