✨Cloudflare Shrinks DNS Cache Footprint by 56%
Cloudflare's DNS Cache Got 56% Smaller, Faster Too
TL;DR
Cloudflare redesigned its DNS cache to save 100TB of memory and boost cache insertion throughput by 43%. This impacts DNS performance and costs for large-scale deployments.
Cloudflare just slashed the memory footprint of its DNS cache by 56%, freeing up 100TB of working-set memory across its fleet. This redesign not only reduces costs but also improves cache insertion throughput by 43% and lookup latency by 19%. If you're running a large-scale DNS service, this could mean major savings and performance gains. The changes involved replacing Vec and String with Box<[T]> and Box<str>, packing Booleans into bitflags, and more.

Key Points
Cloudflare's DNS cache redesign reduced per-entry footprint by 56%, freeing 100TB of memory fleetwide.
Cache insertion throughput increased by 43%, and lookup latency dropped by 19%.
Cloudflare replaced Vec and String with Box<[T]> and Box<str>, saving 64 bytes per entry.
Cloudflare combined answer, authority, and additional records into one list with compact offsets.
The final design stores record data in a contiguous byte buffer, reducing overhead and improving locality.
Why It Matters
If you're running a large-scale DNS service like Cloudflare's 1.1.1.1 resolver, this redesign could mean major savings and performance gains. For instance, at p99, resident memory per instance fell from 9.3 GB to 5.3 GB, and at p90, memory declined from 6.5 GB to 3.8 GB. This impacts DNS performance and costs for large-scale deployments.
Comments
Be the first to comment
Enjoyed this article?
Get it daily. 7am. Free. Reads in 5 minutes.
Join 3,488 builders reading daily.