Node-fetch: DNS cache

Created on 14 Nov 2018  路  3Comments  路  Source: node-fetch/node-fetch

I do understand that mabe it's not the purpose of this lib (feel free to close in case).
But would be useful adding a DNS cache layer.
It's one of the common problem nowadays with huge number of requests. It doesn't cache dns lookups or anything. Maybe it's worth just mentioning this in Readme.

What's the cleanest way to deal with it?

question

Most helpful comment

huge number of requests

  • a handful of domains? set keep alive with agent option.
  • completely different domains? caching isn't going to help you much.
  • somewhere in middle? probably want to solve this by running your local dns server and cache response.
  • you can also write a custom dns lookup function for with agent, but it's not currently documented in nodejs doc, so you have to look it up yourselves.

All 3 comments

huge number of requests

  • a handful of domains? set keep alive with agent option.
  • completely different domains? caching isn't going to help you much.
  • somewhere in middle? probably want to solve this by running your local dns server and cache response.
  • you can also write a custom dns lookup function for with agent, but it's not currently documented in nodejs doc, so you have to look it up yourselves.

The proposed solution doesn't help many parallel requests. Every one does a separate DNS lookup. And they can fail because there are so many in parallel. Making a separate agent for each request would have the same problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bittlingmayer picture bittlingmayer  路  4Comments

githubnikola picture githubnikola  路  3Comments

pdehaan picture pdehaan  路  6Comments

normanrz picture normanrz  路  3Comments

jimliang picture jimliang  路  4Comments