---
title: "How we halved DNS build delay and cut memory use by 85%"
description: "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."
---

# How we halved DNS build delay and cut memory use by 85%

[Cloudflare](https://yomu.fyi/company/cloudflare) · Alex Fattouche · Nov 2, 2026

**Type:** Problem & solution

## 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.

**Tags:** [Cloudflare](https://yomu.fyi/topic/cloudflare), [DNS](https://yomu.fyi/topic/dns), [Kafka](https://yomu.fyi/topic/kafka), [Performance](https://yomu.fyi/topic/performance), [Quicksilver](https://yomu.fyi/topic/quicksilver)

- Source: [Cloudflare](https://blog.cloudflare.com/dns-targeted-zone-builds)
- Source URL: https://blog.cloudflare.com/dns-targeted-zone-builds
- Ingested by Yomu: 2026-11-02T15:00:11.712Z

[Read original post](https://blog.cloudflare.com/dns-targeted-zone-builds)
