Calculate DNS resolver cache size needed to serve a given query rate and TTL distribution.
A DNS resolver cache (systemd-resolved, nscd, dnsmasq, or an application-level cache) reaches a steady-state entry count determined by how many unique queries arrive per second multiplied by how long each answer stays valid — a query rate of 40/sec with a 300-second average TTL settles around 12,000 cached entries, since older entries expire at roughly the same rate new unique queries arrive. Each cached record consumes a modest but nonzero amount of memory for the name, record type, TTL countdown, and answer data, which this calculator totals for basic capacity planning.
Steady-state cache entries
entries = queries_per_sec × avg_TTL
`resolvectl statistics` shows cache hits, misses, and current cache size for systemd-resolved; `sudo systemd-resolve --statistics` is the equivalent on older systemd versions.
A high query rate with very short TTLs (e.g. some cloud load balancer DNS records use 5-60 second TTLs) can still result in a small steady-state cache, since entries expire almost as fast as they're added — it's the product of rate and duration, not rate alone, that determines how many entries coexist at once.
Only up to the point where the cache actually holds the records being requested — for workloads querying a huge number of distinct, rarely-repeated names (low cache hit rate), increasing cache size has diminishing returns, and the bottleneck is upstream resolution latency rather than cache capacity.