How we halved DNS build delay and cut memory use by 85%
When Cloudflare's DNS propagation pipeline was last profiled in 2022, the Zone Builder received about 250 record changes per second; today it handles roughly 700, nearly three times as many, plus about 100 other events such as zone setting changes. The volume of events was never the core problem; rather, the nature of the work and how it scales with zone size posed the real challenge. Some zones now hold more than 20 million records, with expectations of growth toward hundreds of millions, making full zone rebuilds increasingly impractical.
Each event starts a clock measuring the time to turn a change into data authoritative DNS servers can use; this work is called a build. In 2022, per-record builds were 150 times faster than full builds on average, and on a test zone with one million records, per-record builds were 4,250 times faster. The team resolved per-record targeting but recognized that zone setting changes, such as Universal SSL toggles, required a similar planner because a full build must read, encode, and compare every record, holding the entire zone in memory—an operation that does not scale for zones with tens of millions of records.
The new targeted build planner classifies each event into one of five build types: resources only, resources and metadata, apex and metadata, purge, or full zone. The planner chooses the smallest build it can prove is byte-for-byte identical to what a full build would produce, never turning uncertainty into less work. When classification is ambiguous—such as timestamp-only updates or unknown events—the planner defaults to a full build to avoid stale or incorrect DNS data at the edge. Full builds remain necessary when a change can affect records anywhere in the zone or when a zone may need to be published for the first time, though a deliberate threshold prevents escalation for the largest zones.
Quicksilver stores each zone's record keys separately but maintains one shared metadata key for every Cloudflare zone with the same domain name, acting as a directory telling authoritative DNS servers which internal zone IDs may be used when answering queries. Because one public domain can briefly correspond to multiple internal zones during onboarding, offboarding, and lifecycle changes, builds affecting nameserver or wildcard records must update both the zone's record keys and the shared metadata key. At execution time, the Zone Builder reads a fresh publication snapshot—the current zone settings, network enablement status, and which same-name zone IDs belong in the metadata key—ensuring the build reflects current state before writing.
A unified scheduler replaced the previous separate schedulers for record work and full-zone work, allowing the planner and scheduler to combine events for the same zone before execution. When several events arrive before a build starts, the scheduler merges their work—for example, an A record change at www.example.com and a wildcard change at *.example.com are combined into one build including both names and shared metadata. A purge overrides every rebuild because its desired result is that the zone is no longer published, and if any event requires a complete zone, the combined build escalates to full. The scheduler separately tracks DNS work and Kafka messages awaiting acknowledgment, preserving retries and preventing one busy zone from monopolizing workers via per-zone rebuild intervals.
Results over a 24-hour period showed 86.81% of builds as resources only, 2.54% as resources and metadata, 2.30% as apex and metadata, and 1.30% as purges, meaning 92.95% of builds avoided rebuilding the complete zone. Full builds fell to 7.04% of the total, a reduction of about 40% from prior levels. Aggregate working-set memory dropped from an average of 49 GiB to 7 GiB, an 86% reduction, and peaks fell from 79 GiB to 12 GiB, an 85% reduction. The median build completion delay halved from about 7.7 seconds to about 3.3 seconds after the team shortened rebuild intervals and reduced the DNS Kafka Aggregator's event buffer, with p99 completion time dropping from 14.6 minutes to 1.21 minutes, a 12-fold improvement.
Source credits
By Alex Fattouche from Cloudflare Blog. Edited by SetuGeo.