2

I'm trying to research an issue that another developer has reported. He claimed that when the Silverlight application we have created hits a WCF web service hard with concurrent calls that the calls start to be stacked at the server. His claim was that we are using sessions because of the method of authentication we are using (using forms and asp.net membership for sql). So I created a really simple test application

Screen shot of test application

The application allows me to specify the number of concurrent calls to a web service I want and then indicates the current number of outstanding calls and the average response time in seconds.

The web service itself simple sleeps the thread for a second

    public void DoWork()
    {
        Thread.Sleep(1000);
    }

So what I thought would happen is that if my colleague was right, then the calls would be stacking up at the server so the average response would be 2 seconds if there are two concurrent calls. However what appears to happen is that the times remain at just above a second until I get to seven concurrent requests and then it starts to increase relatively predictably.

Running a second client (in a Chrome window along side the initial IE window) does not appear to impact the performance (there is an initial hiccup). This is not the case if you run two IE's or two Chrome's side by side, then the two seem to impact each other suggesting they are sharing a connection.

It also seems that fiddler was interfering. I ran the application without fiddler with 7 concurrent calls and it was averaging around 1.15 seconds per call. I then started fiddler and times dropped back to just over a second, it was as if fiddler was allowing the extra calls to get through.

So my question. What is going on here? Where is the throttling (at 6 concurrent requests) taking place (client or server)? Why does running fiddler speed up the requests?

Some extra info.

The web service class has a couple of attributes

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.PerSession)]
public class DoVeryLittle : IDoVeryLittle
{
    public void DoWork()
    {
    }
}

AspNetCompatibilityRequirements is meant to allow integration with the asp.net pipeline and authentication. The ConcurrencyMode and InstanceContextMode of the ServiceBehavour are apparently to create and instance per session. However we are using the basicHttpBinding for the endpoint and I've seen that this does not support sessions so I'm a bit confused on this.

For completeness here are the service related entries in web.config

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="AspNetSqlRoleProvider" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
naskew
  • 2,091
  • 1
  • 19
  • 20
  • I've been doing a little more research and the service behaviour attributes should be preventing concurrent calls reaching the service from the same session. However it does appear that the session is not maintained and that each call is getting a new session. This kind of lines up with what I read about the basichttpbinding not supporting sessions. More work required I suspect. – naskew Sep 05 '12 at 09:24

2 Answers2

2

The 6 concurrent connections limit sounds like the max enforced by IE.

You don't specify your IE version but here is the reference for IE8, including instructions for changing the limit: Connectivity Enhancements in Windows Internet Explorer 8

I would try to play with the limit and see if it affects your results.

boris
  • 1,525
  • 3
  • 13
  • 18
  • boris, I've tried changing the limit in the way described in the article but it does not seem to have an effect. However I am using IE8 and the link you gave suggests that the limit should be 6 so that matches. I was also using the silverlight client stack and found that also has a limit of 6. Thanks for the reply. – naskew Sep 05 '12 at 09:20
2

OK with some help I have found the explanations I needed.

  • Why was my colleague hitting a problem with concurrent WCF calls?

Well he probably wasn't. During my tests I needed to change the attributes of the service to the following to be able to reproduce the problem.

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.Single)]

This forces a single instance of the service to be created and then concurrent calls to be stacked. Originally I had the attibutes

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.PerSession)]

And this will specifically create a new service for each new session. However I also found that each call was getting a new session and this is because we are using the BasicHttpBinding which does not support sessions.

  • Why is there a limit of 6 concurrent calls?

This is most likely, as boris mentioned, the limit for the browser and then later the client stack that we were using. Although I did not manage to change the setting to see if that made a difference, it makes perfect sense that the number 6 was consistently appearing in both cases.

  • Why does fiddler change this?

I really have no firm idea on this and would welcome anyone else's input.

naskew
  • 2,091
  • 1
  • 19
  • 20
  • Not sure but sometimes the problem with the concurrent calls from silverlight application are related with browser connection management. For me the solution was to put that in our App.xaml.cs, Application_Startup method WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp); http://weblogs.asp.net/olakarlsson/simultaneously-calling-multiple-methods-on-a-wcf-service-from-silverlight – user1011138 Jan 02 '15 at 07:19