Cloudflare Cuts DNS Cache Memory by 100TB via Data Structure Changes
The optimization shows how careful data structure work at the scale of 250 billion cache entries yields dramatic resource savings without hardware upgrades.
Reporting from 1 source: GIGAZINE.
Cloudflare revised the data structure of its DNS cache for 1.1.1.1 and other services, cutting memory usage by about 100TB across the system. Per-entry memory dropped 56 percent, from 953 to 420 bytes, while read and write speeds improved. The changes target inefficiencies in Rust types, DNS section storage, and record types.
Cloudflare's Big Pineapple DNS infrastructure maintains over 250 billion cache entries at any given time, so even a single byte per entry costs more than 250GB of memory. The team replaced Rust's Vec and String types with fixed-size Box types, cutting 64 bytes per entry by removing unused capacity. DNS response sections, previously stored in separate lists, now share one list with two byte offsets, saving 28 bytes each. Boolean values were packed at the bit level, and padding was reduced.
The largest gain came from record types. The enum used for all record types reserved 144 bytes per entry to fit the largest type, NAPTR, while A and AAAA records, which make up over 80 percent of traffic, need only 4 and 16 bytes. Moving large types to a separate memory area saved 120 bytes per entry for A and AAAA records. These changes, combined with avoiding duplicate domain name storage, produced the 100TB reduction.
Synthesized by Yomimono from the 1 cited source below, including Japanese-language reporting where cited, then editorially reviewed before publishing.