Ndots:5 configuration creates hidden latency in Kubernetes service discovery
Kubernetes defaults to a high ndots value that forces excessive DNS search-domain lookups, leading to unnecessary network noise and latency. Optimizing this setting requires careful observation of DNS traffic patterns rather than blind application changes.

Infrastructure taxes hidden in DNS resolver behavior
Kubernetes networking often appears to be a black box that just works until it suddenly does not. Among the most misunderstood components of this stack is the DNS resolver configuration found inside every container. While administrators focus heavily on CoreDNS scaling, load balancing, and resource limits, a single, humble line in the container image or Pod specification continues to cause silent performance degradation across clusters of all sizes. That line is options ndots:5.
This configuration directive, standard in Kubernetes, dictates the threshold at which the Linux resolver treats a hostname as an absolute, fully qualified domain name (FQDN). By setting this value to five, Kubernetes forces the system to perform a series of unproductive search-domain lookups for almost every request, including those intended for external public APIs. This behavior creates a tax on the network and the DNS server that accumulates into significant latency over millions of requests.
Understanding the mechanics of DNS expansion
The Linux resolver library, glibc, uses the ndots parameter to optimize how it maps short names to absolute records. When an application attempts to resolve a hostname like api.stripe.com, the resolver checks the number of dots in that string. In a standard Kubernetes environment with ndots:5, the resolver notes that the hostname contains only two dots. Because this is less than five, the resolver concludes the name might be relative.
It proceeds to append each domain listed in the search configuration to the hostname, generating a sequence of queries until it receives a valid record or exhausts the list. For a Pod in a standard cluster, this sequence usually looks like this: api.stripe.com.namespace.svc.cluster.local, then api.stripe.com.svc.cluster.local, then api.stripe.com.cluster.local, and finally, the original name. The first three queries result in NXDOMAIN responses from CoreDNS. While the final query succeeds, the system has effectively wasted three round trips for a name that was already a complete, globally resolvable domain.
The fallacy of the green dashboard
Operational health metrics often mask this performance leak. Because the final query in the search chain eventually succeeds, the application experiences no downtime, errors, or timeouts. The HTTP request completes, the application log remains clean, and the Prometheus dashboard displays healthy green metrics. This deceptive success is the primary reason why DNS inefficiencies persist in mature environments.

When we multiply these redundant DNS queries by the number of active Pods, the frequency of outgoing service requests, and the total volume of external API calls, the aggregate effect on infrastructure is non-trivial. CoreDNS instances often face artificial CPU spikes and memory pressure simply because they are forced to process hundreds of thousands of redundant NXDOMAIN requests every minute. This is not just a wasted CPU cycle; it is a fundamental architecture flaw where the resolver library is fighting against the reality of modern cloud-native service discovery.
Rethinking service discovery patterns
Removing ndots:5 entirely is not a viable strategy because Kubernetes relies on search domains for internal service discovery. When a developer types database into their configuration, they expect the cluster to resolve that short name to the service address within the current namespace. If we disable the search behavior, that short name would fail instantly. The challenge is balancing the need for convenient short-name resolution for internal services against the need for efficient lookups for fully qualified external names.
Architects should view service names as explicit contracts. If an application intends to communicate with a service in another namespace, using the fully qualified domain name (service.namespace.svc.cluster.local) provides clarity and performance. By moving away from relying on search-domain expansion for cross-namespace communication, organizations can reduce ambiguity in their service topology. This transition requires a cultural shift in how developers write configuration files, favoring explicit naming conventions over short, implicit references.
Implementation of Pod-level DNS tuning
Kubernetes allows fine-grained control over this behavior through the spec.dnsConfig field in the Pod manifest. By defining a specific ndots value, teams can tailor the resolver behavior to the specific needs of an application. For instance, a microservice that primarily talks to external APIs might benefit from ndots:1 or ndots:2, while an internal-heavy worker might function best with the default settings.
However, lowering the ndots value is not a universal performance hack. It requires a deep understanding of the current naming patterns used by the code. If an application relies on a chain of search domains that the team has not fully mapped, lowering the threshold may cause sudden, difficult-to-debug failures for existing service connections. Before any change is deployed, engineers must capture DNS traffic, classify the patterns of queries, and test the impact in a staging environment that mirrors production traffic volumes.
Observability as the path to resolution
Debugging DNS performance requires looking beyond the CoreDNS logs. Engineers must execute into the container environment to inspect the /etc/resolv.conf file directly. The combination of DNS policy, search domains, and the ndots setting determines the exact behavior of the resolver. Two Pods with different dnsPolicy settings in the same namespace may produce wildly different query patterns, making it critical to analyze workloads on a case-by-case basis.
Treating NXDOMAIN as a performance metric, rather than a system error, is the most effective way to identify these hidden costs. If a service shows a high volume of negative DNS results, it is a clear indicator that the application is performing unnecessary search-domain lookups. By identifying the most frequent query patterns and adjusting the naming conventions or the resolver settings, teams can recover significant amounts of latency.
DNS is the connective tissue of a distributed system. Treating it as a set-it-and-forget-it plumbing component is a mistake that obscures architectural bottlenecks. The goal should be to minimize the number of queries required to reach a successful resolution, effectively reducing the noise in the network. A performant cluster is one where the resolver is intelligent enough to know when a name is already complete, thereby allowing the system to focus its resources on actual service discovery rather than repeating unnecessary searches.