Note that there are some explanatory texts on larger screens.

plurals
  1. PODns.BeginGetHost... methods blocking
    primarykey
    data
    text
    <p>So I want to make a <strong>lot</strong> of DNS queries.</p> <p>I create (thousands) of Tasks from the <code>Begin/EndGetHostEntry</code> async pair:</p> <pre><code>var lookupTask = Task.Factory.FromAsync ( Dns.BeginGetHostEntry, (Func&lt;IAsyncResult, IPHostEntry&gt;) Dns.EndGetHostEntry, "google.com", null ) </code></pre> <p>then <code>Task.WaitAll</code> for everything to complete. I'm seeing the number of <code>ThreadPool</code> threads increase drastically in response to my requests. If I force the <code>ThreadPool</code> <code>minThreads</code> to 500, the workload is consumed considerably faster. All of this points to blocking in the <code>Dns</code> asynchronous implementation.</p> <p>If I replace <code>Dns</code> with a <a href="http://arsofttoolsnet.codeplex.com/">managed Dns client</a>, I can consume the same workload with only 1 or 2 threads in the <code>ThreadPool</code> with cpu virtually idling.</p> <p>The thing is, the <code>Dns</code> implementation is absolutely core to many networking APIs (<code>HttpWebRequest</code>, <code>WebClient</code>, <code>HttpClient</code>), and they all seem to be affected by this issue. If I resolve DNS with a 3rd party library, and make HTTP requests using the IP address as the host in the uri, then alter the <code>Host</code> header to fix the request, I get blistering performance in comparison to anything involving <code>System.Net.Dns</code>.</p> <p>What's going on here? Have I missed something or is the <code>System.Net.Dns</code> implementation really that bad?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload