HttpClient.GetAsync is slow in dnxcore50 compared to dnx461
When using GetAsync on HttpClient the request is taking considerably longer to return when running the same code targeting dnxcore50 compared to dnx461. This is from an ASP.NET 5 project, and happens when running within IIS Express and Kestrel.
As an aside was hoping to debug against the core code, but even after cloning the repo, and adding the source folder to my global.json file I couldn't get VS2015 to pick up the local reference, so any help on that would be great.
As an aside was hoping to debug against the core code, but even after cloning the repo, and adding the source folder to my global.json file I couldn't get VS2015 to pick up the local reference, so any help on that would be great.
That is a known issue with DNX. This won't be resolved until ASP.NET 5 (now known as ASP.NET Core 1.0) moves over to the DOTNETCLI toolchain. That will happen in a few weeks.
Is this on Windows or Linux or Mac?
This is on Windows 7.
@ballm Can you please post some Visual Studio solution with repro code? Also, can you share any timings that you have measured between what you see with .NET Core vs. .NET Framework.
I've uploaded a test console app to https://github.com/ballm/dotnet_core_issue_6180.git it makes 10 requests and outputs their timing to screen along with showing an average. When targeting DNX46 it is considerably quicker than targeting DNXCORE5. Have added the outputted results I captured below.
DNX 4.6
0: 291.0291 ms 1: 289.0289 ms 2: 278.0278 ms 3: 273.0273 ms 4: 284.0284 ms 5: 282.0282 ms 6: 281.0281 ms 7: 280.028 ms 8: 296.0296 ms 9: 282.0282 ms
Total Duration: 2836.2836 ms Average: 283.62836 ms
DNXCORE 5
0: 4732.4732 ms 1: 2645.2645 ms 2: 4517.4517 ms 3: 2658.2658 ms 4: 2689.2689 ms 5: 2654.2654 ms 6: 2662.2662 ms 7: 2649.2649 ms 8: 2653.2653 ms 9: 2674.2674 ms
Total Duration: 30536.0533 ms Average: 3053.60533 ms
I ran the Visual Studio solution from your git repo you referenced above.
I did not reproduce your performance results above.
I got comparable results between CLR (.NET Framework) and CoreCLR (CoreFX):
I switched between CLR and CoreCLR using the properties dialog in Visual Studio:


I ran the above timings using Release build:

I'm 100% sure that I had the same issue (with HttpClient) targeting the .NET Core 1+ week earlier (I don't have proof). I ran tests after @davidsh post... But the extremely slowness is just disappeared! So I set the target to .NET Core in my project, and everything was fine, even the requests were faster. I don't know how and what caused the issue. I tried to reproduce but no success. What about you, @ballm ?
The other thing to mention is that DNX will always use the version of System.Net.Http binary that is in its "runtime" folder regardless of what version you might specify in your project.json file. This problem is going away since DNX is going away and DOTNETCLI is taking its place. In particular, there won't be a fixed runtime folder so project.json versions will win out.
The version of System.Net.Http currently being used for DNX RC1 Update 1 is the version in NuGet.org which is 23516. That version is pretty old and did not have many of the perf improvements we've made over the last few months.
Hi, Re-ran the project again just now, ensuring that I had picked the runtime using the properties dialog, and that it was running in release mode. Still getting the same behaviour (albeit my internet speeds here are a lot slower than yours, and today are particularly slow, core is still running comparatively slower than .net framework).


I'm on Windows 7 and behind a corporate firewall, so not sure if either of these could cause a difference, presuming the core version has differences around DNS look up/proxy resolution etc as well as just the actual async send/receive? I will try running it when I'm at home to see if I experience the same thing there, or whether I get comparable results as you did.
Am I able to target a later version than that of RC1 to see if the perf improvements do now resolve this? Or do I need to wait for the RC release? (Not looked very hard at targeting different versions, so this may be easy or not...)
I'm on Windows 7 and behind a corporate firewall, so not sure if either of these could cause a difference, presuming the core version has differences around DNS look up/proxy resolution etc as well as just the actual async send/receive? I will try running it when I'm at home to see if I experience the same thing there, or whether I get comparable results as you did.
Proxy lookup can make a huge difference depending on the autoproxy discover settings on the corporate network/firewall.
Can you try doing this 1) at home, and 2) at work but add handler.UseProxy = false; to disable use of the proxy?
You won't be able to target new binaries until we release RC2 on NuGet.org which will use DOTNETCLI.
Running at work with the handler.UseProxy = false; the times are now comparable.


So it would appear that something around the proxy auto discover is slower with core. Running the tests with the UseProxy = true; again was showing .net framework at the same 294ms average, while core was 2500ms. My internet speeds have been fluctuating however so wouldn't like to say its always around 8.5 times slower, but it is definitely always considerably slower. (Hence why I originally raised this)
I had the same issue too. When I publish my app to iis on server 2008, it went so slow, but it works good on my pc(which I use cmd: "dotnet run")
and then, I change my code with " handler.UseProxy = false ", seems no problem
Closing this issue as it appears that the problem here is slow proxy discovery caused by the particular network configuration of this repro. So, this is specific to the local network being used.