Cloudflare optimized the DNS cache of its 1.1.1.1 and related services (handled by the "Big Pineapple" platform), reducing its per-entry memory footprint by 56% and freeing up roughly 100 terabytes of memory across its server fleet. Through five key architectural and data-structure changes in Rust—such as replacing growable vectors with fixed-size boxes, packing bitflags, omitting redundant record owners, boxing large enum variants, and storing records as contiguous raw bytes in wire format—the team shrank the average cache entry from 953 bytes to 420 bytes.
Rather than sacrificing performance for space, these memory optimizations simultaneously improved speed. Better memory locality and fewer heap allocations increased cache insert throughput by 43% and reduced lookup latency by 19%. Cloudflare plans to reinvest the reclaimed capacity to increase cache hit rates and further reduce upstream query volume.