Search code examples
wcfarchitectureiis-7basichttpbindingchannelfactory

How is a WCF Service and IIS integrated, what is the architecture and flow for incoming requests


I have been technically testing a WCF service recently and have got to the point where, my lack of understanding is not allowing me to progress forward and find a solution to a timeout problem we see.

We are load testing a WCF Service which is hosted on IIS7 on windows server 2008. The system set up to fire the messages actually fires them at an application which is biztalk. Biztalk then process the messages and sends them on to the end point of the WCF Service. The WCF Serviceis also using .net 2.0 in it's app pool (I guess this means it could actually be 3.0 or 3.5 as these were not full releases?

We fire 40 messages within a seconds and 90% of them become timed out due to the send timeout on the client (biztalk). We thought at first this was strange because we expected the server's basic http binding receive timeout to trigger first, but it turned out that was set at 10 minutes and the client send timeout was set at 1Min and 30 Secs.

What I understand:

WCF Services have config files which have inside them behaviors and http bindings. The Server end point we are sending an XML message to is using BasicHtppBindings: Timeouts:Open/Close is 1 Minute, Send and Recieve are 10 minutes. The server's timeout which we know are involved so far is: sendtimeout: 1 minute.

I understand WCF's architecture works by creating an instance of either a channel factory or service host and creates a channel stack which contains the behaviors and binding settings from the config as channels. There is a TransportAdaptor which is used to move the xml message once it has been processed through the channel stack.

I understand from IIS that http.sys handles the incoming requests. It passes requests to the workerprocess and when that is busy, it places requests onto the kernel mode queue? I understand there some machine.config settings that can be set to increase this queue/limit this queue?

I also know about how to make an app pool into a webgarden and I have read you can increase the number of threads per core, from the default of 12; this is don e via a registry setting or a later on in .net a web config change.

I just read about InstanceContextMode and how it can effect the server's service too... But I'm unsure what that is set to in this case.

We recorded some perforamance counters, .net ones and I noticed the number of current requests minus the (Queued+Disconnected) = 12. Which indicates we are using 1 core? and the number of threads of on that core is set to 12.

Can anyone help me for a clearer picture and help piece my knowledge with some extra into something that is more complete?


Solution

  • The WCF Behavior has a throttle setting. Here is an example (grabbed from msdn):

      <service 
        name="Microsoft.WCF.Documentation.SampleService"
        behaviorConfiguration="Throttled" />
    

    ..... .....

    <behaviors>
      <serviceBehaviors>
        <behavior  name="Throttled">
          <serviceThrottling 
            maxConcurrentCalls="1" 
            maxConcurrentSessions="1" 
            maxConcurrentInstances="1"/>
        </behavior>
      </serviceBehaviors>
    

    By default (if not specified), the service is throttled to 10 concurrent calls.

    I find that a sensible production setting for high volume clients running short calls is more like 100. Of course it depends on your implementation, but the defualt definitely hurts performance on my test and production systems.