🇮🇳
स्वतंत्रता दिवस की हार्दिक शुभकामनाएं! 🇮🇳 Happy Independence Day! | Har Ghar Tiranga | देश के 80वें स्वतंत्रता दिवस पर आज़ादी का अमृत महोत्सव मनाएं! - Celebrate the 80th Independence Day of India!

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

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

Cloudflare Reclaims 100TB of RAM Through Massive DNS Cache Optimization

In a significant feat of engineering, Cloudflare has managed to slash the memory footprint of its DNS infrastructure by more than half, effectively freeing up 100 terabytes of RAM across its global network. Remarkably, the company achieved this milestone without swapping out a single piece of hardware; instead, the gains were realized through a strategic overhaul of the software architecture powering its “Big Pineapple” DNS caching platform.

Big Pineapple serves as the backbone for several of Cloudflare’s core services, most notably its lightning-fast 1.1.1.1 resolver and its DNS Firewall. Given that the platform manages over 250 billion DNS entries at any given moment, even minor inefficiencies can translate into massive resource waste. Cloudflare engineers estimated that just one unnecessary byte per entry amounted to a total loss of over 250GB across their entire server fleet.

Precision Engineering in Rust

In a detailed technical breakdown, systems engineer Sebastiaan Neuteboom outlined how the team refactored the Rust-based codebase to reduce the average cache entry size from 953 bytes to a mere 420 bytes.

The optimization process focused on five key areas:

  • Eliminating Metadata: The team moved away from Rust’s standard Vec and String types, which are designed to grow and thus carry extra capacity metadata. By switching to fixed-size boxed slices for DNS records—which do not change once cached—they reclaimed over 15TB of RAM alone.
  • Streamlined Data Layouts: Engineers redesigned how DNS responses are stored, moving from three separate record lists to a single buffer identified by two-byte offsets.
  • Variable-Length Efficiency: Previously, a small IPv4 record occupied the same 144-byte slot as a much larger, rarer record type. By moving to a length-prefixed raw wire-format, Cloudflare eliminated significant padding waste.
  • Smart Reconstruction: The system no longer stores “owner names” when they match the queried domain, instead rebuilding them on the fly when a response is served.

Performance Gains Beyond Memory

The benefits of this optimization project extended well beyond capacity. Following the rollout between mid-May and early July, Cloudflare observed that p99 memory usage per instance dropped from 9.3GB to 5.3GB.

Furthermore, the system became faster. Insert throughput jumped from 625,000 to 893,000 entries per second, and lookup latency—the time it takes for the system to find and serve a DNS record—improved from 828 nanoseconds to 670 nanoseconds.

Investing in Efficiency

The 100TB of RAM reclaimed by Cloudflare is equivalent to the total memory capacity of roughly 130 of its high-performance Gen 13 servers. Rather than simply offloading that capacity, Cloudflare intends to reinvest this “found” memory by expanding its DNS caches. By keeping more records locally, the company aims to improve cache hit rates and reduce the amount of traffic forced to travel to authoritative DNS servers.

This project marks another milestone in Cloudflare’s ongoing initiative to optimize its infrastructure. Following the successful rewrite of its FL2 request-handling layer in Rust last year, the company is proving that in the modern era of high-cost server hardware, writing efficient software is often more impactful than buying more silicon. For a closer look at the technical achievement, you can find more details on how Cloudflare freed up 100TB of RAM on their official blog.

Leave a Reply

Your email address will not be published. Required fields are marked *