Cloudflare Cuts 100TB of RAM From 1.1.1.1's DNS Cache — and Made It Faster
Cloudflare’s DNS platform, internally called Big Pineapple, holds more than 250 billion cache entries at any moment across services like 1.1.1.1, Gateway DNS, and DNS Firewall. At that scale, every wasted byte per entry costs over 250GB fleet-wide, so the team reworked how each cache entry is laid out in memory. Five successive changes to the Rust data structures cut the per-entry footprint by more than half, freeing roughly 100 terabytes of RAM — equivalent to 130 of Cloudflare’s Gen 13 servers.
The wins came from squeezing structural overhead out of the entry types rather than dropping data. Swapping growable Vec and String fields for fixed Box<[T]> and Box
Notably, the leaner layout also ran faster: insert throughput rose 43% and lookup latency fell 19%, because fewer allocations and tighter memory locality meant space and speed improved together rather than trading off. The work is a practical case study in low-level Rust memory optimization at hyperscale, where structural details like capacity fields, padding, and enum tags translate directly into hardware saved.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.