BizTalk: Performance tips for high volume WCF calls

Introduction

Most BizTalk administrators monitoring operations usually tend to realise that a majority of errors during load is caused when communicating with external systems. This article especially focuses on tuning parameters when interacting with external system(s) and attempts to explain a few ways to check if the lack of tuning , these parameters, is the source of your problem.

Applies to

  • BizTalk server 2013 R2
  • IIS 6 - IIS 8.5
  • .Net v4 - .Net v4.5

 

Tip#1 Turn on authPersistNonNTLM on the service side for WCF HTTP calls

Scenario

You have WCF client bindings that use http(s) transport (e.g. basichttpBinding, wshttpBinding) with transport credentials (e.g. windows Kerberos) for authentication. These WCF clients talk to services hosted on IIS 6, IIS7, or IIS 7.5. However you face performance timeouts or slow responses under load.

Symptoms

Solution




         

      <    system.webServer    >   
                 <      modules runAllManagedModulesForAllRequests="true"/>   
                  <      security      >       
                    <      authentication      >       
                      <      windowsAuthentication enabled="true" authPersistNonNTLM="true">   
                      </      windowsAuthentication      >       
                    </      authentication      >       
                  </      security      >       
      </    system.webServer    >  

Additional Info

  • You may also face a .net bug where your application stops responding or hangs. For details see KB 2497453 - FIX: Application may stop responding after several HTTP requests are aborted if you use the HttpWebRequest class to send requests in the .NET Framework 

Tip#2 Increase max concurrent client http connections for your top services to avoid client side timeouts.

Scenario

Your BizTalk solution talks to a service, over http(s). When send multiple simultaneous requests to this service, the BizTalk server experiences timeouts.  On further investigation, you realise that the server response times are not an issue and client side http requests tracing through tools like fiddler seem to be responding with ok response times. Then your problem could be related to .net client side timeouts as the .net service point manager internally uses queues to process http request per endpoint+authentication , and the time-out settings usually include the queue time at the client side.

Symptoms

  • BizTalk server experiences timeouts under heavy load when making external http(s) calls
  • When you load test the service, tracing client side requests with fiddler show fast response times (order of milliseconds), but the client calls still time-out
  • During the load test, the HttpWebRequest performance counters HttpWebRequests Queued/Sec & or HttpWebRequests Average Lifetime show high values. For details about these counters see msdn blog  New Performance Counters for HttpWebRequest  

Note: If during load tests, the client side performance counter HttpWebRequests Average Lifetime shows zero, when the HttpWebRequests Created per sec is not zero then you may not be closing/aborting the WCF connections correctly. If so, fix the code, before you increase max connection

Finally after investigating through all cases to isolate client side timeouts, vs clients not closing connections and server failing under load you definitely have sufficient evidence to suggest that these errors are due to client side http request timeout. Now you can now increase the client max client connections to an acceptable level.

Solution

 




         

      <    system.net    >   
                  <      connectionManagement      >       
                    <!-- Ideally max connections should be set upto 12 * Number of CPUS       
                     Caveat:        
      Increasing the max connections may start to cause server side issues. So this setting needs to be a tradeoff between client side timeouts and server side load issues. If you think increasing the number of max client connections causes the server to fail, you can decrease the max connections and increase the client side timeout settings. -->   
                    <      add maxconnection="24" address="http://contoso.com/:8080"/>   
                    <      add maxconnection="24" address="*"/>   
                  </      connectionManagement      >       
      </    system.net    >  

Additional Info

Tip#3 Configuring NetTcpBinding for high performance

Scenario

Your BizTalk solution uses an intranet WCF service using NetTcpBindings.  However despite using NetTCPBinding you still face client side timeouts under load..

Solution

  • Increase max concurrent service instances on the service side before service throttling kicks in...



         

      <    system.serviceModel    >   
                    <      behaviors      >       
                      <      serviceBehaviors      >       
                        <      behavior      >       
                          <      serviceThrottling maxConcurrentCalls="100000" maxConcurrentInstances="100000" maxConcurrentSessions="100000" />   
                          </      behavior      >       
                      </      serviceBehaviors      >       
                    </      behaviors      >       
      </    system.serviceModel    >  
  • Increase listenbacklog and maxconnections on the service side nettcpbinding configuration.



         

      <    netTcpBinding    >   
                    <      binding  listenBacklog="1000" maxConnections="1000"   />   
      </    netTcpBinding    >  
  • If you have hosted the net.tcp enabled service on IIS then the listenbacklog, maxPendingConnections settings must be configured on SMSvcHost.exe.config (for 64 bit app pool process using .net 4.0 , this is located at C:\Windows\Microsoft.NET\Framework64\v4.0.30319) . For more info, see section additional info about modifying smsvchost config.  



         

      <    net.tcp listenBacklog="100" maxPendingConnections="1000" maxPendingAccepts="2" > 
                   <!-- ........-->      
                 </      net.tcp      >      

For the new settings in SMSvcHost.exe.config  to take into effect,  the SMSvcHost.exe must be  restarted. The only way to stop SMSvcHost.exe is to stop all dependent services such as Net TCP port sharing service.  So you must stop  nettcpportsharing and related services until the SMSvcHost.exe disappears from the windows task manager and start these services again.

Additional Info

Tip#4 Slow down sending requests to external services using host throttling

Scenario

Your BizTalk solution process a huge volume of messages where scalability is far more important than high performance. Common use cases for this scenarios are messages from a one way port (ftp, file adapter, one way http receive, batch processing cases etc.) and eventually processing them successfully is more important completing them quickly. These messages rely on external systems to complete processing, but the external systems are unable to cope with a huge volume of concurrent requests causing failures.

Solution

  • Create a new BizTalk host  called say, BiztalkHostSuperSlowHttpSend, as per https://msdn.microsoft.com/en-us/library/aa561079.aspx
  • You now want to slow down the number of messages delivered to this host, as the rate of message delivery to this host is much faster than the adapter can process, decrease the value of the In-process messages per CPU , see sample value (10)  in the screen shot. PS: You may need to tweak (lower this value even further) this value depending on your requirements.

  • Use this host (BiztalkHostSuperSlowHttpSend ) as the send handler for all your send ports where you want the messages to be slowed down
  • PS: If you are using http to connect to the external system, there are other parameters such as maxConnections see section Tip#2 that can be tweaked. Decreasing max connections for that particular server:port and increasing the WCF send timeout will allow you to throttle the requests to that server and complete processing without timeouts. However the maxconnections settings applies to all outbound connections to that server:port and may not work well with cases where you want to prioritise certain messages to that server. An example of this would be BizTalk receiving a request response web operation and this relies on the same external server:port to complete its operation. In such cases you can configure 2 different send ports, one using use a slow lane (throttled BizTalk host eg BiztalkHostSuperSlowHttpSend) for batch processing and the other port using the default send handler for that transport for optimal message processing.

Additional info

See Also

Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.