Skip to content

Instantly share code, notes, and snippets.

@adgad
Last active August 29, 2015 14:27
Show Gist options
  • Save adgad/659a7e801b56cbc190b4 to your computer and use it in GitHub Desktop.
Save adgad/659a7e801b56cbc190b4 to your computer and use it in GitHub Desktop.
Notes from playing around with DNS on node
  • Node http uses dns.lookup behind the scenes

  • dns.lookup = uses OS facilities i.e. should be same as ping/wget etc

  • dns.resolve = gets from network, ignores OS config

  • both have options to force IPv4

  • dns.lookup seems to cache (presumably OS cache) i.e. first lookup on app startup slow, after that fast

  • localhost: resolves and lookups all quick. lookup() slightly slower than lookup(...4) (until cache hits)

  • heroku: dns.resolve() a lot quicker than dns.lookup(). markets: lookup slower than lookup(v4), portfolio: lookup and lookup(v4) equally slow.

UPDATE - The reason portfolio lookup(v4) was still slow is because lookup is constrained by a fixed threadpool size. Setting that UV_THREADPOOL_SIZE environment variable to a higher value got the test results back to expected. https://nodejs.org/api/dns.html#dns_implementation_considerations

  • Not all urls work with an IP address e.g. amazon s3 redirects, heroku says no such app found.

URLS

https://github.com/yahoo/dnscache

https://howdns.works

https://floating-falls-5368.herokuapp.com/test

https://nodejs.org/api/dns.html#dns_implementation_considerations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment