How do you choose the `forks` value?
BeginnerProductionPerformance and Scale
Answer
forks is the number of hosts processed in parallel. The default 5 is conservative. We raise it to 20 to 50 on a decent controller and measure.
[defaults]
forks = 40
Limits are the controller's CPU and memory (each fork is a Python process, often 50 to 100 MB), network and SSH connection capacity, and the targets (for example hammering one package mirror or API). Beyond roughly 100 forks, returns diminish and you should look at splitting runs across several controllers instead.
More on Performance and Scale
Why can Ansible be slower than a shell script for 100 servers, and what dominates the time?BeginnerWhat is SSH pipelining and why does it help?BeginnerWhich SSH settings matter for performance and stability?IntermediateHow do you find out which tasks are slow?BeginnerHow do you reduce the cost of fact gathering?IntermediateWhat is Mitogen for Ansible and would you use it?Advanced