Host Parallelism Calculator
Calculate how many batches Ansible needs to process all hosts given a forks setting, and the resulting total run time.
Inputs
Number of hosts targeted by the play.
Value of the --forks flag (or ansible.cfg forks setting) controlling parallelism.
Time for one batch of hosts (up to `forks` hosts) to complete the play's tasks.
Total Run Time
1.33min
Number of Batches
10batches
Hosts in Final Batch
20hosts
Fork Utilization
100.0%
Step by step
Batches: ceil(hosts / forks)
ceil(200 / 20)
= 10 batches
Total run time: batches × time per batch
10 × 8s
= 80.0s (1.33 min)
Hosts in final (partial) batch
200 − (10−1) × 20
= 20 hosts
How it works
Ansible processes hosts in batches of size `forks`, running each batch's tasks to completion before moving to the next batch (unless using free strategy). Total run time is therefore the number of batches — ceil(hosts / forks) — multiplied by how long one batch takes to clear all tasks. Raising forks reduces batch count and total time, up to the point where the control node's CPU, memory or network saturates.
Formula
total_time_sec = ceil(hosts / forks) × time_per_batch
- hosts
- Total target hosts
- forks
- Ansible parallelism (--forks)
- time_per_batch
- Seconds for one batch to complete all tasks
Frequently Asked Questions
Why does the last batch matter?
If hosts doesn't divide evenly by forks, the final batch runs with fewer hosts than your fork limit, meaning you're not using full parallelism for that batch — but it still takes roughly the same wall-clock time as a full batch since batch time is dominated by the slowest host.
Does raising forks always reduce total time?
Only up to the point where the control node runs out of CPU, memory, or available SSH connections. Beyond that ceiling, contention increases per-batch time enough to offset the reduction in batch count.
What's the difference between forks and the linear strategy's batching?
With the default 'linear' strategy, Ansible waits for every host in a batch to finish a task before starting the next task, batching by forks. The 'free' strategy lets each host run ahead independently, which this batch model doesn't capture.
How do I measure real task time per batch?
Run with `-vvv` or the profile_tasks callback plugin to get per-task timing, then use the slowest host's cumulative task time as your 'time per batch' input.