Under the hood

How the platform nameservers are built, why we wrote our own authoritative server in Rust instead of running an existing one, how we check that it answers correctly, and what it measures.

Last updated 21 November 2026View as Markdown

Every platform nameserver runs dns-server-rs, an authoritative nameserver we wrote in Rust. It never opens a database: the control plane renders every hosted zone, app hostname and outstanding certificate challenge into one snapshot document, and each nameserver pulls it, keeps the last good copy on disk and answers from memory. The decision that shapes everything else is that the snapshot is the replication protocol: what a record answers is settled when it is built, and the nameserver only has to answer fast, sign, and survive whatever the internet sends it.

What runs where

control plane (TypeScript)
  builds one JSON snapshot of all zones, app hosts,
  ACME challenges, pre-signed DNSKEY sets, sealed ZSKs
        │  HTTPS pull, full document, every 15 s
        ▼
nameserver (dns-server-rs, one small container each,
            a few machines in different locations)
  disk: last good snapshot    memory: zone store
        ▲
resolver ──UDP/TCP 53──▶ per-address limit ─▶ decode
          ─▶ resolve ─▶ sign (cached) ─▶ RRL ─▶ encode
        │
        └─ every 60 s: counts, optional query-log lines
           back to the control plane

A query is decoded with hickory-proto, answered against the in-memory store, signed online if the zone has DNSSEC on, passed through response-rate limiting (UDP only) and encoded. UDP is served by one task per core on a shared socket; TCP has its own listener. The snapshot is swapped in atomically, so a pull never blocks an answer. Zone transfers to your secondaries and NOTIFY on a serial change come from the same process and the same snapshot. The country table for geolocation loads on its own thread at start-up; until then, geolocation records answer their default.

What we built, and what we did not

Ours is the glue and the logic: transports and limits, the resolver, the snapshot store, response-rate limiting, online DNSSEC signing with compact denial of existence (RFC 9824), AXFR/IXFR/NOTIFY with TSIG, geolocation lookup and telemetry, about 4,500 lines of Rust including tests. Not ours: hickory-proto 0.26 for the wire format, DNSSEC record types and TSIG, tokio for I/O, ring for ECDSA P-256 and AES-GCM, arc-swap for the snapshot swap, reqwest with rustls for the pull, mimalloc as the allocator, and DB-IP's IP-to-Country Lite table (CC BY 4.0). We did not use hickory-server; no reason either way was recorded.

Why our own server at all. The records are derived from platform state: an app hostname follows the machine serving it with nobody editing a zone, answers depend on the client (geolocation, weighted), on health checks (failover) and on other resources (ALIAS), and DNSSEC signs at answer time so those answers are signed as sent. Pre-signing was rejected because it breaks per-query weighted and geolocation answers and needs a full NSEC chain. We never wrote an evaluation of PowerDNS, Knot, NSD, CoreDNS or BIND as the serving engine before we built it; a static zone-file server cannot give those answers without a layer in front of it. On 2026-11-21 we did measure Knot and NSD on our benchmark zones (below): per core they answer about twice as fast as ours. Where their behaviour is the standard we copied it: response-rate limiting and TSIG work as BIND and Knot do them, and BIND 9.18 and Knot 3.2 are what we run as secondaries to test our zone transfers against.

Why Rust rather than the TypeScript server it replaced. The first server, from June 2026, was TypeScript on dns-packet, answering app hostnames and certificate challenges from the database. Hosted zones made it a public authoritative server parsing packets from anyone, and dns-packet was not written for hostile input: its failures are invisible until fuzzed. Fuzzing it found six bugs, among them a one-packet remote crash (a 103-byte UDP packet caused 65,535 re-decodes and exhausted the heap) and a TCP crash on a TXT set over 64 KB. We fixed them, but the problem was the parser, and hickory-proto is built and fuzzed for exactly this job. The port also gave about five times the throughput per core, multi-core scaling, a server that holds the advertised cap of 100,000 record sets inside a 256 MB container (the TypeScript one did not), start-up in 0.04 to 0.28 s instead of 1.2 to 1.9 s, and a 55 MB image instead of 1.74 GB (measured 2026-11-10/11 on the same arm-16 box, raw output not kept). We rejected keeping TypeScript (256 MB could not hold the caps, flood headroom at half a CPU was an estimated 6,000 queries a second, the parser needed a guard) and porting the database mode (about 700 lines of naming rules shared with the console would exist twice), so the snapshot became the contract and its builder stayed in TypeScript. mimalloc is there because glibc's malloc kept each swap's high-water mark: on 2026-11-10/11, twenty pulls of a 100,000 record-set snapshot left about 410 MB resident (raw output not kept).

DNSSEC. Online signing, ECDSA P-256 (algorithm 13) only. The key-signing key stays on the control plane, sealed under the KMS master key, and signs the DNSKEY set at build time; the zone-signing key travels in the snapshot sealed with AES-256-GCM under a key the snapshot never contains, and every other RRset is signed at answer time, with a cache of 16 shards of 4,096 signatures. Compact denial means a random-subdomain flood costs one signature per negative answer on a nameserver budgeted at half a CPU.

Zone transfers (decided 2026-11-20). The snapshot nameservers serve AXFR, and IXFR as a full zone unless the secondary is current, over TCP to an allow-list, TSIG by default. Rejected: a separate transfer service reading the database (a second serving path to keep equal to the nameserver's answers), real IXFR deltas (needs snapshot history on every nameserver; ranked next), transferring a signed zone unsigned (a validation outage by design), always requiring TSIG (shuts out free secondaries that cannot sign), and being an ongoing secondary of your primary.

Geolocation and IPv6. Country, then continent, then default, honouring EDNS Client Subnet; latency routing waits for a second region. IPv6 is served on a real IPv6 network, not through a userspace proxy, so v6 clients keep their addresses for rate limits, RRL and geolocation.

caddy-dns-ews. A Go libdns provider and Caddy module (dns.providers.ews, 750 lines including tests against a fake DNS API) so Caddy gets wildcard certificates on hosted zones without another DNS provider. It adds and removes single values in the _acme-challenge TXT set, so a wildcard and its apex do not overwrite each other, and on a platform machine it exchanges the instance identity for short-lived credentials. See Get wildcard certificates with Caddy.

How we know it answers the same

The Rust resolver is a branch-for-branch port of the TypeScript one. Before the old server was deleted we recorded its answers to 2,450 cases: 63 names by 12 types, EDNS sizes from 0 to 65,535, odd flags and opcodes, 41 hand-made malformed packets, TCP pipelining and partial frames, an answer over 64 KB, 150 random and 300 bit-flipped datagrams. Every gate run replays them, compares the decoded answers (not bytes: the Rust server compresses names), and fails on any difference not explained by a named rule that inspects the packet. The pre-switch run had 1,743 cases: 1,692 identical, 51 explained (compression letting records fit where the old server truncated, questions the old server dropped, malformed records hickory-proto rejects), 0 unexplained. The gate also validates 21 signed answers with delv and checks routing and RRL.

Fuzzing is in-process with cargo-fuzz under AddressSanitizer: one target pushes any datagram through decode, answer and encode for UDP and TCP; the other feeds any snapshot document through parse, store and resolve, where a bug must cost a failed pull, never the nameserver. Before the switch: 13.3 million inputs for the packet target (four runs of 20 minutes, coverage flat at 3,442 edges) and 17.1 million for the snapshot target, no crash, hang or slow input. Every gate run fuzzes again, 120 seconds in CI for packets and a third of that for snapshots.

Benchmarks

How to rerun these: the load is public (dnsperf, with the commands below; Knot and NSD from the distribution); the zones, query files and the script that pins the servers are an internal tool, not published, built as the next paragraph describes. The 2026-11-10/11 numbers' raw output was not kept, and the TypeScript server they compare with no longer exists.

Run on 2026-11-21, 15:35 to 15:42 UTC, on our arm-16 test box (16 Ampere Altra Neoverse-N1 cores, 32 GB, aarch64), shared with other work (load average 1.2 when the run started), no VM. Raw output kept. The snapshot held 205 zones (10,000 bulk record sets in 200 zones plus 5 fixture zones) and 2,007 app hosts, 1.0 MB. The country table was not loaded and the one signed fixture zone was served unsigned, so these are unsigned answers without geolocation. The server was pinned with taskset to one core, then to cores 0 to 7, with the per-address rate limit and response rate limiting turned off. Load came from dnsperf 2.14 (the Ubuntu 24.04 package) in a container on cores 8 to 15, 15 s per step, a ladder of offered rates and then unthrottled. CPU time and resident memory are the server's, from /proc. hot.txt is 5,000 lines over 2,338 distinct questions; cold.txt is 1,000,000 lines over 303,452. Both mix existing names, NXDOMAIN, no-data, apex SOA/MX/TXT, in-zone CNAME and REFUSED. One step, and its TCP variant (the unthrottled step drops -Q):

taskset -c 8-15 dnsperf -s 127.0.0.1 -p 25354 -m udp -d cold.txt -l 15 \
  -c 32 -T 4 -t 2 -O latency-histogram -O suppress=timeout,unexpected -Q 40000
taskset -c 8-15 dnsperf -s 127.0.0.1 -p 25354 -m tcp -d hot.txt -l 15 \
  -c 16 -T 4 -t 2 -O latency-histogram -O suppress=timeout,unexpected -Q 40000

One core, UDP:

File Offered q/s Achieved q/s Lost p50 ms p99 ms
hot 10,000 9,999 0 % 0.077 0.279
hot 40,000 39,965 0 % 0.062 0.187
hot unthrottled 59,190 0 % 1.663 2.047
cold 20,000 19,993 0 % 0.049 0.159
cold 120,000 61,071 0 % 1.599 1.983
cold unthrottled 59,908 0 % 1.631 1.951

One core, TCP, and eight cores unthrottled:

Run Offered q/s Achieved q/s Lost p50 ms p99 ms
TCP, 1 core, hot 10,000 9,999 0 % 0.111 0.399
TCP, 1 core, hot 40,000 39,975 0 % 0.735 1.471
TCP, 1 core, hot unthrottled 52,814 0 % 1.727 3.007
UDP, 8 cores, cold unthrottled 419,755 0 % 0.171 0.407
TCP, 8 cores, cold unthrottled 317,644 0 % 0.215 0.783

The server's CPU and resident memory at each of those steps:

Run Offered q/s CPU cores RSS MB
UDP, 1 core, hot 10,000 0.28 24.0
UDP, 1 core, hot 40,000 0.87 24.2
UDP, 1 core, hot unthrottled 0.98 26.4
UDP, 1 core, cold 20,000 0.49 26.5
UDP, 1 core, cold 120,000 0.98 24.7
UDP, 1 core, cold unthrottled 0.98 24.8
TCP, 1 core, hot 10,000 0.35 25.4
TCP, 1 core, hot 40,000 0.98 25.5
TCP, 1 core, hot unthrottled 0.98 26.2
UDP, 8 cores, cold unthrottled 7.33 29.6
TCP, 8 cores, cold unthrottled 6.78 29.9

One core saturates at about 59,000 to 61,000 queries a second over UDP with nothing lost; the clients then queue and p99 sits around 2 ms. Below saturation, up to 40,000 q/s, p50 is 0.05 to 0.18 ms (highest at the lightest step, 5,000 q/s) and p99 0.16 to 0.59 ms. Hot and cold answer alike, as a store without an answer cache should. Peak resident memory over the run was 51 MB.

The same harness on the same machine type on 2026-11-10/11 (raw output not kept) gave 69,005 q/s unthrottled on one core over UDP, a peak step of 71,110, 59,565 over TCP, and 433,192 UDP and 309,401 TCP on eight cores. Today's one-core figure is about 15 % lower; the box is shared and the server has gained DNSSEC, zone transfers and geolocation since, and we have not isolated the cause. The eight-core figures are within a few percent. Treat the one-core number as a band, not a constant.

That earlier run is the only one with the TypeScript server beside it (2026-11-10/11, same box and harness, raw output not kept): 13,086 to 13,746 q/s on one core over UDP, 18,873 to 18,979 over TCP, and, single-threaded, no more on eight cores; at 10,000 q/s it used 0.81 to 0.89 cores against the Rust server's 0.27 to 0.28, and 169 to 249 MB resident against 21.8 to 25.6. In the container limits of 256 MB and half a CPU, it was killed at the 100,000 record-set cap (it fitted about 75,000) where the Rust server used 177 MiB over twenty pulls; that figure predates the country table.

Against Knot DNS and NSD, 2026-11-21

The same zones and query files served by Knot DNS 3.4.9 and NSD 4.12.0 (the Alpine 3.22 packages, each in a container) beside ours, one server at a time, 19:56 to 20:04 UTC on the same arm-16 box (load average about 3.6 from other work). The snapshot was written out as zone files for them; what a static server cannot do was flattened for all three alike: routed records answer their default, ALIAS sets are left out, nothing is signed. Every server answered the same mix (for cold.txt 70 % NOERROR, 25 % NXDOMAIN, 5 % REFUSED), with nothing lost. Each got core 2, then cores 0 to 7 (Knot with as many UDP and TCP workers, NSD with as many server processes and reuseport); rate limiting off everywhere; dnsperf as above, 15 s per step. CPU and memory for Knot and NSD are their containers' (all processes), memory as anonymous memory now / the peak.

Unthrottled, q/s ours Knot DNS NSD
UDP, 1 core, hot 57,317 101,237 119,319
UDP, 1 core, cold 56,661 103,384 116,702
TCP, 1 core, hot 53,006 39,589 35,635
UDP, 8 cores, hot 460,550 544,549 491,103
UDP, 8 cores, cold 441,512 509,617 513,924
TCP, 8 cores, hot 345,478 68,360 203,103
One core, UDP cold ours Knot DNS NSD
p50 / p99 at 20,000 q/s, ms 0.049 / 0.303 0.062 / 0.171 0.044 / 0.155
CPU per 10,000 answers at saturation, ms 176 97 86
Memory now / peak, MB 12.9 / 19.6 5.2 / 7.9 13.2 / 47.8

What it shows: on one core Knot answers about 1.8 times and NSD about 2.1 times as many UDP queries as ours, at roughly half our CPU per answer. Our server keeps one TCP connection's work on one core and answers more over TCP (on eight cores, Knot's TCP stayed at 1.6 cores busy with its default TCP handling; we did not tune it). On eight cores over UDP we are about 15 % behind both, with dnsperf's 32 clients part of the limit. Neither Knot nor NSD here does what ours exists for (answers computed from platform state per query, signing at answer time, geolocation, weighted and failover answers), so this is the price of that in raw speed, not a verdict: at the half a CPU a nameserver is budgeted, either would have about twice our headroom against a flood.

What these numbers do not show: loopback on one machine, so no network, no loss and no real resolvers; no signatures (a signed answer costs an ECDSA signature or a cache hit on top); no geolocation; no rate limiting; whole cores on an aarch64 box, while a nameserver runs in a container budgeted at half a CPU and 256 MB, which we have not measured. A ceiling, not a promise.

Known limits

  • No anycast: redundancy is a few nameservers in different locations, and a resolver picks one.
  • Every pull is the full snapshot; the control plane offers ETag but the nameserver does not use it yet, so pull cost grows with the total size of all zones.
  • A change is answered from the next pull: the 15 s interval plus up to 5 s of build reuse.
  • No global signing-rate guard: a distributed random-name flood on a signed zone costs one ECDSA signature per negative answer, bounded only by per-network RRL.
  • Under black-box fuzzing (three runs of a million mutated packets; the server stayed up) resident memory grew from 31 to 95 MB (2026-11-10/11, raw output not kept); not investigated.
  • The country table costs about 40 MB of heap and under a second at start-up; a precompiled form is proposed, not built.
  • Not measured yet: throughput inside the half-CPU container budget, signed answers under load, and any third-party server beside ours.
Did this page help you?