Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Service only handling 10 concurrent calls regardless of what I do [duplicate]

I realize there's a ton of questions relating to this already but regardless of what I try, there seems to be something different about my problem that keeps any of the other solutions from fixing it.

Here's the problem: I have a simple WCF service. It seems to only allow 10 concurrent calls, I need to to support more than that. This is regardless of what I set my maxConcurrentCalls to in my config. In this case, to simplify the problem I don't even have a real .Net WCF client calling it, I'm simply using fiddler on a few machines to issue a bunch of HTTP posts to the service. They all work individually, but I see them come in 10 at a time. As #1 finishes, #11 starts and so on.

My service is a simple "sleep for 30 seconds and return a string" for this example.

Below is my web.config. You can see I have cranked up my maxConcurrentCalls and my maxConcurrentSessions to more than the defaults. This seems to have no impact at all as I still only see 10 concurrent requests at a time.

What part am I missing to crank this up to allow more concurrent requests?

Edit: This is hosted in IIS 7.5.

Web.config:

<configuration>
<system.web>
    <compilation debug="true" targetFramework="4.0" />
</system.web>

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <security>
        <authentication>
            <anonymousAuthentication enabled="true" />
        </authentication>
    </security>
</system.webServer>
<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
                <serviceThrottling 
                    maxConcurrentCalls="32" 
                    maxConcurrentInstances="2147483647" 
                    maxConcurrentSessions="20"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>

Service:

using System;
using System.ServiceModel;

namespace WCFTestService
{
    using System.Diagnostics;
    using System.Threading;

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
    public class TestService : ITestService
    {

        public string RequestIdentifier { get; set; }

        public int i;

        public string DoWork(string id)
        {
            var secondsBeforeResponding = 20;

            i++;

            this.RequestIdentifier = id;

            Debug.WriteLine("Request: " + id + " Instance:" + i.ToString() + " Thread:" + Thread.CurrentThread.ManagedThreadId.ToString() + " Time:" + DateTime.Now.ToString());

            Thread.Sleep(secondsBeforeResponding * 1000);

            Debug.WriteLine("                                                          Done with request: " + this.RequestIdentifier);

            return "Done with request: " + this.RequestIdentifier;
        }
    }
}

ITestService:

[ServiceContract(SessionMode = SessionMode.NotAllowed)]
public interface ITestService
{
    [OperationContract]
    string DoWork(string requestIdentifier);
}

Output:

Request: b3 Instance:1 Thread:54 Time:4/13/2013 1:50:31 PM <!--- this is the first 10, they all start at pretty much the same time
Request: b4 Instance:1 Thread:47 Time:4/13/2013 1:50:31 PM
Request: b1 Instance:1 Thread:48 Time:4/13/2013 1:50:31 PM
Request: b2 Instance:1 Thread:45 Time:4/13/2013 1:50:31 PM
Request: b5 Instance:1 Thread:44 Time:4/13/2013 1:50:31 PM
Request: b6 Instance:1 Thread:42 Time:4/13/2013 1:50:31 PM
Request: b7 Instance:1 Thread:41 Time:4/13/2013 1:50:32 PM
Request: b8 Instance:1 Thread:39 Time:4/13/2013 1:50:32 PM
Request: b9 Instance:1 Thread:40 Time:4/13/2013 1:50:33 PM
Request: b10 Instance:1 Thread:38 Time:4/13/2013 1:50:34 PM
                                                          Done with request: b3
                                                          Done with request: b4
                                                          Done with request: b1
                                                          Done with request: b2
Request: b11 Instance:1 Thread:35 Time:4/13/2013 1:50:51 PM  <--- this request only starts after the first one finishes
Request: b13 Instance:1 Thread:45 Time:4/13/2013 1:50:51 PM
Request: b14 Instance:1 Thread:54 Time:4/13/2013 1:50:51 PM
Request: b12 Instance:1 Thread:37 Time:4/13/2013 1:50:51 PM
                                                          Done with request: b5
Request: b15 Instance:1 Thread:44 Time:4/13/2013 1:50:51 PM
                                                          Done with request: b6
Request: b16 Instance:1 Thread:42 Time:4/13/2013 1:50:51 PM
                                                          Done with request: b7
Request: b17 Instance:1 Thread:41 Time:4/13/2013 1:50:52 PM
                                                          Done with request: b8
Request: b18 Instance:1 Thread:39 Time:4/13/2013 1:50:52 PM
                                                          Done with request: b9
Request: b19 Instance:1 Thread:40 Time:4/13/2013 1:50:53 PM
                                                          Done with request: b10
Request: b20 Instance:1 Thread:38 Time:4/13/2013 1:50:54 PM
...
...
...
like image 888
Bob Bland Avatar asked Apr 13 '13 14:04

Bob Bland


People also ask

How many requests can a WCF service handle?

By default, a WCF service handles only one request at a given moment of time.

What is the default max concurrent calls?

1. The default value of Maximum concurrent calls for WCF throttling is 26 . 5.


1 Answers

You could be running into OS limitations. Try to deploy your service out to a server and reproduce the behavior from there.

like image 83
Jeff Avatar answered Oct 22 '22 06:10

Jeff