started · updated
Cloudflare reclaims 100 TB of RAM via DNS cache optimization
Cloudflare has successfully reclaimed approximately 100 TB of RAM across its global infrastructure through a series of five code optimizations to its Big Pineapple platform. This platform powers several key services, including the 1.1.1.1 public resolver, DNS Firewall, Gateway DNS, and AS112.
By managing over 250 billion DNS entries, the company found that even a single byte of unnecessary data per entry resulted in 250 GB of wasted memory globally. The optimization process involved rewriting parts of the Rust-based code to change how data is represented and stored in memory.
Key technical changes included replacing dynamic structures like Vec and String with fixed-size Box structures to eliminate unused capacity fields, which alone saved over 15 TB of RAM. Additionally, the company consolidated DNS response sections—such as answer, authority, and additional—into a single structure using smaller offsets. These refinements reduced the size of an individual DNS entry from 953 bytes to 420 bytes while simultaneously improving cache performance.