In Kubernetes, some outbound requests take exactly 5 seconds longer than they should.
AdvancedTroubleshootingLatency
Answer
Likely causes → DNS: with ndots:5, a lookup for api.stripe.com tries every search domain first. Parallel A and AAAA queries over UDP from the same socket can also race in conntrack and drop one, so the resolver waits its 5s timeout before retrying.
Diagnose →
kubectl exec -it api-xxx -- cat /etc/resolv.conf
kubectl exec -it api-xxx -- sh -c 'time getent hosts api.stripe.com'
conntrack -S | grep insert_failed # on the node
Fix → Use FQDNs with a trailing dot, lower ndots via dnsConfig.options, add single-request-reopen (glibc), and deploy NodeLocal DNSCache.
Prevent → Monitor CoreDNS latency and errors, and run NodeLocal DNSCache as a default cluster add-on.
More on Latency
p99 latency jumped from 200 ms to 3 s right after a deploy; error rate is flat.BeginnerThe API is slow, the database shows 100% CPU, and the slow query log is full of one query doing a sequential scan.BeginnerA JVM service has latency spikes every 30–60 seconds; GC logs show "Pause Full (G1 Compaction Pause)" taking 4 seconds.IntermediateThe first request after idle takes 5 seconds; Lambda logs show "Init Duration: 4512.33 ms".BeginnerLatency grows with traffic and logs show "QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30.00".IntermediateA container uses only 40% of its CPU limit on average, yet latency is high; `container_cpu_cfs_throttled_periods_total` keeps rising.Advanced