简体   繁体   中英

Web service concurrent calls processing

I've faced with the next issue related to web service request processing:

Preamble
I have

  • Web api service hosted on IIS 7.0 on local machine
  • Test harness console application on the same machine

and i'm trying to simulate web service load by hitting one with requests generated via test harness app. Test harness core code:

    static int HitsCount = 40;

    static async void PerformHitting()
    {
        {
            await Task.WhenAll(ParallelEnumerable.Range(0, HitsCount)
                                                 .Select(_ => HitAsync())
                                                 .WithDegreeOfParallelism(HitsCount));
        }
    }

    static async Task HitAsync()
    {
        // some logging skipped here
        ...
        await new HttpClient().GetAsync(TargetUrl, HttpCompletionOption.ResponseHeadersRead);
    }

Expectation
Logging shows that all HitAsync() calls are made simultaneously: each hit via HttpClients had started in
[0s; 0.1s] time frame (timings are roughly rounded here and below). Hence, I'm expecting to catch all these requests in approximately the same time frame on web service side.

Reality
But logging on the service side shows that requests grouped in bunches 8-12 request each and service catches these bunches with ~1 second interval. I mean:

[0s, 0.3s] <- requests #0-#10
[1.2s, 1.6s] <- requests #10-#20
...
[4.1s, 4.5s] <- request #30-#40

And i'm getting really long execution time for any significant HitCount values.

Question
I suspect some kind of built-in service throttling mechanism or framework built-in concurrent connections limitation. Only I found related to such guesstimate is that , but i didn't get any success trying soulutions from there.
Any ideas what is the issue?

Thanks.

By default, HTTP requests on ASP.NET are limited to 12 times the number of cores. I recommend setting ServicePointManager.DefaultConnectionLimit to int.MaxValue .

好吧,问题的根源在于IIS + Windows 7并发请求处理限制(有关限制的一些信息, 在此 。使用Windows Server将服务移出计算机即可解决问题)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM