Fact Gathering Time Calculator
Estimate time spent on the implicit setup/gather_facts step across all hosts, with and without fact caching.
Inputs
Number of hosts facts are gathered from.
Time for the setup module to collect facts from one host.
Concurrency limit — gathering happens in parallel up to this many hosts at once.
If enabled, cached facts (e.g. in redis/jsonfile) are reused within their TTL instead of re-gathered.
Percent of hosts with a valid, unexpired cached fact set (only applies if fact caching is enabled).
Total Fact Gathering Time
12.00seconds
Time Saved by Caching
0.0%
Hosts Requiring Fresh Gather
200hosts
Gather Batches
10batches
Step by step
Hosts requiring fresh gather
200 (caching disabled)
= 200 hosts
Batches needed
ceil(200 / 20)
= 10 batches
Total gather time
10 × 1.2s
= 12.00s
Time saved vs. no caching
12.00 − 12.00
= 0.00s (0.0%)
How it works
Every play implicitly runs the `setup` module against each host unless `gather_facts: false` is set, and this cost scales like any other task: ceil(hosts / forks) batches × time per host. Fact caching (backed by redis, jsonfile, or memcached) lets Ansible skip re-gathering for hosts with a valid cache entry within the configured TTL, which this calculator models via a cache hit rate applied before batching.
Formula
total_fact_time_sec = ceil(hosts / forks) × gather_time_per_batch_sec
- hosts
- Number of target hosts
- forks
- Ansible parallelism (--forks)
- gather_time_per_batch_sec
- Time for setup module to complete per batch
Frequently Asked Questions
Can I just disable fact gathering entirely?
Yes, with `gather_facts: false`, but only if your playbook doesn't reference any `ansible_*` facts — many roles (package management, service handling) rely on facts like `ansible_os_family`, so disabling it entirely is often impractical.
What's a typical fact cache TTL?
Common values are 1-24 hours (`fact_caching_timeout` in ansible.cfg) — short enough that facts don't go stale after infrastructure changes, long enough to skip re-gathering across frequent, related playbook runs.
Does `gather_subset` help if I can't disable facts entirely?
Yes — `gather_subset: min` or listing specific subsets (e.g. `!hardware`) gathers only the facts you actually need, which can meaningfully reduce per-host gather time versus the full fact set.
Why is my cache hit rate lower than expected?
Fact caches are usually keyed by inventory hostname — if hosts are re-provisioned with new names/IPs frequently, or the cache backend has connectivity issues, hit rates drop and most runs fall back to a full gather.