176 lines
12 KiB
Markdown
176 lines
12 KiB
Markdown
# Performance: EasyDNS vs BIND 9 (estimates)
|
||
|
||
> **These are estimates, not benchmark results.** Only one EasyDNS figure below was
|
||
> measured; all BIND figures come from ISC's published Perflab results, and the comparison
|
||
> is derived from the architecture of both servers. Measure on your own hardware before
|
||
> sizing production (see "How to measure").
|
||
|
||
## Reference points
|
||
|
||
| Source | Figure |
|
||
|---|---|
|
||
| EasyDNS 0.1.0, **measured** (docs/testing.md) | 54 600 QPS, authoritative A answers from a small zone over UDP, 2 vCPU container, load generator on the same 2 vCPUs; p50/p95/p99 = 0.87/1.43/1.89 ms; RSS 13 MB |
|
||
| ISC Perflab, BIND 9.20, 96-core servers ([ISC: BIND Authoritative Performance on Multi-core Systems](https://victor.isc.org/blogs/2026-09-03-new-perflab/)) | about 1 million QPS at about 30 cores (read from a chart); scaling flattens above ~16 cores. |
|
||
| ISC Perflab, BIND 9.20 vs 9.18 ([ISC, Dec 2025](https://www.isc.org/blogs/bind-auth-performance-december-2025/)) | 9.20 is 4–7 % faster than 9.18 for most authoritative profiles |
|
||
|
||
Averaged over 30 cores that is roughly 33 000 QPS per core for BIND 9.20. Per-core
|
||
throughput at low core counts is typically higher than this average.
|
||
|
||
## Estimated throughput – authoritative, small zone, UDP
|
||
|
||
| Cores | BIND 9.20 (estimate) | EasyDNS 0.1.0 (estimate) | EasyDNS / BIND |
|
||
|---|---|---|---|
|
||
| 1 | 40–70 k QPS | 30–45 k QPS | ~65–75 % |
|
||
| 2 | 80–130 k | 60–90 k (55 k measured with the load generator sharing the CPUs) | ~70 % |
|
||
| 4 | 150–250 k | 100–150 k | ~60 % |
|
||
| 8 | 300–450 k | 130–200 k | ~40–45 % |
|
||
| 16+ | 500 k – 1 M | 150–250 k (plateau) | ~25–30 % |
|
||
|
||
Why EasyDNS keeps up on small machines but falls behind on large ones:
|
||
* a Tokio task per packet and allocation-heavy decode/encode (hickory `Message`);
|
||
* answers are built per query (no pre-rendered wire answers);
|
||
* no `recvmmsg`/`sendmmsg` batching (one system call per packet).
|
||
|
||
The table above describes 0.1.0. See "Changes in 0.1.1" for what has been removed
|
||
from this list and what was measured.
|
||
|
||
## Changes in 0.1.1
|
||
|
||
| Change | Effect |
|
||
|---|---|
|
||
| **UDP socket group with SO_REUSEPORT** (`server.udp_sockets`, default one per CPU, max 16) | the kernel spreads queries over N sockets, each with its own receive loop: receiving is no longer serialised on one task. This was the main plateau above ~4 cores. |
|
||
| **Sharded cache** (16 locks instead of one; records copied after the lock is released) | cache hits from many cores no longer queue on one lock; boxed slices drop spare `Vec` capacity per entry |
|
||
| **Rate limiter**: client buckets in 16 shards, server-wide limit as a lock-free atomic (GCRA) | rate limiting (on by default) no longer takes two global locks per UDP query |
|
||
| `rate_limit.global_qps` default changed from 100 000 to **0 = no server-wide cap** | the old default capped every server at 100 k QPS regardless of hardware; per-client limits still apply |
|
||
| **Query coalescing** (forwarder and recursion) | N identical concurrent cache misses cost one upstream resolution; the others wait for its answer |
|
||
| No `String` allocation per query for metrics | small per-query saving |
|
||
|
||
Measured on the same 2-vCPU container as before (load generator sharing the CPUs,
|
||
`ebench -c 50`, 3 × 8 s runs):
|
||
|
||
| Build | QPS | p99 | RSS |
|
||
|---|---|---|---|
|
||
| 0.1.0 | 55 800 – 56 800 | 1.76 – 1.86 ms | 12.0 MB |
|
||
| 0.1.1, `udp_sockets: 1` | 56 000 – 57 200 | 1.70 – 1.82 ms | 12.7 MB |
|
||
| 0.1.1, `udp_sockets: 0` (2 sockets) | 59 400 – 60 100 | 1.74 – 1.76 ms | 12.3 MB |
|
||
|
||
That is about +6 % on 2 vCPUs. The changes target many-core machines, which this
|
||
container cannot show; the multi-core gain is **expected, not measured**. Revised
|
||
estimates for authoritative UDP (to be confirmed with dnsperf on real hardware):
|
||
|
||
| Cores | EasyDNS 0.1.0 (estimate) | 0.1.1 (estimate) | vs BIND 9.20 |
|
||
|---|---|---|---|
|
||
| 1–2 | 30–90 k | 30–95 k | ~70 % |
|
||
| 4 | 100–150 k | 120–180 k | ~70 % |
|
||
| 8 | 130–200 k | 220–320 k | ~65–70 % |
|
||
| 16+ | 150–250 k (plateau) | 350–550 k | ~50–60 % |
|
||
|
||
Memory: the socket group adds about 4 KiB of user-space buffer per socket; the kernel
|
||
receive/send buffers (1 MiB requested, capped by `net.core.rmem_max`/`wmem_max`) are only
|
||
filled while packets are queued. The cache and rate limiter keep the same entry limits as
|
||
before (cache `max_entries` is split across the shards; the limiter tracks at most 100 000
|
||
client prefixes in total). Coalescing holds one small waiter per waiting query, at most
|
||
1 024 per name.
|
||
|
||
At typical real-world loads (a few thousand QPS per server) both are far below their
|
||
limits; latency at low load is similar (sub-millisecond on a LAN).
|
||
|
||
## Round 2 (0.1.1): encoded-answer cache, batched UDP, prefetch
|
||
|
||
| Change | What it does |
|
||
|---|---|
|
||
| **Encoded-answer cache** (`cache.answer_entries`, default 20 000) | identical queries are answered by copying stored response bytes and patching ID, question case and (for resolved data) TTLs – no parsing, policy, lookup or encoding. Invalidated at once by any zone change, reload or cache flush; client profile (view, ACL, block-list exemption, forward rules, transport) is part of the key. See [configuration.md](configuration.md#encoded-answer-cache-cacheanswer_entries). |
|
||
| **UDP fast path** | cache hits are answered inside the receive loop – no task spawned per packet |
|
||
| **Batched UDP on Linux** (`recvmmsg`/`sendmmsg`, 32 packets per call) | fewer system calls when packets queue up under heavy load |
|
||
| **Resolver prefetch** (`cache.prefetch`, default on) | popular entries (≥ 2 hits, TTL ≥ 20 s) are refreshed in the background in the last 10 % of their TTL, so clients do not wait for re-resolution of popular names; for recursion and forwarding |
|
||
| Zone path normalisation | `file: ../x.zone` works before the data directory exists |
|
||
|
||
### Measured (2-vCPU container, release build, load generator on the same CPUs)
|
||
|
||
The load generator takes about half of the two CPUs, so QPS understates the server's
|
||
gain. The meaningful number is the **server CPU time per answered query** (from
|
||
`/proc/<pid>/stat` over 10 s of `ebench -c 50`):
|
||
|
||
| Workload | Answer cache off | Answer cache on | Change |
|
||
|---|---|---|---|
|
||
| One name repeated (best case) | 14.4–14.8 µs/query ≈ 68 k QPS per core | 6.3–6.7 µs/query ≈ **150 k QPS per core** | **2.2×** |
|
||
| Realistic mix: 10 000 names, 80 % A / 10 % MX / 10 % random NXDOMAIN | 14.4–16.0 µs ≈ 65 k QPS per core | 8.7–9.3 µs ≈ **110 k QPS per core** | **1.65×** |
|
||
| Forwarder answering from its cache (resolver/forwarder hot path) | 14.5–14.9 µs ≈ 68 k QPS per core | 6.4–6.8 µs ≈ **150 k QPS per core** | **2.2×** |
|
||
| QPS seen by the generator (single name) | ~57 k | ~70 k | +22 % |
|
||
| p99 latency (single name) | 1.8–2.0 ms | 1.4–1.5 ms | −25 % |
|
||
| RSS | 12.9 MB | 11.4 MB | – |
|
||
|
||
Batched `recvmmsg`/`sendmmsg` showed **no measurable gain in this setup**: the generator
|
||
waits for each answer, so batches hold 1–2 packets (confirmed with `strace -c`: one
|
||
`recvmmsg` and one `sendmmsg` per ~1.3 queries). It pays off only when packets queue in
|
||
the socket under real load; it does not cost anything measurable at low batch sizes.
|
||
|
||
### Updated estimate vs BIND 9.20 (authoritative UDP) – not measured on multi-core yet
|
||
|
||
Per core, EasyDNS now spends about 6–9 µs per answered query on cacheable traffic.
|
||
BIND's published figure of roughly 1 M QPS on ~30 cores is ~33 k QPS per core on that
|
||
hardware (more per core at low core counts). The two numbers come from different
|
||
machines and methods, so they are **not directly comparable**; the realistic reading:
|
||
|
||
| Traffic | Before round 2 | Now (estimate) |
|
||
|---|---|---|
|
||
| Repeated queries (typical authoritative traffic, popular names) | ~70 % of BIND per core | **about BIND's level, possibly above** on few cores |
|
||
| Unique names / random-subdomain floods (cache misses) | ~65–70 % | unchanged: ~65–70 % (full parse + lookup + encode) |
|
||
| Scaling to 8–16 cores | estimated 65–70 % (SO_REUSEPORT, round 1) | similar or better; shared structures are sharded, but contention was not measured |
|
||
|
||
To replace these estimates with facts run `scripts/bench-vs-bind.sh` on a machine with
|
||
8+ cores: it starts BIND and EasyDNS with the same 10 000-record zone on the same pinned
|
||
cores and drives both with `dnsperf` (80 % existing names, 10 % MX, 10 % random
|
||
NXDOMAIN), reporting QPS, latency, loss and RSS for BIND, EasyDNS and EasyDNS with the
|
||
answer cache off.
|
||
|
||
## Other workloads (estimates)
|
||
|
||
| Workload | Comparison | Reason |
|
||
|---|---|---|
|
||
| Recursive, **cache hit** | 0.1.0: ~50–70 % of BIND on 1–4 cores, falling behind on more cores. 0.1.1: sharded cache, expected to scale with cores | 0.1 had a single-lock cache |
|
||
| Recursive, **cache miss** | latency similar (dominated by network RTT); EasyDNS sends more upstream queries (0.1.0: ~10–30 %; coalescing now removes duplicates for identical concurrent questions) | no prefetch, no aggressive NSEC use (RFC 8198), simpler server selection; coalescing covers whole client questions, not the resolver's internal NS-address lookups |
|
||
| DNSSEC validation | similar per-signature cost (ring); EasyDNS caches zone key states 300 s | key cache with fixed TTL |
|
||
| Zone transfers (AXFR/IXFR) | comparable for small and medium zones | 16 KiB messages, journal-based IXFR on both sides |
|
||
| Large zones (≥ 1 M records): load time | EasyDNS ~2–4× slower | text parser + per-record allocation |
|
||
| Large zones: memory | EasyDNS ~2–3× BIND (≈ 300–500 B/record vs ≈ 150–250 B) | `Record` objects with owned names in hash maps (BIND 9.20: qp-trie) |
|
||
| Idle memory | EasyDNS ~10–20 MB, BIND ~30–80 MB | small runtime, no preallocated pools |
|
||
| DoT | comparable per connection | rustls; TCP_NODELAY fixed (0.1.1: new connection 44 ms → 0.5 ms on loopback) |
|
||
| DoH | comparable (0.1.1) | HTTP/2 multiplexing like BIND; 0.1.0 had HTTP/1.1 only |
|
||
| Encrypted forwarding (DoT/DoH upstreams) | 0.1.1: persistent connections – 0.06 ms (DoT) / 0.13 ms (DoH h2) per query on loopback vs ~0.5 ms with a handshake per query | see [secure-dns.md](secure-dns.md) |
|
||
| Reload of one changed zone | faster in EasyDNS | only changed zones are re-published (atomic pointer swap); BIND `rndc reload` re-reads all zones |
|
||
|
||
## Planned improvements (by expected impact)
|
||
|
||
Done: SO_REUSEPORT socket group, sharded cache and rate limiter, query coalescing
|
||
(round 1); encoded-answer cache with UDP fast path, batched UDP on Linux, resolver
|
||
prefetch (round 2).
|
||
|
||
1. Measure on 8–32 cores with `scripts/bench-vs-bind.sh` and update the tables above.
|
||
2. Cache-miss path: allocation-free parsing of plain queries and pre-encoded RRsets in
|
||
zones (helps unique names and random-subdomain floods) – needs a fuzzing campaign.
|
||
3. Compact zone storage (name interning or trie) for large zones.
|
||
4. Resolver: aggressive use of NSEC/NSEC3 (RFC 8198), coalescing of internal lookups.
|
||
|
||
## How to measure
|
||
|
||
Automated comparison on one machine (needs `dnsperf`, `bind9`, a release build):
|
||
```bash
|
||
scripts/bench-vs-bind.sh --cores 8 --duration 30 --clients 200
|
||
# → bench-results/bench-<date>.md: BIND / EasyDNS / EasyDNS without answer cache
|
||
```
|
||
Server CPU time per query (works on small machines, where the generator competes for
|
||
CPUs): compare `utime+stime` from `/proc/<pid>/stat` before and after a run.
|
||
|
||
Manual: run both servers on the **same machine** with the same zone, and the load generator on
|
||
another machine:
|
||
|
||
```bash
|
||
easybench @SERVER -d queries.txt --qps 0 --duration 60s -c 200 --i-own-this-server --json
|
||
dnsperf -s SERVER -d queries.txt -l 60 -c 200 -Q 1000000 # BIND's tool, for cross-checks
|
||
resperf -s SERVER -d queries.txt -m 200000 # resolver capacity ramp
|
||
```
|
||
|
||
Record cores, CPU model, kernel, QPS, p50/p95/p99, lost queries, CPU and RSS
|
||
(`process_resident_memory_bytes`), and the cache hit ratio for resolvers.
|