Cloudflare’s 1.1.1.1 DNS cache cut saves 100TB of memory

Sebastiaan Neuteboom

The team behind 1.1.1.1 just cut their DNS cache memory usage from 100 terabytes down to 300 gigabytes. Not by throwing more silicon at the problem, but by rewriting the caching layer in Rust and rethinking how they evict stale records. That’s the kind of efficiency jump you usually see in research papers, not in production systems.

And it wasn’t just a happy accident—it happened because their old C++ cache had become a victim of its own success. Every millisecond of latency counted, but the data structures they’d chosen years ago were ballooning out of control as the internet kept growing. So they rolled up their sleeves, rewrote the cache from scratch, and ended up with something that’s not just smaller but faster too. Wonder how they pulled that off?

Technical Overview

At first glance, the memory savings here don’t look revolutionary. Shaving 4GB off a 9.3GB process isn’t going to make anyone stop and rewrite their allocation tracking code. But when you multiply that 43% reduction across 250 billion DNS cache entries, the math becomes inescapable: 250 GB of RAM saved per byte trimmed from each entry. That’s not a cleanup; that’s a data center–scale win.

The improvements aren’t just about the headline numbers. The p99 drop from 9.3 GB to 5.3 GB is real, but the latency improvement—cache lookup falling from 828 ns to 670 ns—is what actually matters when you’re serving 40 million queries per second. If every lookup shaves off another 150 ns, that’s real CPU time freed up to handle more traffic or run other services.

How did they get there? The table gives the clearest clue:

| Metric | Before | After | Change | |-----------------------|--------|-------|--------| | Per-entry allocations | 1.1 KB | 461 B | -58% | | Cache lookup latency | 828 ns | 670 ns | -19% |

The memory reduction wasn’t just a compression trick—it’s a rethink of how each entry is stored. At this scale, every byte counts, and a 58% cut isn’t an optimization; it’s a rewrite of the data structure. The latency drop is harder to pin down, but it likely comes from denser memory layouts and fewer cache misses during lookups.

The numbers hold up under scrutiny. If Big Pineapple is carrying 250 billion entries at any given time, shaving 639 bytes per entry saves 159.75 terabytes at fleet level. That’s not “slightly better memory usage”; that’s enough RAM to retire a few racks. The latency improvement, while smaller in percentage terms, compounds across millions of requests. Every extra nanosecond shaved off a lookup is a micro-optimization that, repeated at scale, turns into macro-efficiency.

Industry Impact

The discussion around DNS caching isn’t really about caching itself—it’s about whether we’re optimizing the wrong layer. The inefficiencies people point to aren’t just quirks of implementation; they’re symptoms of a system that still assumes DNS records are a scarce resource. When you see unused fields or scattered memory allocations, that’s not lazy engineering. That’s a mismatch between the problem (historically small, static datasets) and the tools we’ve repurposed (general-purpose caching layers built for mutable, unpredictable workloads). The people complaining aren’t wrong, but their frustration assumes we’ll always need DNS caching at all. For edge networks serving a handful of domains, it makes sense. For a resolver handling 250 billion records, it’s like using a spreadsheet to track the milky way.

The alternative isn’t just “don’t cache.” It’s acknowledging that DNS resolution has split into two distinct problems. There’s the high-volume, ephemeral lookups—where you want something closer to a hash table with deterministic eviction. And then there’s the long-tail, authoritative data that’s better served by specialized backends. The community’s fixation on contiguous memory layouts and zero-copy tricks misses that the real tension isn’t about speed; it’s about whether we’re still pretending DNS records are hot data. I don’t know if the next generation of resolvers will solve this by rearchitecting caching entirely or by sidestepping it altogether. But the debate makes one thing clear: we’re only now starting to ask the right questions.

Conclusion

Cloudflare’s memory save is one raw number wrapped in another: 250B cache entries, 100TB freed. That’s the kind of leverage you feel in the cables, not on a slide deck. The team didn’t just trim a byte per entry—they cut 58% of per-entry allocations, p99 memory slid from 9.3 GB to 5.3 GB, and all without a single extra node in the rack.

I’m still not sure what to make of the quietness of it. No press tours, no benchmark bombs—just engineers swapping one allocator for another and watching the fleet breathe easier. The trick wasn’t cloud-scale magic; it was Rust code that actually counted the bytes, and a DNS team willing to stare at 250 billion rows of cache until the waste showed itself. Maybe the biggest takeaway is how rare that discipline feels right now.