Skip to content
ENExplore Calculators

Ansible Forks Calculator

Determine the optimal forks setting for Ansible based on control node resources.

About Ansible Forks Calculator

The forks setting controls how many hosts Ansible connects to and runs tasks against simultaneously. Setting it too low under-utilizes the control node and slows runs; setting it too high can exhaust CPU or memory on the control node, or overload the network/SSH capacity of target hosts. This calculator picks the largest safe value: the smaller of your total host count, a CPU-based ceiling (2× cores, since fork processes are largely I/O-bound waiting on SSH), and a memory-based ceiling (available memory ÷ per-fork footprint).

Formula

optimal_forks = min(hosts, cpu_cores × 2, available_memory_MB / per_fork_MB)

hosts
Total target hosts
cpu_cores
Control node vCPU cores
available_memory_MB
Control node RAM (MB)
per_fork_MB
Memory consumed per fork process (MB)

Worked example

With the default values below, Ansible Forks Calculator returns Optimal Forks Setting of 8. Change any input above and every figure here is recalculated in your browser.

Inputs used

Total Hostsaccepts 1–100,000 hosts
300 hosts
Control Node CPU Coresaccepts 1–256 cores
4 cores
Control Node Memoryaccepts 128–1,000,000 MB
8,192 MB
Memory per Forkaccepts 1–5,000 MB
60 MB

Results

Optimal Forks Setting
8 forks
Binding Constraint
CPU cores
CPU-Based Ceiling
8 forks
Memory-Based Ceiling
136 forks
Resulting Batches
38 batches

Step by step

  1. 1CPU-based ceiling: cores × 2= 8 forks
  2. 2Memory-based ceiling: memory ÷ per-fork memory= 136 forks
  3. 3Optimal forks: min(hosts, CPU ceiling, memory ceiling)= 8 forks (limited by CPU cores)

Assumptions and limits

  • The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

Why 2× CPU cores as the ceiling instead of 1×?

Ansible forks spend most of their time waiting on network I/O (SSH round trips) rather than burning CPU continuously, so a control node can support more concurrent forks than raw core count without CPU becoming the bottleneck — 2× is a conservative multiplier for this I/O-bound pattern.

What if I set forks higher than my host count?

There's no benefit — Ansible can never run more concurrent connections than there are hosts in the current batch, so forks beyond your host count simply go unused.

How much memory does one fork really use?

It varies with module complexity and fact size, but 40-80MB per fork process is a reasonable planning number for typical playbooks; modules that gather large facts or process big data structures can use more.

Should I set forks globally in ansible.cfg?

Yes, for a baseline — most teams set a global default in `ansible.cfg` sized for their typical control node, then override with `--forks` for unusually large or resource-constrained runs.

Ansible Forks Calculator – Calculate Optimal Forks Setting