CloudflareAlex FattoucheProblem & solution
How we halved DNS build delay and cut memory use by 85%
Summary
Cloudflare’s DNS Zone Builder now processes about 700 record changes per second, with some zones exceeding 20 million records. Full builds that read and encode every record no longer scaled for the largest zones because the zone does not fit in memory. The team built a targeted build planner that selects the smallest safe build from five types based on what changed, requiring byte-for-byte identity with a full build, and a scheduler that combines work for the same zone. Zone setting changes no longer trigger full rebuilds of massive zones, and above a fixed record-count threshold the Zone Builder never escalates to a full build, instead rebuilding the apex, metadata, and every name identified by queued events. This cut peak memory by 85% and halved the time from a DNS change to its data being written to Quicksilver, with p99 build delay now about 12 seconds.
Context
Cloudflare’s DNS Zone Builder processes changes to DNS zones, converting them into data for authoritative servers. With increasing event rates (700 per second) and zone sizes (over 20 million records), full builds that read and encode every record became unsustainable. The team needed a targeted approach to avoid rebuilding entire zones for small changes.
Approach / What changed
Implemented a targeted build planner that selects from five build types (resources only, resources and metadata, apex and metadata, purge, full zone) based on what changed, ensuring byte-for-byte identity with a full build. Combined with a scheduler that merges work for the same zone, and a threshold that prevents full builds for zones above a certain record count.
Takeaways
The targeted build planner selects from five build types, ensuring every key written is byte-for-byte identical to what a full build would write; if not provable, a full build is used.
Zone setting changes no longer trigger full rebuilds of zones with tens of millions of records; above a fixed record-count threshold, the Zone Builder never escalates to a full build.
The changes cut peak memory by 85% and halved the time from a DNS change to its data being written to Quicksilver, with p99 build delay now about 12 seconds.
FAQ
Why did full builds stop scaling?
Full builds read, encode, and compare every record, holding the whole zone in memory. For zones with tens of millions of records, the zone does not fit in memory, making full builds infeasible.
How does the planner ensure correctness?
The planner requires that every key a targeted build writes must be byte-for-byte identical to what a full build would write. If that cannot be proven, a full build is used. The planner never turns uncertainty into less work.
What happens when a zone is too large for a full build?
Above a fixed record-count threshold, the Zone Builder never escalates to a full build. Instead, it rebuilds the apex, metadata, and every name identified by the queued events, accepting the tradeoff because a full build cannot finish.
Source and freshness
- Source
- blog.cloudflare.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.