JVM vs Netty resolver · EKS CoreDNS flow · FQDN vs non-FQDN — all interactive
InetAddress.getAllByName() · Click to see call stackDnsAddressResolverGroup · Click to see call chainndots:5 by default. If your hostname has fewer than 5 dots, CoreDNS tries every search domain before treating it as absolute. Type a name and press Resolve to see both paths.
ndots value drives the FQDN expansion above. Adjust the controls to see how it changes.
redis-master (0 dots) all 4 domains get tried before the bare name — that's 5 DNS lookups.
ClientResources resources = DefaultClientResources.builder() // Use Netty's async DNS resolver instead of InetAddress .dnsResolver(new DnsResolvers.NettyDnsResolver()) // Refresh cluster topology when DNS changes .build(); RedisClusterClient client = RedisClusterClient.create( resources, "redis://my-redis.cache.amazonaws.com");
Or with Spring Data Redis, configure the LettuceClientConfigurationBuilderCustomizer bean.
# In $JAVA_HOME/conf/security/java.security networkaddress.cache.ttl=5 networkaddress.cache.negative.ttl=1 # Or as JVM argument at startup -Dsun.net.inetaddr.ttl=5
This affects the entire JVM — all DNS lookups, not just Lettuce. The Netty resolver approach is scoped to Lettuce only and is generally preferred.
# Option 1: always use FQDN with trailing dot in your connection string redis-master.redis.svc.cluster.local. # Option 2: set ndots:1 in your pod spec (most effective) spec: dnsConfig: options: - name: ndots value: "1" # Option 3: set ndots:2 — still avoids most explosion but keeps # short cluster-internal names working
Setting ndots:1 means any name with 1 or more dots is treated as absolute first — practically eliminates spurious queries for ElastiCache endpoints which already have many dots.
cache 5 in the Corefile for the amazonaws.com zonekubectl get configmap coredns -n kube-system -o yaml