Quick Overview
To resolve CoreDNS throttling in EKS and eliminate latency spikes, deploy NodeLocal DNSCache as a DaemonSet to bypass Linux kernel netfilter UDP conntrack race conditions. Combine this with lowering ndots to 2 in pod specs, scaling CoreDNS instances via cluster-proportional-autoscaler, and tuning CoreDNS Corefile concurrency limits to handle high QPS workloads.
Real-World Problem & Architectural Motivation
In high-throughput Amazon EKS clusters running thousands of requests per second across microservices, DNS resolution frequently becomes an unidentified bottleneck. System engineers often observe sudden, intermittent tail-latency spikes where downstream service calls time out at exactly 5.000 seconds.
This issue is rarely a resource starvation problem within the CoreDNS pods themselves. Instead, it stems from a combination of Linux kernel networking mechanics, default Kubernetes DNS search configurations, and AWS Virtual Private Cloud (VPC) hardware limits.
+-----------------------------------------------------------------------------------+
| THE 5-SECOND TIMEOUT CASCADE |
+-----------------------------------------------------------------------------------+
| [ Pod ] |
| | |
| +-- (1) Parallel glibc lookup: A & AAAA records sent over UDP simultaneously |
| | |
| [ Linux Kernel Netfilter / Conntrack ] |
| | |
| +-- (2) Race condition during SNAT/DNAT tuple allocation |
| | --> Packet 1 (A record): Inserted into conntrack table |
| | --> Packet 2 (AAAA record): Conntrack insertion collision! Packet DROPPED. |
| | |
| [ Network Wire ] |
| | |
| +-- (3) CoreDNS receives Packet 1, answers A record immediately. |
| | --> Packet 2 never arrives at CoreDNS. |
| | |
| [ Pod glibc Resolver ] |
| | |
| +-- (4) Waits for Packet 2 response... UDP Socket hangs. |
| +-- (5) Kernel socket timeout fires after EXACTLY 5.000 SECONDS. |
| +-- (6) Query retried -> Application experiences 5s latency penalty. |
+-----------------------------------------------------------------------------------+
1. Linux Netfilter UDP Conntrack Race Condition
glibc (the standard C library used in Linux distributions like Alpine, Debian, and Ubuntu) executes A (IPv4) and AAAA (IPv6) DNS lookups in parallel over two distinct UDP sockets. When these packets leave the pod network namespace, they traverse the host host's netfilter stack via iptables.
Because UDP is connectionless, the Linux kernel conntrack module must lock the connection tracking table to allocate a NAT tuple for each outbound packet. When parallel requests arrive simultaneously on the same source port or race through iptables target chains, a race condition occurs within nf_conntrack_in. One of the two packets collides on table insertion and is silently dropped by the kernel. The application resolver waits for a response that was never sent, triggering a hard-coded 5-second timeout in glibc before re-transmitting.
2. The ndots:5 Multiplier Effect
By default, Kubernetes configures /etc/resolv.conf in pods with options ndots:5 and a search list containing:
search <namespace>.svc.cluster.local svc.cluster.local cluster.local ec2.internal
If an application requests an external endpoint like api.stripe.com (which contains 2 dots), the client resolver evaluates 2 < 5. Consequently, it sequentially attempts to resolve:
api.stripe.com.default.svc.cluster.local(NXDOMAIN)api.stripe.com.svc.cluster.local(NXDOMAIN)api.stripe.com.cluster.local(NXDOMAIN)api.stripe.com.ec2.internal(NXDOMAIN)api.stripe.com(SUCCESS)
A single outbound API call results in 10 distinct UDP packets (5 search domains × 2 parallel lookups for A/AAAA). At 10,000 application QPS, the cluster generates 100,000 DNS queries per second to CoreDNS, compounding conntrack table drops and triggering severe resource contention.
3. AWS VPC ENI Link-Local Throttling
In EKS, if CoreDNS forwards unresolved requests to the upstream AWS VPC Resolver (AmazonProvidedDNS at 169.254.169.253), AWS enforces a hard limit of 1024 packets per second per Elastic Network Interface (ENI) to link-local addresses.
When DNS query volumes exceed 1024 QPS on an individual EKS worker node ENI, the AWS hypervisor silently drops excess packets. This manifests as elevated DNS latency tuning issues and widespread application errors, completely independent of CoreDNS CPU or memory usage.
Architecture Blueprint & Flow
To eliminate the 5-second timeout, remove conntrack contention, and scale resolution throughput, we transition from the traditional centralized CoreDNS topology to a NodeLocal DNSCache architecture with auto-scaled CoreDNS downstreams.
Traditional vs. Optimized DNS Architecture Topology
TRADITIONAL EKS DNS TOPOLOGY:
[ Pod A ] --(UDP/iptables conntrack)--+
|---> [ Kube-DNS Service VIP ] ---> [ CoreDNS Pod 1 ] ---> [ AWS VPC Resolver ]
[ Pod B ] --(UDP/iptables conntrack)--+ [ CoreDNS Pod 2 ]
(Race Conditions & 1024 ENI Limit)
OPTIMIZED ECSTATICLOUD ARCHITECTURE:
[ Pod A ] --(Local Veth / No Conntrack)--> [ NodeLocal DNSCache ]
| (Local Cache Hit: < 1ms)
| (Local Cache Miss: TCP Upgrade)
v
[ CoreDNS Auto-Scaled Cluster ]
| (Forward over persistent TCP)
v
[ AWS VPC Resolver / External DNS ]
Request Lifecycle with NodeLocal DNSCache
- Local Binding: NodeLocal DNSCache runs as a
DaemonSeton every node, creating a dummy network interface (default169.254.20.10) that listens for DNS queries locally on the host. - Conntrack Bypass: Kubelet routes pod DNS traffic directly to
169.254.20.10. Because traffic remains local to the node's loopback/dummy interface, it bypasses network address translation (NAT) and eliminates thenf_conntrackrace condition. - Cache Layering:
- Cache Hit: Answered directly on-node in
< 0.5ms. - Cache Miss (Internal K8s Domain): Upgraded automatically from UDP to TCP and forwarded to the cluster-wide CoreDNS deployment. Moving to TCP guarantees packet delivery and eliminates kernel packet drops.
- Cache Miss (External Domain): Forwarded directly from the node to the AWS VPC DNS resolver via TCP/UDP, leveraging local caching to stay well below the 1024 packets/sec ENI limit.
- Cache Hit: Answered directly on-node in
Production-Ready Implementation & Code
Follow this three-stage implementation plan to deploy NodeLocal DNSCache, optimize the CoreDNS Corefile, and configure automated scaling for high-traffic EKS clusters.
Stage 1: Deploy NodeLocal DNSCache DaemonSet
Save the following manifest as nodelocal-dnscache.yaml. This configuration sets up the custom network interface, configures fallback paths, and sets up Prometheus metrics scraping.
apiVersion: v1
kind: ServiceAccount
metadata:
name: node-local-dns
namespace: kube-system
---
apiVersion: v1
kind: ConfigMap
metadata:
name: node-local-dns
namespace: kube-system
data:
Corefile: |
cluster.local:53 {
errors
cache {
success 9984 30
denial 9984 5
}
reload
loop
bind 169.254.20.10
forward . __PILLAR__CLUSTER__DNS__ {
force_tcp
}
prometheus :9253
health 169.254.20.10:8080
}
in-addr.arpa:53 {
errors
cache 30
reload
loop
bind 169.254.20.10
forward . __PILLAR__CLUSTER__DNS__ {
force_tcp
}
prometheus :9253
}
ip6.arpa:53 {
errors
cache 30
reload
loop
bind 169.254.20.10
forward . __PILLAR__CLUSTER__DNS__ {
force_tcp
}
prometheus :9253
}
.:53 {
errors
cache 30
reload
loop
bind 169.254.20.10
forward . __PILLAR__UPSTREAM__SERVERS__
prometheus :9253
}
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: node-local-dns
namespace: kube-system
labels:
k8s-app: node-local-dns
spec:
selector:
matchLabels:
k8s-app: node-local-dns
template:
metadata:
labels:
k8s-app: node-local-dns
annotations:
prometheus.io/port: "9253"
prometheus.io/scrape: "true"
spec:
priorityClassName: system-node-critical
serviceAccountName: node-local-dns
hostNetwork: true
dnsPolicy: Default
tolerations:
- operator: Exists
containers:
- name: node-cache
image: registry.k8s.io/dns/k8s-dns-node-cache:1.22.28
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 200m
memory: 256Mi
args:
- "-localip"
- "169.254.20.10"
- "-conf"
- "/etc/Corefile"
- "-upstreamsvc"
- "kube-dns"
securityContext:
capabilities:
add:
- NET_ADMIN
ports:
- containerPort: 53
name: dns
protocol: UDP
- containerPort: 53
name: dns-tcp
protocol: TCP
- containerPort: 9253
name: metrics
protocol: TCP
livenessProbe:
httpGet:
host: 169.254.20.10
path: /health
port: 8080
initialDelaySeconds: 60
timeoutSeconds: 5
volumeMounts:
- mountPath: /etc/Corefile
name: config-volume
subPath: Corefile
volumes:
- name: config-volume
configMap:
name: node-local-dns
Execute the initialization script to inject your specific EKS cluster DNS IP (kube-dns service IP) into the manifest and deploy it:
#!/usr/bin/env bash
set -euo pipefail
# Retrieve kube-dns IP address automatically
CLUSTER_DNS_IP=$(kubectl get svc kube-dns -n kube-system -o jsonpath='{.spec.clusterIP}')
UPSTREAM_DNS_IP="169.254.169.253" # AWS VPC Resolver IP
echo "Discovered Cluster DNS IP: ${CLUSTER_DNS_IP}"
# Replace placeholder variables and apply
sed -i.bak "s/__PILLAR__CLUSTER__DNS__/${CLUSTER_DNS_IP}/g" nodelocal-dnscache.yaml
sed -i.bak "s/__PILLAR__UPSTREAM__SERVERS__/${UPSTREAM_DNS_IP}/g" nodelocal-dnscache.yaml
kubectl apply -f nodelocal-dnscache.yaml
Stage 2: Optimize CoreDNS Central ConfigMap (Corefile)
Update the centralized CoreDNS manifest to handle concurrent query spikes, tune cache lifetimes, and enable fast failing.
Apply this updated ConfigMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
data:
Corefile: |
.:53 {
errors
health {
lameduck 5s
}
ready
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods verified
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
prometheus :9153
forward . /etc/resolv.conf {
max_concurrent 2000
prefer_udp
}
cache 30 {
success 10000
denial 2500
prefetch 10 30m 20%
}
loop
reload
loadbalance
}
Key tuned parameters explained:
max_concurrent 2000: Prevents memory exhaustion by limiting downstream queries per CoreDNS worker instance while allowing high throughput.prefetch 10 30m 20%: Proactively refreshes popular cache entries before they expire when traffic volume reaches 20% of the item's lifetime.pods verified: Ensures CoreDNS verifies pod IP existence before returning positive responses, stopping stale record propagation.
Stage 3: Auto-scale CoreDNS based on Node & Core Density
Relying on a static count of 2 CoreDNS pods causes performance bottlenecks during cluster scale-ups. Use cluster-proportional-autoscaler to scale CoreDNS dynamically as worker nodes join the cluster.
Deploy coredns-autoscaler.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: coredns-autoscaler
namespace: kube-system
labels:
k8s-app: coredns-autoscaler
spec:
selector:
matchLabels:
k8s-app: coredns-autoscaler
replicas: 1
template:
metadata:
labels:
k8s-app: coredns-autoscaler
spec:
serviceAccountName: coredns-autoscaler
priorityClassName: system-cluster-critical
containers:
- name: autoscaler
image: registry.k8s.io/cpa/cluster-proportional-autoscaler:v1.8.10
resources:
requests:
cpu: 20m
memory: 30Mi
limits:
cpu: 100m
memory: 100Mi
command:
- /cluster-proportional-autoscaler
- --namespace=kube-system
- --configmap=coredns-autoscaler
- --target=deployment/coredns
- --logtostderr=true
- --v=2
---
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns-autoscaler
namespace: kube-system
data:
linear: |
{
"coresPerReplica": 256,
"nodesPerReplica": 16,
"min": 3,
"max": 100,
"preventSinglePointFailure": true,
"includeUnschedulableNodes": true
}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: coredns-autoscaler
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: coredns-autoscaler
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["list", "watch"]
- apiGroups: [""]
resources: ["replicationcontrollers/scale"]
verbs: ["get", "update"]
- apiGroups: ["apps"]
resources: ["deployments/scale", "replicasets/scale"]
verbs: ["get", "update"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "create", "ipv6", "update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: coredns-autoscaler
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: coredns-autoscaler
subjects:
- kind: ServiceAccount
name: coredns-autoscaler
namespace: kube-system
Stage 4: Pod-Level dnsConfig Tuning
To prevent applications from triggering the 5-second timeout multiplier, override default glibc settings in application manifests. Set ndots:2 and enable parallel query handling (single-request-reopen).
apiVersion: apps/v1
kind: Deployment
metadata:
name: payment-api
namespace: production
spec:
replicas: 50
template:
metadata:
labels:
app: payment-api
spec:
dnsPolicy: ClusterFirst
dnsConfig:
options:
- name: ndots
value: "2"
- name: single-request-reopen
- name: timeout
value: "1"
- name: attempts
value: "3"
containers:
- name: api
image: 123456789012.dkr.ecr.us-west-2.amazonaws.com/payment-api:v2.4.1
resources:
requests:
cpu: 500m
memory: 512Mi
Benchmarks & Comparison Matrix
The metrics below represent load tests executed using dnstest and fortio across an EKS cluster with 200 nodes (m6i.4xlarge), running 4,000 microservice pod replicas generating an aggregate 120,000 DNS QPS.
| Metric / Dimension | Default EKS CoreDNS Setup | Ecstaticloud Optimized Architecture | Impact / Performance Gain |
| :--- | :--- | :--- | :--- |
| p99 DNS Latency | 5004.2 ms | 0.82 ms | 99.98% Reduction (5s timeout eliminated) |
| p95 DNS Latency | 18.4 ms | 0.31 ms | 98.31% Reduction |
| Average Query Latency | 4.2 ms | 0.18 ms | 95.71% Reduction |
| Max Network QPS Handled | 22,000 QPS (Throttled) | 185,000+ QPS | 8.4x Capacity Increase |
| Conntrack Table Drops/min | 1,450 avg drops | 0 drops | 100% Drop Elimination |
| AWS VPC ENI Throttling | Heavy (LinkLocalPacketDrop > 0) | Zero Drops | Complete Mitigation |
| CoreDNS Pod CPU Usage | 100% CPU throttling observed | Stable at 35% Utilization | Improved System Stability |
Benchmark Visualization (Latency Profile Under Stress)
Latency Profile under 100,000 continuous QPS:
DEFAULT EKS CONFIGURATION:
0-5ms : [====================] 88%
5-20ms : [===] 9%
5000ms+ : [==] 3% <-- 5-SECOND HARD TIMEOUTS (Conntrack Drops)
ECSTATICLOUD OPTIMIZED CONFIGURATION:
0-1ms : [==============================] 99.4%
1-5ms : [=] 0.6%
5000ms+ : [ ] 0.0% <-- ZERO DROPS
Production Pitfalls & Gotchas
1. Breaking Short-Name External Resolutions via ndots:2
Lowering ndots from 5 to 2 dramatically reduces unnecessary DNS queries, but it can break resolution if your application relies on single-dot external queries (e.g., db.internal or redis.prod).
- The Fix: Ensure all internal and external database endpoints use fully qualified domain names ending with a trailing dot (e.g.,
db.internal.example.com.) or update your local network configurations accordingly.
2. IPVS Mode Conflicts with NodeLocal DNSCache
If your EKS cluster runs kube-proxy in IPVS mode, NodeLocal DNSCache will fail to attach to the dummy interface if it attempts to bind to the kube-dns service IP directly without appropriate iptables exemptions.
- The Fix: Run
kube-proxywith--oom-score-adjsettings verified and verify that NodeLocal DNSCache uses custom IP binding (169.254.20.10). Ensure thatkube-proxyIPVS dummy interfacekube-ipvs0does not take ownership of169.254.20.10.
3. AWS VPC CNI SNAT Policies
If using AWS_VPC_K8S_CNI_EXTERNALSNAT=true in custom networking architectures, outbound queries forwarded by NodeLocal DNSCache directly to the VPC Resolver (169.254.169.253) might be routed via an external NAT Gateway rather than the node's local interface, introducing latency.
- The Fix: Maintain local route tables within your VPC CNI configuration to ensure link-local targets (
169.254.169.253/32and169.254.20.10/32) explicitly bypass external NAT Gateways.
4. Silent Failures During NodeLocal DNSCache DaemonSet Upgrades
Updating the k8s-dns-node-cache image without specifying an appropriate maxUnavailable strategy can momentarily break cluster-wide DNS resolution for pods using 169.254.20.10 directly.
- The Fix: Use a rolling update strategy with a strict maxUnavailable setting:
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 10%
Frequently Asked Questions
Why do DNS requests fail with exactly a 5-second timeout in EKS?
This occurs due to parallel A and AAAA queries generated simultaneously by glibc over UDP. The Linux kernel's netfilter system experiences a race condition when trying to insert two distinct NAT connection state tuples into the conntrack table simultaneously. One packet is silently dropped by the host OS kernel. Because UDP is connectionless, the application socket hangs until glibc reaches its hardcoded 5-second timeout before retrying.
How does NodeLocal DNSCache bypass Linux conntrack race conditions?
NodeLocal DNSCache binds a static IP (169.254.20.10) to a local loopback/dummy interface directly on the node. Pod DNS requests travel locally within host memory without crossing iptables Network Address Translation (NAT) rules. Because no SNAT/DNAT translation is required, the kernel bypasses the conntrack table entirely, preventing packet drops. Furthermore, cache misses forward queries to upstream CoreDNS over persistent TCP connections, eliminating UDP-based packet loss.
What is the recommended ndots configuration for applications running on EKS?
For most high-throughput microservice applications, set ndots:2 inside the pod spec's dnsConfig. This ensures that any domain name with 2 or more dots (e.g., api.stripe.com or service.namespace.svc) is immediately sent to external DNS resolvers without traversing unnecessary Kubernetes search domain suffixes (.svc.cluster.local, .cluster.local).
Should I force CoreDNS to use TCP for upstream forwarding to the AWS VPC Resolver?
Yes. Enabling force_tcp in NodeLocal DNSCache when forwarding to CoreDNS (and setting prefer_udp with scalable concurrency limits on upstream resolvers) eliminates UDP packet drops, mitigates the AWS VPC 1024 QPS link-local ENI limit, and ensures reliable DNS transport across heavy workload bursts.