Ron
Thanks for the summary! Very useful, the thread has become too long to digest at one go.
I don't claim to know the mechanisms behind cron.php - they have been changing at a rapid speed since about Moodle 3.7 - but can confirm your explanations as a "user", a Linux system admin, I mean. I just want to clear some misunderstandings of others users, which I see often in discussions in the forums, specially in the Hardware and performance forum.
- These tons of tasks increase the load on the
serverNo, they do not. The (total) load caused by Moodle increases continuously because Moodle get more and more work thanks to the new features that are added in every version. The task processing tries to keep Moodle still responsive by pushing as much processing as possible to the background.
- Increasing the frequency of calling cron.php increases the load.
No, it is the same (total) load the Moodle, the task system tries to distribute them sensibly. Invoking tasks which are in the queue or being processed or finished and nothing to be done don't restart the task. The task system detects those states and do nothing.
So the answer to the original question, "Why run cron every minute when it takes 3minutes to run?" is, there is nothing called *one* cron task, it is a sea of tasks. cron.php simply wakes them up. More often the better, only then is Moodle always ready, up-to-date, to respond. This waking up doesn't cost a big overhead as explained above.