This article details Cloudflare's architectural changes to their DNS propagation pipeline, focusing on how they halved DNS build delays and significantly reduced memory usage. The improvements center around moving from full zone rebuilds to targeted, incremental builds, especially for large zones and zone setting changes, by analyzing event data and optimizing their build planning and scheduling processes. This approach addresses the scaling challenges posed by millions of DNS records and frequent updates in a global distributed system.
Read original on Cloudflare BlogCloudflare's DNS propagation pipeline is a critical component for distributing DNS record changes globally. As the number of events and the size of individual zones (some with over 20 million records) grew, the original system, which relied on full zone rebuilds, faced significant scalability challenges, particularly concerning memory consumption and build latency. This case study highlights their architectural shift towards a more efficient, targeted approach.
Scaling Challenge: Full Builds
The original Zone Builder's simplicity—it didn't need to know *why* a zone changed, just rebuilt from current state—became its downfall. For zones with tens of millions of records, a full build meant reading, encoding, comparing every record, and holding the entire zone in memory, leading to OutOfMemory errors and blocking further changes. Zone settings changes were particularly problematic as they often triggered full rebuilds.
To address the scalability issues, Cloudflare introduced a targeted build planner and a unified scheduler. This system intelligently identifies the minimal set of changes required for a build, drastically reducing memory usage and latency. The core problems solved were: events needing to be more specific, mapping changes to the smallest safe build, accounting for shared zone data, handling database changes between event and build, and combining work efficiently.
A crucial trade-off for very large zones (above a fixed record-count threshold) is that the Zone Builder will *never* escalate to a full build, even if uncertainty suggests it. Instead, it rebuilds the apex, metadata, and specifically identified names. This pragmatic decision acknowledges that a full build for such zones is infeasible and would block other operations, prioritizing availability over absolute theoretical correctness in rare edge cases.