Breaking Lab srl
The hidden cost of DNS at scale
Every server that handles DNS — the system that translates domain names like “example.com” into IP addresses — keeps a local cache in RAM. That cache stores recent answers so the server doesn’t have to ask upstream every single time. When you are running one server, the memory used by that cache barely registers. When you are running Cloudflare’s global 1.1.1.1 resolver, handling trillions of queries a day, it adds up to hundreds of terabytes.
Cloudflare recently published a detailed breakdown of how their engineering team cut the memory footprint of that cache by 56% per entry. The result: roughly 100 terabytes of RAM freed across their entire fleet — without buying a single new machine.
What they actually changed
The code is written in Rust, a systems programming language known for fine-grained control over how data sits in memory. The team made five separate changes, each targeting a specific inefficiency in how DNS records were stored. The biggest wins came from trimming wasted space inside data structures — the small gaps and paddings that a compiler adds automatically to keep data aligned in memory. On one record type alone, they shrank the size from 153 bytes to 88 bytes.
They also replaced a general-purpose string storage type with a more compact one tuned to short text values, since most DNS names are short. And they swapped out a flexible but heavy container type for a simpler array in places where the number of items was always small and predictable.
Why this matters if you run your own server
You are almost certainly not running DNS at Cloudflare’s scale. But the underlying lesson applies to any service that keeps large amounts of data in RAM — whether that’s a database, a reverse proxy cache, or a self-hosted DNS resolver like Unbound or PowerDNS. Memory is not free. On a VPS (a virtual private server, a rented slice of a physical machine), RAM is often the first resource you run out of, and upgrading to a bigger plan costs money every month.
Cloudflare’s writeup is unusually transparent about the trade-offs they considered and the measurements they took before committing each change. Even if you never touch Rust, reading through their reasoning is a practical education in how to think about memory when you are tuning a service.
Looking ahead
The fact that a company with essentially unlimited hardware budget still invests heavily in software-level efficiency is a useful signal. As AI workloads compete for data-centre RAM and cloud providers quietly raise prices, the ability to squeeze more out of the same hardware is becoming a genuine competitive advantage — and a meaningful cost saving — for anyone running infrastructure, large or small.




