I have a feeling this has been asked before, maybe even by me (😅), but I can't find any results when searching. I have a homelab with k3s, using an external postgres database as datastore. Since last evening (~14 hours or so), k3s has made ~35000 DNS queries to get the IP for the postgres server, which seems excessive. Is this some kind of misconfiguration on my system, or is this normal? (Or is it some kind of bug?).
c
creamy-pencil-82913
06/26/2025, 5:52 PM
There is no caching built in to the golang dns resolver. If you use a hostname in an address, it will look it up every time it needs to connect to it.
creamy-pencil-82913
06/26/2025, 5:53 PM
Use the ip instead, or use a local cache on your node (nscd, systemd-resolved, or the like).
q
quick-dentist-45681
06/26/2025, 6:33 PM
Still, doesn't that imply that the server creates a new connection 35000 times over 14 hours? That means every connection has a lifetime of between 1 and 2 seconds, which seems awfully wasteful?
c
creamy-pencil-82913
06/26/2025, 6:47 PM
it is up to the postgres sql driver to pool connections. but yes that does suggest it is opening and closing connections frequently.