Search code examples
performancewcfwcf-binding

Increasing WCF Performance


We have design AJAX – Enable WCF web services for our mobile application. Web service methods returns data in JSON format. We are observing delay in calling web services and binding it to mobile widget. The size of data in approximately 50K.

According to Code Project , we have applied changes to web.config file of WCF Web Service.

Similarly, following one of the stackoverflow question we are trying to increase message size. Now, problem is how we should apply changes to our current web.config file so that message size is increase. We are using default NET 4.0 setting. Also, do we need to define end point on our client web.config file. Can someone provide client side web.config?

Our current server web.config settings is:

<?xml version="1.0" encoding="utf-8"?>

<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<identity impersonate="false" />
<webServices>
  <protocols>
    <add name="HttpGet"/>
    <add name="HttpPost"/>
  </protocols>
</webServices>
</system.web>

<system.serviceModel>
<diagnostics performanceCounters="All"></diagnostics>
<behaviors>

  <serviceBehaviors>
    <behavior name="ServiceBehavior">

      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />

      <!--Increase WCF Performance-->
      <serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>      

    </behavior>
  </serviceBehaviors>

  <endpointBehaviors>
    <behavior name="MobileService.webHttpBehavior">
      <enableWebScript />          
    </behavior>        
  </endpointBehaviors>
</behaviors>

<!--Increase WCF Performance-->
<bindings>
  <basicHttpBinding>
    <binding name="basicHttp" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
      <readerQuotas maxDepth="32" maxArrayLength="20000000" maxStringContentLength="20000000"/>              
    </binding>        
  </basicHttpBinding>
</bindings>

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

<services>
  <service name="MobileWCFService.Service1" behaviorConfiguration="ServiceBehavior">
    <endpoint address="" binding="webHttpBinding" contract="MobileWCFService.Service1" behaviorConfiguration="MobileService.webHttpBehavior" />        
  </service>
</services>

</system.serviceModel>

</configuration>

Solution

  • Can anyone confirm if changes I applied is valid or not and mark it has confirm answers?

     <system.serviceModel>
     <diagnostics performanceCounters="All"></diagnostics>
     <behaviors>
    
      <endpointBehaviors>
        <behavior name="MobileService.webHttpBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
    
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
    
          <!--Increase WCF Performance-->
          <serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>      
    
        </behavior>
    </serviceBehaviors>     
    </behaviors>
    
    <!--Increase WCF Performance-->
    <bindings>
      <webHttpBinding>
        <binding name="webHttp" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32" maxArrayLength="20000000" maxStringContentLength="20000000"/>
        </binding>
      </webHttpBinding> 
    </bindings>
    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    
    <services>
      <service name="MobileWCFService.Service1" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="webHttpBinding" contract="MobileWCFService.Service1" behaviorConfiguration="MobileService.webHttpBehavior" bindingConfiguration="webHttp" />        
      </service>
    </services>