-
Notifications
You must be signed in to change notification settings - Fork 7.3k
dns.lookup shares a thread pool with disk operations #2868
Comments
When you say "disk I/O", are you referring to If you're referring to |
Am Samstag, den 10.03.2012, 17:55 -0800 schrieb Colton Baker:
That's not "threads", it's processes. And, uhm, this really seems like a |
@thejh Okay. Maybe using "threads" wasn't the best word to choose. Should have known someone would be a technical brat. Regardless of whether This is not a Node error. It is a user error. You act as if this wouldn't happen in another coding language where a lot of requests were made back-to-back, using the same queued callback for everything. By the way, where was your suggestion on how to fix this? If you're here to TroLLz, can I play too? |
I'm referring to fs. See this thread for context: http://groups.google.com/group/nodejs/browse_thread/thread/6f564ac1dcd650bf/100bc657172b88e2 I solved my own problem using dns.resolve4 and then handing the IP to an http request, the performance difference is amazing. I also contributed a patch to the fetch module (https://github.com/andris9/fetch) doing that. I'm a little surprised no other http client library implements this. It would be the bottleneck of many network-bound projects. |
"Colton Baker" reply@reply.github.com schrieb:
I don't mind you contributing... Uhm... half-constructive comments, too. :D No, seriously - IMO, it'd be good to be able to reserve IO threads for specific node domains, but I don't have code for that as it's not related to any problems I have and I'm a bit lazy. Also, well, we don't have domains yet, so it won't work anyway. |
To clear up any misunderstandings, what happens here is that |
This is a very serious issue, as queuing only 4 DNS queries will delay everything else using the thread pool. Considering that a DNS query can take more than 20 seconds with default timeout/retry settings, if the thread pool queue is filled with DNS queries, everything can be delayed for minutes or even hours. |
Are there any blockers to Node using dns.resolve internally for net.connect etc? And leaving dns.lookup for those that need it? |
I've responded to your question on the mailing list. For posterity:
tl;dr net.connect() and friends won't be switching to dns.resolve() anytime soon. The scalability of the thread pool is a subject of ongoing research; it's possible to speed up specific workloads by a factor of 10 - but not, it seems, without regressing other workloads by a factor of 5 or more. That won't do, of course. If you want node.js to use more threads, run |
Let me add that a change that makes the DNS resolver configurable in the call to net.connect() might be acceptable. (Should target master, come with docs and regression tests, etc. See CONTRIBUTING.md for details.) The API I have in mind is something like this: net.connect({
host: "nodejs.org",
port: 80,
resolver: function(host, type, callback) {
return dns.resolve(host, type, callback);
}
}); It's up for debate if the 'type' argument should be called 'family' instead and be a number, like how dns.lookup() works. I'm open to well-reasoned suggestions. |
Thanks Ben, that would help. I had a runtime environment flag in mind though, just to indicate to net.connect that it should use dns.resolve directly. This would save me from having to update calls to net.connect to pass in a custom resolver (although that might be great for other use cases). |
also for posterity there are things like http://npmjs.org/package/native-dns which implement dns in terms of node primitives such that you're not subject to the thread pool |
Can this issue be re-opened? I like the API that @bnoordhuis has proposed. :) @bnoordhuis - Is it also possible to revise Thoughts? |
I'm ok with it, but have no time to work on it :( |
That's okay. I will try to take a shot at it over the next few days here. Just too busy at the moment. At any rate, if the issue is re-opened, it might get a bit more attention. Thanks! |
I think that there are a few issues here: 1.) The API for With all that being said... How should this issue be handled? Should a new issue be opened? Should this one be re-opened? |
Going to reopen since we seem to be cool w/ the possibility of implementation. But yeah, core doesn't have time for this now. PR's will be welcome. :) |
@trevnorris - Thanks for re-opening! If time permits, I will work on a PR. |
Closing this in favor of the reduced issue #8475. |
If you generate a lot of DNS requests, they get queued and become slow. Disk I/O gets in the same queue so it is slowed down as well.
The text was updated successfully, but these errors were encountered: