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

Skye Jacobs

Posts: 2,271   +64
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
 
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
First, there are no companies that I know that are willingly giving your camera data to the cops, without your knowledge or approval. And the cops cannot just compel you for your camera data. They need a warrant. Having said that, there is such a thing as a "DELETE BUTTON", or are you/anyone implying that these cloud service companies keep a copy of my/your data even though I/you delete it on my/your your end/account? And besides, my cloud service is set to delete my camera data every 24hrs.... It's amazing to me that I have to explain this to you otherwise intelligent folks?
 
Last edited:
Glad that the memory woes are acting as a constraint to force code optimisation: a forgotten art from olden times.

This is simply not true. Code optimization is in no way a ‘forgotten art’ and in this case it was a fairly simple optimization.
 
This is simply not true. Code optimization is in no way a ‘forgotten art’ and in this case it was a fairly simple optimization.
Fair enough; it's not forgotten. But, on the broader topic, we must concede that today's applications take a lot more resources for not much more functionality, often to make the programmers' lives easier at the cost of runtime performance.

As an extreme comparison, the Voyager satellites have about 70 KB of RAM.
 
Fair enough; it's not forgotten. But, on the broader topic, we must concede that today's applications take a lot more resources for not much more functionality, often to make the programmers' lives easier at the cost of runtime performance.

As an extreme comparison, the Voyager satellites have about 70 KB of RAM.
This is true but it’s not down to laziness. It’s down to prioritizing other work and allowing hardware to do more heavy lifting. The benefits are still felt elsewhere and none of the devs are sat around being idle I can assure you.
 
This is true but it’s not down to laziness. It’s down to prioritizing other work and allowing hardware to do more heavy lifting. The benefits are still felt elsewhere and none of the devs are sat around being idle I can assure you.
Not saying they are being lazy, but the increased reliance on higher-level frameworks and languages has come at a cost whilst making code and cross-platform deployment easier. Today, applications are taking up gigabytes of memory. Understandably, hardware was cheap all these years, but now that that has changed, more aggressive optimisation will become mandatory.
 
This is my favorite kind of optimization story. One wasted byte per cache entry costing more than 250GB across the fleet is a beautiful illustration of why optimization still matters at hyperscale.
 
This is my favorite kind of optimization story. One wasted byte per cache entry costing more than 250GB across the fleet is a beautiful illustration of why optimization still matters at hyperscale.

Yep. instead of ever expanding with new servers, hardware or even expensive DDR5 you could actually optimize it to the bone and pull more out of the existing.

I'm just sick of all of the "standby while we check to see if you are a bot" delays when going to some websites. And it's CLOUDFARE!

The reason why you get these is because webmasters who run their website on cloudflare, tap the option "I'm under attack" which raises a Js challenge like that on every visitors. Likely to kill off bots. It's not Cloudflare. It's just a bad implementation of the website owner who has no clue on how to properly do it.


It is. And not a good thing to have such concentration.

And why? They have the largest network on the planet and can block 7.3 Terabits per second of a DDOS at no ease.

It is the only company who as well offers domain registrations for registration fee's. Please, more cloudflare.
 
AI could be a useful tool for identifying such things. I wonder if it was used? No credit? lol
 
Yep. instead of ever expanding with new servers, hardware or even expensive DDR5 you could actually optimize it to the bone and pull more out of the existing.



The reason why you get these is because webmasters who run their website on cloudflare, tap the option "I'm under attack" which raises a Js challenge like that on every visitors. Likely to kill off bots. It's not Cloudflare. It's just a bad implementation of the website owner who has no clue on how to properly do it.




And why? They have the largest network on the planet and can block 7.3 Terabits per second of a DDOS at no ease.

It is the only company who as well offers domain registrations for registration fee's. Please, more cloudflare.
Quis custodiet ipsos custodes?
 
Back