Stack Matrix Hub (10)
Moodle Cron CLI & Parallel Adhoc Task Worker Memory
Isolate scheduled cron.php and adhoc_task.php memory spikes from interactive exam PHP-FPM pools so PDF annotation and grading never starve students.
task_adhoc_concurrency=3 · Separate CLI memory_limit=512M · 60s systemd timer
Why Background Adhoc Tasks Spike Memory During Exam Windows
Moodle processes forum digests, assignment PDF conversions, quiz regrades, and .mbz automated course backups through CLI adhoc task runners. If unconstrained, 10 parallel Ghostscript/PHP CLI tasks can consume 3+ GB RAM mid-exam.
Capping task_adhoc_concurrency During Peak Hours
Set $CFG->task_adhoc_concurrency = 2 or 3 on 8-16 GB servers, keep $CFG->task_scheduled_concurrency = 2, and move heavy automated course backups outside live exam hours.
Measured Thresholds & Configuration
| Host RAM Tier | task_scheduled_concurrency | task_adhoc_concurrency | CLI Memory Reserve |
|---|---|---|---|
| 3 - 4 GB Turbo | 1 | 1 | 256 - 384 MB |
| 8 GB Cloud VPS | 2 | 2 | 512 - 768 MB |
| 16 - 32 GB VDS | 2 - 3 | 3 - 4 | 1,024 - 1,536 MB |