Cloudflare freed up 100TB of RAM behind its 1.1.1.1 DNS without adding a single server

Skye Jacobs

Posts: 2,143   +62
Staff
In a nutshell: Cloudflare has cut the memory used by the DNS cache behind its 1.1.1.1 resolver by more than half, freeing about 100TB of RAM across its network. The company did not replace server hardware or remove memory modules. Instead, engineers changed how cached DNS data is stored in software.

The optimization work was centered on Big Pineapple, Cloudflare's DNS caching platform behind the popular 1.1.1.1 resolver, DNS Firewall, and several other DNS services they offer. In a technical blog post, systems engineer Sebastiaan Neuteboom detailed five changes to the Rust codebase that shrank a typical cache entry from 953 bytes to 420 bytes.

The changes also made the cache faster. Cloudflare reported that insert throughput rose from 625,000 to 893,000 entries per second, while lookup latency fell from 828 nanoseconds to 670 nanoseconds. During the rollout, from mid-May to early July, p99 memory use per instance dropped from 9.3GB to 5.3GB.

Cloudflare says Big Pineapple holds more than 250 billion DNS entries at any given time, and at that scale even small amounts of wasted memory add up fast. The company estimates that a single unnecessary byte in each cache entry costs more than 250GB across its fleet.

One of the biggest changes involved Rust's Vec and String types. Those containers are designed to grow, so they store capacity data in addition to the data itself. But DNS records do not need to expand after they enter the cache. Cloudflare replaced those structures with fixed-size boxed slices, eliminating metadata that was no longer useful. The company said that change alone saved more than 15TB of RAM.

Engineers also rethought how DNS responses are laid out in memory. Big Pineapple used to store three separate record lists per response. The new design puts the records in one buffer and identifies them with two-byte offsets.

The cache no longer retains owner names when they simply repeat the queried domain. Cloudflare rebuilds those names when it serves the response. It also now stores record data as length-prefixed raw wire-format bytes. That change addresses a mismatch in the earlier design. A four-byte IPv4 A record occupied the same 144 bytes as the largest DNS record type Cloudflare caches, the relatively uncommon NAPTR record. Storing raw data in a variable-length format reduces that waste.

The 100TB of RAM Cloudflare recovered across its fleet is roughly equal to the memory in 130 of its Gen 13 servers, each of which carries 768GB of DDR5-6400. The company had considered a 1,152GB configuration for that server generation but passed on it after weighing the cost of higher-capacity RAM.

With the RAM savings, Cloudflare plans to allocate the memory to larger DNS caches. Keeping more records locally should improve cache hit rates and reduce the traffic it sends to authoritative DNS servers.

This project follows another major memory-efficiency effort completed last year, when Cloudflare rewrote its FL2 request-handling layer in Rust. That's probably a good way to spend resources and squeeze more out of its existing infrastructure as server memory gets pricier.

Permalink to story:

 
The only thing I use a Cloud service for (in my case it's free) is for my outside cameras. Wouldn't be the end of the world if I lost they lost that data, or I couldn't retrieve it.
 
The only thing I use a Cloud service for (in my case it's free) is for my outside cameras. Wouldn't be the end of the world if I lost they lost that data, or I couldn't retrieve it.
You pay for your cloud service with your data. Also, depending on which cameras you have it is linked to flocks server and you voluntarily give law enforcement access to them
 
No that's NOT true. I'm smarter than that...
Ring cameras are the most famous ones that do this, but most home camera systems that make use of the cloud do this. Not saying yours do, but if that's something you care about you have to make certain that yours don't
 
Cloudflare pretty much covers 40% of the complete internet. It's insane when you think of it, 40% of all internet's traffic tunnels through them. Such a large scale of new trends, bots, malware and you name it. I've been using or at least deploying all their 1.1.1.1 DNS services locally and in my phone (Cloudflare WARP). DNS lookups are faster, and it's privacy minded. Your ISP won't see the sites you visit, nor the data it can collect through it. You also evade any blocking going on (I.e in Europe rt.com is blocked), and it's a good gesture in the excellent products Cloudflare is providing.
 
Ring cameras are the most famous ones that do this, but most home camera systems that make use of the cloud do this. Not saying yours do, but if that's something you care about you have to make certain that yours don't
So you saw him claim he didn't hand over his data and you just rejected his response and still claim he didn't do his research?
 
So you saw him claim he didn't hand over his data and you just rejected his response and still claim he didn't do his research?
No, I didn't make that claim. I said he should double check it because they're sneaky ****ers always switching up their EULA in updates to steal your data so you can never trust any cloud company reliably
 
Cloudflare pretty much covers 40% of the complete internet. It's insane when you think of it
It is. And not a good thing to have such concentration.

For very simple DNS resolving, I'm using Quad9 (9.9.9.9). Great quality, better privacy, better control on how they respond, and while it's a hosted service I don't control at least it's a bit more fragmentation than using 1.1.1.1
 
Back