Cloudflare freed up 100TB of RAM behind its 1.1.1.1 DNS without adding a single server
Key Points:
- Cloudflare reduced the memory usage of its DNS cache behind the 1.1.1.1 resolver by more than half, freeing approximately 100TB of RAM across its network without changing hardware.
- The optimization focused on Big Pineapple, Cloudflare's DNS caching platform, by implementing five key changes in the Rust codebase that shrank cache entries from 953 bytes to 420 bytes.
- These software improvements also enhanced performance, increasing insert throughput by 43% and reducing lookup latency by 19%, while lowering per-instance memory use from 9.3GB to 5.3GB during rollout.
- Significant changes included replacing Rust’s growable Vec and String types with fixed-size boxed slices, reorganizing DNS record storage into a single buffer, and storing record data as length-prefixed raw wire-format bytes to reduce wasted space.
- The reclaimed 100TB of RAM allows Cloudflare to expand its DNS caches, improving cache hit rates and reducing authoritative DNS server traffic, representing a cost-effective infrastructure enhancement amid rising memory prices.