What changes when the inventory has 10,000+ hosts?
AdvancedProductionPerformance and Scale
Answer
Parsing and variable merging become noticeable, and each fork's memory grows with the size of hostvars.
- Prefer plugin
compose/keyed_groupsover thousands of per-hosthost_varsfiles. - Keep
group_varssmall and avoid embedding large data blobs in variables. - Cache the inventory and sync it separately from job runs (AWX inventory sync schedules).
- Always run with
--limitor a targeted host pattern, and use job slicing in AWX to split one job template across many workers. - Be careful with
hostvars-wide loops (see Jinja2 cost) andgather_factson every host.
time ansible-inventory --list > /dev/null tells you quickly how bad parsing is.
More on Performance and Scale
Why can Ansible be slower than a shell script for 100 servers, and what dominates the time?BeginnerHow do you choose the `forks` value?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?Intermediate