Inventory Size Calculator
Calculate total hosts and control-node memory footprint of an Ansible inventory from group and host counts.
Inputs
Number of host groups defined in the inventory (e.g. webservers, db, staging).
Average number of hosts in each group. Hosts in multiple groups are counted once per membership.
In-memory footprint Ansible allocates per host object (vars, facts cache pointers) — roughly 1KB is typical.
If enabled, adds an inventory-refresh overhead estimate to the memory total.
Estimated Unique Hosts
255hosts
Control Node Memory Footprint
0.25MB
Total Group Memberships
300memberships
Dynamic Inventory Overhead
0.0KB
Step by step
Total group memberships: groups × hosts/group
12 × 25
= 300 memberships
Estimated unique hosts (85% after overlap)
300 × 0.85
= 255 hosts
Base memory: unique hosts × per-host memory
255 × 1KB
= 255.0KB
Total memory incl. dynamic inventory overhead
static inventory, no overhead
= 255.0KB (0.25MB)
How it works
An Ansible inventory's size is driven by groups × hosts-per-group, but real inventories overlap — the same host often belongs to an environment group (staging) and a role group (webservers) simultaneously. This calculator applies an 85% overlap-adjustment factor to estimate unique hosts, then multiplies by a per-host memory footprint (~1KB is typical for host vars and fact-cache pointers) to project control-node memory pressure, adding overhead if using a dynamic inventory plugin that refreshes on each run.
Formula
unique_hosts = groups × hosts_per_group × 0.85; memory_KB = unique_hosts × memory_per_host_KB × (1 + dynamic_overhead)
- groups
- Number of inventory groups
- hosts_per_group
- Average hosts per group
- memory_per_host_KB
- In-memory footprint per host object (KB)
- dynamic_overhead
- 0.2 if dynamic inventory, 0 otherwise
Frequently Asked Questions
Why isn't unique hosts just groups × hosts per group?
Because inventories are commonly organized with overlapping groups (by environment, role, and region), the same physical host is often counted in several groups. The 85% factor is a rough correction; your actual overlap depends on inventory structure.
Does inventory size affect playbook run time?
Indirectly — a larger inventory increases fact-gathering and connection setup time, but the direct driver of runtime is host count divided by forks, not group count.
What's the memory overhead of dynamic inventory plugins?
Dynamic inventory sources (AWS EC2, Azure, GCP plugins) re-query the source and rebuild the in-memory inventory graph on every run, which typically adds 15-25% overhead versus a static YAML/INI inventory.
At what inventory size should I worry about performance?
Inventories beyond a few thousand hosts often benefit from splitting into multiple inventory files, using `--limit`, or adopting an inventory plugin with caching to avoid re-parsing the full host list on every run.