Page 1 of 1
DNS Lookup Question
Posted: Thu Jul 11, 2024 1:40 pm
by JasonWallace
I have a question that maybe more an IBM i DNS issue, but I wanted to check here first.
I have some programs that make many http calls using a dns name (4-5/second). IBM i is setup with an DNS server on the lan.
The networking team is complaining that it appears we are not respecting the ttl of the response ( ttl is 3600 and the response is non-authoritative).
it seems we are doing a dns lookup each time.
Is their any settings in libhttp that may affect this?
Thanks in advance.
Re: DNS Lookup Question
Posted: Thu Jul 11, 2024 8:03 pm
by Scott Klement
HTTPAPI simply asks the operating system to look up the name -- as all applications do. The DNS resolver routines are part of the operating system, they aren't part of HTTPAPI.
You configure your DNS resolver with the CHGTCPDMN command, or CFGTCP option 12.
That said, I don't think your network people understand what the TTL does. The resolver is not expected to cache the response for the TTL time -- but rather, the local DNS server is supposed to do that. i.e. a non-authoritative server will get the answer from an authoritative one, and will cache it for the TTL time. The resolver simply asks the server for it each time.
If you didn't do that, every job on the system would have it's own DNS cache separate from the others. Putting it in a DNS server is done so that everyone on your network can share the same cache, making it more efficient for everyone. If you and I are on the same network and both look up Google.com it only has to look it up once because we're using the same server. When you ask for it the first time, the local DNS server reaches out to Google to get it and caches it for the TTL time. When I ask for it, since it's already in the cache, it returns the same answer to me without having to leave the network.
You seem to be expecting this behavior in every application rather than in the local caching DNS server. In my 25 years of TCP/IP programming, I've not heard of that... That makes application programming wildly complex and inefficient. I could see the logic behind putting it in the DNS resolver in the OS so that the logic doesn't need to be repeated in every application -- but I haven't ever seen that, either. It's always in the local caching DNS server.