This documents the design of the Krang scheduler daemon. Krang's
scheduler is responsible for running scheduled jobs at their appointed
time. Things like publishing, alerts and expiration can all be
scheduled through the user interface.
The scheduler must:
Run jobs as close to on-time as is feasible.
Run time-sensitive jobs, like alerts, before less sensitive ones, like
daily publish runs.
Be memory efficient. Since the scheduler will run indefinitely even a
small leak will eventually become a big problem.
The scheduler will be constructed using the following modules:
Each time the scheduler wakes up to run it performs the following steps:
Collect a list of jobs ready to run, sorted by priority and lateness.
Partition jobs into chunks where chunk size is chosen to limit
potential memory usage and improve performance on multi-processing
systems.
Fork a child to run each chunk. The child will execute each job in
order and then exit, freeing any memory used. The number of children
forked to run simultaneously will be configurable
(ScheduleParallel).
Mark completed jobs finished.
Check again for jobs ready to run, if found goto step 1. If not,
sleep() for a configurable period (ScheduleInterval) and then
goto step 1.