Batch Processing
Overview
The queue runner processes actions in batches, balancing throughput with limits on time and memory.
Batch size
Batch size controls how many actions are claimed at once:
- Default:
25 - Filter:
action_scheduler_queue_runner_batch_size
Claiming and processing
For each batch:
- The runner stakes a claim with
ActionScheduler_Store::stake_claim( $size ). - Each action in the claim is processed with
process_action(). - If the claim is lost during processing, the batch ends early.
- After the batch, the claim is released and caches are cleared.
Concurrent batch limits
The runner limits concurrent batches by checking the number of active claims:
action_scheduler_queue_runner_concurrent_batches(default1)ActionScheduler_Abstract_QueueRunner::has_maximum_concurrent_batches()compares current claim count to the allowed limit.
Time limits
Time limits are enforced per run:
- Default:
30seconds - Filter:
action_scheduler_queue_runner_time_limit - Deprecated filter:
action_scheduler_maximum_execution_time(use the newer filter)
The runner estimates time per action and stops the batch if it is likely to exceed the max time limit:
- Filter:
action_scheduler_maximum_execution_time_likely_to_be_exceeded - Optional CPU-time based measurement (e.g. Pantheon):
- Filter:
action_scheduler_use_cpu_execution_time(defaultdefined( 'PANTHEON_ENVIRONMENT' ))
- Filter:
Memory limits
Memory usage is capped at 90% of the WordPress memory limit:
- Filter:
action_scheduler_memory_exceeded
If memory is exceeded, the batch stops.
Cache clearing
After each batch, caches are cleared to reduce memory and stale data:
- Uses
wp_cache_flush_runtime()when available. - Falls back to
wp_cache_flush()if no external object cache is in use. - Filter
action_scheduler_queue_runner_flush_cachecan force flushing even with an external cache.
Hooks & Filters
Filters
action_scheduler_queue_runner_batch_sizeaction_scheduler_queue_runner_concurrent_batchesaction_scheduler_queue_runner_time_limitaction_scheduler_maximum_execution_time(deprecated)action_scheduler_maximum_execution_time_likely_to_be_exceededaction_scheduler_use_cpu_execution_timeaction_scheduler_memory_exceededaction_scheduler_queue_runner_flush_cache