System Architecture
A deep technical dive into the NexoralDNS internal design, the 7-layer query engine, and its performance optimizations.
System overview
7-layer query processing
Every query flows through the same pipeline regardless of transport (UDP, TCP, TLS).
Redis Cache — 0.5–1ms
Check Redis for previously resolved queries. Sub-millisecond responses for 80%+ of traffic.
Service Status — 0.5ms
Verify DNS service is active. If disabled, return NXDOMAIN immediately.
Block List — 0.5ms
Check global or client-specific blocks. Blocked domains return NXDOMAIN and are logged.
Rewrite Rules — 1ms
Check domain rerouting rules, resolve the target domain, return its IP.
DNS Record Lookup — 2ms
Query MongoDB for custom records like myapp.local.
User Plan Validation — 0.5ms
For custom domains, verify the subscription plan is active. Expired plans return NXDOMAIN.
Upstream DNS — 10–50ms
If no match, forward to 8.8.8.8 / 1.1.1.1 and cache the response.
Component breakdown
Client Layer
Web UI (Next.js), mobile app, CLI client, and any device using the DNS server.
API Server (Fastify, :4000)
REST endpoints, controllers, services, and JWT authentication.
DNS Server (:53 UDP/TCP, :853 TLS)
A Go binary. server/udp.go, tcp.go and dot.go share the dnsio.Handler contract and dispatch into one rules pipeline.
Caching Layer (Redis)
Full responses, records, service status, rewrites, block lists and user plans.
Database (MongoDB)
dns_records, dns_rewrites, dns_blocks, user_plans, dns_query_logs (30-day TTL), domains, service.
Global Forwarder
Upstream DNS resolution with single-flight inflight de-duplication.