Key Takeaways
- Five Rust storage changes cut per-entry cache memory by 56%, from 953 to 420 bytes.
- The optimization freed roughly 100 TB of RAM across Cloudflare’s 1.1.1.1 infrastructure.
- Insert throughput jumped 43% and lookup latency dropped 19%, proving efficiency gains can boost speed.
Table of Contents
A 56 Percent Smaller Cache Entry Changes Fleet Math
Cloudflare has documented a 56 percent reduction in per-entry memory footprint for its 1.1.1.1 DNS cache, freeing roughly 100 terabytes of fleet-wide RAM and cutting steady-state resident memory at the p99 level from 9.3 GB to 5.3 GB per instance. The rollout, completed across production services by July 6, 2026, came from five successive changes to how Rust cache entries are stored.
The gains were not bought with slower performance. Insert throughput climbed 43 percent and lookup latency fell 19 percent, because fewer allocations and tighter memory locality meant the cache did not trade speed for space.
Five Rust Storage Levers Behind the 100 Terabytes
At more than 250 billion DNS cache entries in steady state, a single wasted byte per record costs over 250 gigabytes of memory. The optimization team targeted structural overhead that remains after a cache entry is inserted and no longer mutates.
As detailed in Cloudflare’s write-up, the first lever eliminated capacity fields and over-reserved heap space. Because a stored DNS response never changes, replacing Vec and String fields with boxed slices and boxed strings removed an eight-byte capacity cost per field while suppressing future-growth allocations.
Across eight Vec and String fields per entry, that one shift saved 64 bytes per entry and more than 15 terabytes in aggregate across the fleet.
A second lever consolidated the answer, authority, and additional record sections into one list indexed by two-byte offsets. That removed two entire list structures, each carrying an eight-byte pointer and eight-byte length, replacing them with two-byte markers and saving 28 bytes per entry.
Padding elimination compounded those savings. Packing multiple boolean flags into one bitflag shrank surrounding alignment padding, so structs contracted by more than the raw field size.
The third lever removed redundant owner names. For most records, the owner matches the queried domain, so the cache can infer it from the key instead of storing a full name.
The fourth lever attacked Rust enum sizing. Record data stored as enum variants was sized for the largest possible variant, NAPTR at 136 bytes, leaving small A and AAAA records paying for 120 bytes of unused space.
Boxing only the large variants moved rare record types to the heap while keeping common records inline, cutting the common enum cost.
The fifth lever went further: record data is now stored as raw wire-format bytes in a single contiguous buffer with length prefixes. That removes per-variant enum overhead and scattered heap allocations altogether.
The raw encoding eliminates most per-record parsing on lookup because common types like A, AAAA, TXT, and DNSSEC records can be copied directly into outgoing DNS responses. Only records that require name compression, such as CNAME, NS, MX, and SOA, still need parsing.
Benchmarks showed this wire-format change alone improved insert throughput by 13 percent and reduced lookup latency by 5 percent. Across the full optimization set, per-entry footprint fell from 953 bytes to 420 bytes, and per-entry allocation volume dropped from 1.1 KB to 461 bytes.
- Per-entry net footprint: 953 bytes to 420 bytes, a 56 percent reduction.
- Per-entry allocations: 1.1 KB to 461 bytes, a 58 percent reduction.
- Insert throughput: 625,000 to 893,000 entries per second, up 43 percent.
- Lookup latency: 828 ns to 670 ns, down 19 percent.
Production measurements tracked p90, p98, and p99 resident memory across instances. At p90, memory dropped from 6.5 GB to 3.8 GB, a 42 percent reduction.
Why Memory Efficiency Now Doubles as a Speed Strategy
In large-scale DNS infrastructure, per-byte overhead is rarely just a storage problem. It is a cache locality problem that inflates allocator pressure, pointer chasing, and CPU cache misses.
The 1.1.1.1 optimization is significant because it improved memory and speed together. The change also matters for ECS-heavy locations, where authoritative servers return different answers depending on client network.
Those locations store multiple variants of the same query, making per-entry compression more valuable where cache cardinality is highest.
For performance teams, the deeper lesson is structural: mutability assumptions embedded in Rust collections have a measurable fleet cost. Once a data structure becomes immutable after insertion, growth capacity and resizing overhead are pure waste.
The 100 terabytes of freed memory is now available for cache capacity expansion without increasing fleet memory. That can increase hit rates and reduce upstream query volume, changing the cost profile of DNS delivery at the edge.
As of late August 2026, the rollout has been complete for roughly seven weeks. The stable plateau data in production, rather than initial post-restart dips, confirms that the reductions represent steady-state working-set behavior.
The Cache Reinvestment That Resets DNS Capacity
The 1.1.1.1 memory overhaul proves that DNS cache performance is no longer a trade-off between space and speed; it is a single engineering discipline. For teams building latency-sensitive infrastructure, WordPress speed engineering is how Andres SEO Expert applies the same discipline — contact the team.
Frequently Asked Questions
How did Cloudflare reduce DNS cache memory usage by 56%?
Cloudflare reduced the per-entry memory footprint in its 1.1.1.1 DNS cache from 953 bytes to 420 bytes, a 56 percent reduction, through five successive changes to how Rust cache entries are stored. These changes eliminated capacity fields, consolidated record sections, removed redundant owner names, boxed large enum variants, and switched to raw wire-format bytes.
What are the five storage levers behind the 100 terabytes freed in the DNS cache?
The five levers are: eliminating capacity fields and over-reserved heap space by using boxed slices/strings, consolidating answer/authority/additional sections into one list with two-byte offsets, removing redundant owner names, boxing only large enum variants to reduce enum sizing, and storing record data as raw wire-format bytes in a single contiguous buffer.
How did the DNS cache optimization affect performance?
The optimization improved both insert throughput and lookup latency. Insert throughput climbed 43 percent from 625,000 to 893,000 entries per second, and lookup latency fell 19 percent from 828 ns to 670 ns, due to fewer allocations and tighter memory locality.
Why did memory efficiency double as a speed strategy for the 1.1.1.1 cache?
In large-scale DNS infrastructure, per-byte overhead is also a cache locality problem that inflates allocator pressure, pointer chasing, and CPU cache misses. Reducing the memory footprint improved memory and speed together, making it a speed strategy as well.
What happened to the 100 terabytes of freed memory from the DNS cache?
The 100 terabytes of freed memory is now available for cache capacity expansion without increasing fleet memory. This can increase hit rates and reduce upstream query volume, changing the cost profile of DNS delivery at the edge.
How does the wire-format storage change improve DNS lookup performance?
The raw wire-format encoding eliminates most per-record parsing on lookup because common record types like A, AAAA, TXT, and DNSSEC can be copied directly into outgoing DNS responses. Only records that require name compression, such as CNAME, NS, MX, and SOA, still need parsing, improving insert throughput and reducing lookup latency.
