Reputation: 2856
I setup an Azure website that just returns the default page. The response time calling this link from .Net Core 2.1 is a few milliseconds. I then try to send 1000 concurrent requests using HttpClient. The batch completes on average in 27 seconds.
class Program
{
static void Main(string[] args)
{
Task.WhenAll(Enumerable.Range(0, 1000).Select(i => Get(i)));
}
static HttpClient client = new HttpClient();
static async Task Get(int i)
{
var response = await client.GetAsync("http://testinghttpclient.azurewebsites.net/");
var content = await response.Content.ReadAsStringAsync();
}
}
27 seconds per 1000 requests seems too slow to me. Am I using HttpClient correctly? If so, can you please help me understand what my limiting resource is in this situation?
Upvotes: 0
Views: 186
Reputation: 2856
The issue was running this from the IDE. Publishing it in the release mode and running it from the command line brought the execution to under a second.
Upvotes: 1