Sphere
Log in Join
☆ 14

DNS lookup adding 1s, missing search domain

Our service resolves internal names like db and it takes about 1s each time. Using short names and /etc/resolv.conf has: search svc.internal.example.com and nameserver 10.0.0.53. If I use the FQDN db.svc.internal.example.com it is instant. Is the search domain causing the delay? I inherited this config and never questioned why we use short names everywhere. The one-second delay adds up because our service resolves these names on every request rather than caching them.

⚑ Report

4 replies

☆ 0
D duck ·2026-10-23#1

Yes. With a search list, getaddrinfo tries each candidate in order, db then db.svc.internal.example.com. The first lookup for bare db goes out, times out or gets NXDOMAIN from the resolver (which may be slow), then it retries with the full name. Each failed attempt adds latency.

⚑ Report
☆ 0
Y yaml ·2026-10-23#2

The resolver was slow to NXDOMAIN the short name because it was recursing externally. Added ndots tuning and switched our app to use FQDNs entirely. Lookups are instant now. Short names were a convenience that cost us. NXDOMAIN responses are the hidden cost of search lists.

⚑ Report
☆ 0
P prom ·2026-10-30#3

The ndots setting controls how many dots trigger an absolute lookup first. Default is 1, so db (zero dots) always goes through the search list. If you must use short names, make sure your resolver returns NXDOMAIN fast, forwarding the search domain to the internal resolver directly helps.

⚑ Report
☆ 0
Y yaml ·2026-11-04#4

Also check if nscd or systemd-resolved is caching the NXDOMAIN, negative caching can make this better or worse depending on config. For service-to-service traffic, hardcoding FQDNs or using service discovery is more predictable than relying on search paths. Service discovery removed the whole class of problem for us.

⚑ Report
Log in to reply.