-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using an IP still invokes DNS lookup due to callback being defined on datagram send #198
Comments
We're seeing the exact same problem. Also wanted to note that we tried using |
What versions are you both using? Note we have had issues with cacheDns in the past, as noted in https://github.com/brightcove/hot-shots/blob/master/CHANGES.md. So unfortunately some older versions may not work with this setting as expected. Thank you for all of the looking into this issue @peeter-tomberg in case it's not this. It's not clear to me from nodejs/node#35130 if that would mean this would be a real DNS lookup however? The comment in that issue says " "dns.lookup() has a fast path for IP addresses" which I would assume mean it wouldn't really do a DNS lookup. |
We've been on 8.3 (latest) for two months now. This post on However, the "fast path" for DNS lookups leaves me equally confused as to what's causing this. |
We're experiencing the exact same problem |
Reproducing this is pretty straightforward on my macbook:
produces the output:
|
@peeter-tomberg It's not clear to me that this reproduction really shows that DNS is in use. As I noted above, the issues says that "dns.lookup() has a fast path for IP addresses" which I would assume mean it wouldn't really do a DNS lookup. That would make a lot of sense to me, that the code would be smart enough to return an IP if it thought that's what was seen. To be clear, I'm not saying there isn't an issue here. I'm just not sure it's clear what exactly is wrong (and how to fix it). Is this a new issue for people? |
Ok so I looked at this a little bit more tonight, and the example can be changed to actually cache by waiting a bit. Something like this:
This is because that gives time for the resolved address to get in place for future calls, which you can see in https://github.com/brightcove/hot-shots/blob/master/lib/transport.js#L64 I also now remember that we do have tests in place for this exact case: https://github.com/brightcove/hot-shots/blob/master/test/udpDnsCacheTransport.js#L88 One thing to note is that yes you could see some DNS calls as the caching kicks in, and you will see more DNS calls when cacheDnsTtl expires (which you can set to be higher). I am wondering if these two things, along with the cache setting just being broken in a much of releases, is what everyone is seeing altogether. I don't think I know for sure though, so interested in more data. I should note though that I have not had a lot of time to dig into things lately- today was an exception. So I very much appreciate all digging in (and PRs, which I do still make sure get looked at promptly). Thanks all! |
Referencing DataDog/dd-trace-js#1187 |
This behavior still seems to occur in the latest version, but the recent discussion in nodejs/node#39468 might provide an explanation for the behavior. Node’s UDP One workaround is to provide a no-op |
Since a399dda landed in const client = new StatsD({
host,
port,
udpSocketOptions: {
type: 'udp4',
lookup: (hostname, options, callback) => {
// if IP address, bypass dns.lookup
if (isIP(hostname)) {
callback(null, hostname, 4);
return;
}
// if a real hostname, then resolve using dns.lookup
dns.lookup(hostname, options, callback);
},
},
}); |
Is this issue still actual? |
added the workaround from brightcove/hot-shots#198 (comment) Co-authored-by: Aman Karmani <[email protected]>
Yeah, this issue is still real @meetmatt |
Hello!
We recently integrated datadog ontop of our existing monitoring solution and discovered a lot of DNS lookups for our statsd agent IP. We were specifically passing an IP so we wouldn't have to resolve a host name.
It seems to be the fact that for UDP we are using: https://nodejs.org/docs/latest-v12.x/api/dgram.html#dgram_socket_send_msg_offset_length_port_address_callback
Which is being utilised here: https://github.com/brightcove/hot-shots/blob/master/lib/transport.js#L46-L87 through this API: https://github.com/brightcove/hot-shots/blob/master/lib/statsd.js#L314-L373
Since we are always passing a callback the following kicks in:
which seems to cause a DNS lookup: nodejs/node#35130
By that post, there should be a quick path for DNS Lookup for IPs but I couldn't find it. We're seeing A LOT of requests for resolving DNS for an IP. Any recommendations on how/if we should cut these down?
The text was updated successfully, but these errors were encountered: