oblivion
BlogsPortfolio / ResumeEmail
cloud Dispatch7 min read

CoreDNS Cascading Failure: Resolving 12M Request/Sec Conntrack Saturation in EKS

A
Ajay Kumar Chaturvedi & Elena Rostova
Lead Systems Contributors

Root-cause analysis of a 42-minute cross-region outage caused by ndots:5 query multiplication, overflowing Linux kernel socket tables on EC2 nodes.

duration42 minutes
peak Load12.4M QPS
scopeEKS us-east-1
resolutionNodeLocal DNS

At 14:22 UTC, synthetic health checks triggered critical latency alerts across checkout services in our primary EKS us-east-1 cluster. External HTTPS calls to payment providers failed with connection timeouts. Internal cluster DNS resolution latency jumped from an average 1.2ms to over 4,800ms, and packet drops peaked at 68%. This incident report details the empirical findings, kernel-level socket exhaustion mechanics, and architectural remediations applied across 2,400 worker instances.

1. Incident Timeline & Telemetry Breakdown

During peak promotional traffic, an upstream batch processing event initiated a rapid horizontal pod autoscaler (HPA) surge across 14 microservice tiers. Within four minutes, total container instances scaled from 50 to 800 pods simultaneously across 40 EC2 worker nodes.

Detection and Latency Alerts

Automated synthetic probing detected the initial breach when p99 latency on the checkout orchestration API climbed from 18ms to 3,400ms. Distributed tracing spans in Jaeger highlighted external gateway resolutions hanging indefinitely on socket connection initialization:

  • 14:22 UTC: Latency alarm fires on checkout-orchestrator. P99 response times exceed 3.4 seconds.
  • 14:25 UTC: CoreDNS pod CPU saturation reaches 100% across all 12 replicas. Ingress request rate spikes past 12.4M QPS.
  • 14:28 UTC: Node-level kernel logs emit cascading nf_conntrack: table full, dropping packet warnings.
  • 14:34 UTC: Incident bridge convened. Triage engineers observe 68% packet loss between worker pods and cluster DNS IPs.
  • 14:48 UTC: Hotfix deployment of NodeLocal DNSCache DaemonSet initiated across worker nodes.
  • 15:04 UTC: Resolution latency normalizes to 0.4ms. Conntrack utilization stabilizes below 14% of capacity.

Kernel Socket Table Saturation Dynamics

The Linux netfilter subsystem uses connection tracking (nf_conntrack) to maintain state tables for NAT and UDP packet flows. On default AWS EKS optimized AMIs based on c6i.4xlarge instances, net.netfilter.nf_conntrack_max was configured to 262,144 entries. Because UDP is connectionless, each outbound DNS query allocates a new conntrack tuple (IP_CT_NEW) that remains locked in kernel memory until timeout expiration, typically 30 seconds for unreplied UDP flows.

When 800 application pods concurrently generated bursts of external DNS queries, the total active conntrack table entries crossed 262,144 in less than 90 seconds. The kernel immediately began executing drop semantics on all subsequent network packets requiring state tracking.

2. Root Cause Analysis: Glibc ndots:5 Query Multiplication

Standard Linux container runtimes default to ndots:5 in /etc/resolv.conf. When application workloads initiate connections to external endpoints such as api.stripe.com (which contains only two dot separators), the glibc resolver treats the domain as a relative name and appends every cluster search domain in sequence before querying the external root.

Resolv.conf Search Domain Cascades

Each microservice container inherited the following default resolver configuration:

CODEimmutable
nameserver 10.100.0.10
search default.svc.cluster.local svc.cluster.local cluster.local ec2.internal
options ndots:5

Because api.stripe.com contains two dots, which is strictly less than the ndots:5 threshold, glibc executes five sequential DNS queries for every single outbound network call:

Sequential 5-Step Glibc DNS Lookup Traversal Path: 1. api.stripe.com.default.svc.cluster.local. -> NXDOMAIN 2. api.stripe.com.svc.cluster.local. -> NXDOMAIN 3. api.stripe.com.cluster.local. -> NXDOMAIN 4. api.stripe.com.ec2.internal. -> NXDOMAIN 5. api.stripe.com. -> 200 SUCCESS (5x queries)

During normal operations, local CoreDNS caches absorb these requests. However, when 800 pods scale up and connect to multiple third-party payment, fraud, and webhook endpoints, the 5x query multiplication transforms what should have been 2.48M queries into a 12.4M QPS flood.

Figure 1: DNS Packet Traversal & InterceptionMermaid.js
sequenceDiagram
    autonumber
    actor Pod as Worker Pod
    participant NodeLocal as NodeLocal DNS (169.254.20.10)
    participant CoreDNS as CoreDNS ClusterIP
    participant Upstream as AWS Route53

    Note over Pod,Upstream: Unmitigated ndots:5 Loop (Outage)
    Pod->>CoreDNS: 1. A api.stripe.com.default.svc.cluster.local
    CoreDNS-->>Pod: NXDOMAIN (Search Path 1)
    Pod->>CoreDNS: 2. A api.stripe.com.svc.cluster.local
    CoreDNS-->>Pod: NXDOMAIN (Search Path 2)
    Pod->>CoreDNS: 3. A api.stripe.com
    CoreDNS->>Upstream: Forward Query
    Upstream-->>CoreDNS: 200 OK
    CoreDNS-->>Pod: 200 OK

    Note over Pod,NodeLocal: Mitigated with NodeLocal DNSCache
    Pod->>NodeLocal: A api.stripe.com (Local Loopback)
    NodeLocal-->>Pod: 200 Cached (0.2ms latency)
Worker PodNodeLocal (169.254.20.10)CoreDNS ClusterAWS Route53Unmitigated ndots:5 Loop (Outage) — 5x Sequential NXDOMAIN Queries1. A api.stripe.com.default.svc.cluster.localNXDOMAIN (Search Path 1)2. A api.stripe.com.svc.cluster.localNXDOMAIN (Search Path 2)Mitigated with NodeLocal DNSCache (Loopback Interception)A api.stripe.com (Local Loopback)200 Cached (0.2ms latency)

App->>Kernel: UDP 53 query: api.stripe.com.default.svc.cluster.local Kernel->>Kernel: Allocate conntrack tuple: IP_CT_NEW Kernel->>CoreDNS: Forward UDP packet CoreDNS-->>Kernel: NXDOMAIN Kernel-->>App: Forward NXDOMAIN

Note over Kernel: Repeat x4 for remaining ndots search domains

App->>Kernel: UDP 53 query: api.stripe.com (5th query) Kernel-->>Kernel: Saturated: 262,144/262,144 entries full! Kernel--xApp: DROP: nf_conntrack: table full, dropping packet `

Figure 2: Kernel Conntrack Table Exhaustion Topology
Figure 2: Kernel Conntrack Table Exhaustion Topology

Microsecond eBPF Tracing of Packet Loss

To confirm packet drop behavior in real-time, we attached an eBPF tracepoint probe to kfree_skb in the Linux kernel:

CODEimmutable
SEC("tracepoint/skb/kfree_skb")
int trace_kfree_skb(struct trace_event_raw_kfree_skb *ctx) {
    u32 protocol = BPF_CORE_READ(ctx, skbaddr, protocol);
    if (protocol == __constant_htons(ETH_P_IP)) {
        bpf_printk("Conntrack saturation drop: reason=%d\n", ctx->reason);
    }
    return 0;
}

The eBPF trace revealed that 94% of dropped packets were attributed directly to SKB_DROP_REASON_NETFILTER_DROP, validating that neither NIC hardware ring buffers nor VPC elastic network interfaces were the choke point. The bottleneck existed entirely within kernel netfilter memory structures.

3. Architectural Remediation & Hardening Plan

To permanently eliminate recursive query cascades and protect the kernel conntrack table from future scaling spikes, we designed and deployed a three-tier reliability architecture across all clusters.

NodeLocal DNSCache DaemonSet Architecture

We deployed NodeLocal DNSCache as a privileged DaemonSet across all worker nodes. NodeLocal DNSCache binds to link-local IP 169.254.20.10 and intercepts DNS queries directly on the node's loopback interface using a dummy network adapter:

YAMLimmutable
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-local-dns
  namespace: kube-system
spec:
  selector:
    matchLabels:
      k8s-app: node-local-dns
  template:
    metadata:
      labels:
        k8s-app: node-local-dns
    spec:
      hostNetwork: true
      priorityClassName: system-node-critical
      containers:
        - name: node-cache
          image: registry.k8s.io/dns/k8s-dns-node-cache:1.22.28
          args:
            - -localip
            - 169.254.20.10
            - -conf
            - /etc/Corefile
            - -upstreamsvc
            - kube-dns

By resolving external and internal requests on loopback, outbound packets avoid iptables destination NAT (DNAT). Because no NAT occurs on loopback, the kernel allocates zero conntrack tuples for local DNS queries. In benchmark testing, average response latency dropped from 1.2ms to 0.18ms.

Kyverno Admission Controller Policy for ndots

To stop glibc from generating four redundant NXDOMAIN lookups for fully qualified external hosts, we instituted an admission control policy using Kyverno. The policy automatically injects dnsConfig overrides into any deployment manifest entering production namespaces:

YAMLimmutable
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: mutate-dns-ndots
spec:
  rules:
    - name: set-ndots-2
      match:
        resources:
          kinds:
            - Pod
      mutate:
        patchStrategicMerge:
          spec:
            dnsConfig:
              options:
                - name: ndots
                  value: "2"

Configuring ndots: 2 instructs glibc that any domain containing two or more dots (such as api.stripe.com or storage.googleapis.com) must be treated as an absolute query immediately, bypassing the internal cluster search path entirely. This single policy eliminated 80% of DNS query volume from client pods.

EC2 Kernel Sysctl Parameter Optimization

In parallel with client and cache optimizations, we hardened the host Linux operating system via EC2 user-data launch templates:

BASHimmutable
# Raise conntrack table limit to 1M entries

# Reduce generic UDP connection timeout from 30s to 10s sysctl -w net.netfilter.nf_conntrack_udp_timeout=10 sysctl -w net.netfilter.nf_conntrack_udp_timeout_stream=30

# Persist to sysctl.d cat <<EOF > /etc/sysctl.d/99-conntrack-hardening.conf net.netfilter.nf_conntrack_max = 1048576 net.netfilter.nf_conntrack_udp_timeout = 10 net.netfilter.nf_conntrack_udp_timeout_stream = 30 EOF `

Increasing nf_conntrack_max to 1,048,576 allocates approximately 128MB of additional kernel memory per node, a negligible overhead on 64GB instances that provides a 4x buffer against unmitigated traffic spikes.

4. Operational Takeaways & Verification Metrics

Following the deployment of NodeLocal DNSCache and Kyverno ndots: 2 mutation:

  • Total cluster-wide DNS queries dropped from a peak of 12.4M QPS to 1.8M QPS under identical workload pressure.
  • Worker node conntrack table occupancy remained steady below 14,000 active entries (5.3% of capacity).
  • Median DNS query latency settled at 0.22ms, with 99.9th percentile resolution capped at 1.4ms.
  • Zero nf_conntrack: table full drops have occurred during any subsequent promotional scaling event.

For quantum computing research on noise suppression, see Fault-Tolerant Grover Oracles.

Referenced In & Suggested Next Reads

Bidirectionally cross-referenced across technical domains.