Kubernetes ndots: Optimizing DNS Resolution to Eliminate Latency and Traffic Bloat
Kubernetes ndots is a silent performance killer that forces redundant DNS lookups for external traffic by defaulting to excessive search path expansion. By aligning resolver settings with application traffic patterns, engineers can significantly reduce network overhead and improve request latency.

The Hidden Cost of the Kubernetes DNS Default
Most Kubernetes infrastructure assumes a closed ecosystem where internal service discovery is the primary driver of network traffic. However, modern cloud native applications are rarely isolated. They frequently reach out to external APIs, object stores, and managed databases. The default resolver configuration in Kubernetes pods, specifically the ndots setting, is built for the former scenario, creating an accidental tax on the latter. This setting, often set to a value of five, governs how Linux systems handle domain name resolution, and it represents a massive architectural assumption that rarely matches the needs of high scale production environments.
Understanding the Resolver Logic
The ndots parameter defines a simple threshold for the resolver. If a domain name contains fewer dots than the defined ndots value, the resolver treats the name as relative. It then appends the search domains listed in the resolv.conf file to the query one by one until it receives a response or exhausts the list. Only after these unsuccessful attempts does it query the name as an absolute address. When ndots is set to five, any domain with four or fewer dots triggers this exhaustive search sequence. For an application requesting api.example.com, the system performs several wasted lookups across search domains like default.svc.cluster.local and svc.cluster.local before finally reaching the public internet. This process introduces unnecessary latency and generates significant noise in your internal DNS infrastructure.
The Infrastructure Tax of Search Domains
In a cluster with thousands of pods, the cumulative impact of this search behavior is profound. Each unnecessary request adds milliseconds of tail latency to every external API call. Furthermore, these queries are not merely slow, they are noisy. They flood your CoreDNS pods with NXDOMAIN responses for domains that clearly do not exist within the cluster scope. In high volume environments, this can lead to core DNS saturation, which impacts the resolution of legitimate internal services. This is a classic case of an infrastructure default creating a performance bottleneck through misaligned architectural assumptions. The standard configuration prioritizes ease of service discovery for internal developers, but it shifts the cost onto the stability and performance of the overall networking stack.

Strategic Tuning for Real World Traffic
To reclaim this lost performance, engineers must evaluate their application traffic patterns. If your microservices interact more with external cloud endpoints than with local cluster services, the default ndots value is likely your enemy. Lowering this value in your pod specifications can force the resolver to treat domain names as absolute much earlier in the lookup process. For instance, setting ndots to two ensures that any name with two or more dots is treated as an absolute query immediately. This change eliminates the search path traversal for almost all fully qualified domain names. The trade off is a requirement for greater precision when calling internal services. You must ensure that internal communications use fully qualified names or explicit paths rather than relying on the resolver to magically guess the target through broad search lists.
Managing the Migration Safely
Infrastructure changes that affect fundamental networking components should always follow a staged rollout. You should not modify your cluster DNS configuration in a vacuum. Start by measuring the current DNS request volume and latency metrics within your cluster. Then, deploy the modified ndots configuration to a small subset of non critical pods. Monitor the error rates closely, specifically watching for any failed connections to internal services that previously relied on search path expansion. If the application environment is stable, expand the change to larger portions of the cluster. A gradual transition allows you to observe how your specific software stack handles the shift away from broad search domains without introducing production outages.
Architectural Alignment as a Best Practice
Treating ndots as a global constant is a mistake. The optimal resolver configuration is a reflection of your application's unique dependency map. In architectures where most traffic is egress bound, a lower ndots value is a clear performance win. Conversely, in highly dense internal service meshes, the default may be perfectly appropriate. The duty of the site reliability engineer is to audit these configurations regularly. We must move away from the mindset that Kubernetes defaults are optimal and toward a model of explicit, measured configuration. By controlling the resolver settings, we take back responsibility for the reliability and efficiency of our network traffic. Precision in naming your endpoints is the ultimate solution to the dns bloat problem, as it removes the ambiguity that makes these resolvers necessary in the first place.