Interview Prep/Ansible/Performance and Scale

How do `serial`, `forks` and `throttle` interact?

AdvancedProductionPerformance and Scale
Answer
  • forks is the global upper limit on parallel workers on the controller.
  • serial splits the play's hosts into batches, and each batch runs the whole play before the next starts.
  • throttle limits concurrency of one task (or block), even if forks and the batch size are larger.

The effective parallelism for a task is min(forks, batch size, throttle). With serial: 50 and forks: 20, each batch of 50 runs 20 at a time. With serial: 1 and forks: 100, only one host is touched at a time.

- hosts: web
  serial: [1, 5, "25%"]
  tasks:
    - ansible.builtin.command: /opt/app/bin/warm-cache
      throttle: 2
All Ansible questions Roadmap: Ansible

More on Performance and Scale