0

I have microservices, all are deployed in IIS. When I trigger request to those services taking 2k+ millisecond for each and every request. But, If I run those services using IIS Express and self hosted way(for wcf) I got response in 100 millisecond. Verified time using Postman.

Already tried some basic verification like , App Pool recycling (1740 minutes) StartMode(Always Running) PreEnabled(True) AppInitialization also set.

Can anyone suggest solution for this problem?

WCF implementation here,

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <connectionStrings>

  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.7.2" />
    <httpRuntime targetFramework="4.6.1" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="CalculationService">
        <endpoint address="rest" behaviorConfiguration="CalculationServiceAspNetAjaxBehavior" bindingConfiguration="webHttpBinding_IMyService" binding="webHttpBinding" contract="ICalculationService" />
        <endpoint address="" binding="basicHttpBinding" contract="ICalculationService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://ip/CalculationService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <webHttpBinding>
        <binding name="webHttpBinding_IMyService" maxBufferPoolSize="524288000" maxBufferSize="524288000" maxReceivedMessageSize="524288000">
          <readerQuotas maxDepth="524288000" maxStringContentLength="524288000" maxArrayLength="524288000" maxBytesPerRead="524288000" maxNameTableCharCount="524288000" />
          <security mode="None" />
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="CalculationService.CalculationServiceAspNetAjaxBehavior">
          <webHttp defaultOutgoingResponseFormat="Json" helpEnabled="true" faultExceptionEnabled="true" />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="http" />
      <add binding="webHttpBinding" scheme="http" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <directoryBrowse enabled="true" />
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

  • Are there any SQL Server operations in your WCF service project? Generally, this kind of WCF service hosted in IIS takes more time to query the data when it is called,especially the first time. Besides, on my side, for verifying this measured result, I compared the time consumption that calls the REST WCF service hosted in console application and IIS. The result is literally the same, with no sharp difference. – Abraham Qian Jan 01 '20 at 09:00
  • Which type of operation contract mainly exists in your web service? computational or I/O operation(read/write a file, SQL server)? At last, please refer to the below link about accelerating the first-time access to the web application in IIS. https://stackoverflow.com/questions/13386471/fixing-slow-initial-load-for-iis – Abraham Qian Jan 01 '20 at 09:00
  • Hi @AbrahamQian, Thanks for your message. I am using computational only. First request takes more time is not a problem for me but, consecutive requests also taking similar time when deployed in IIS. If I run the code using self hosting way first response is bit slower and consecutive responses are super fast. – Venkatesh Kumar Jan 02 '20 at 10:12
  • Are you using WCF with Rest API style, created by `Webhttpbinding`? Maybe the WCF project deployed to IIS can be simplified. Please post your WCF project structure and I will try to test it. – Abraham Qian Jan 03 '20 at 09:37
  • Hi @AbrahamQian, Please find above the wcf configuration. – Venkatesh Kumar Jan 07 '20 at 06:50
  • It looks like your project still contains read/write operations to the database. And services are published as soap and rest API style. Which style of service does your client mainly consume? If it's a rest API, I suggest you delete all the Settings for the soap message format except maxReceivedMessageSize="524288000". – Abraham Qian Jan 07 '20 at 07:51
  • HI @AbrahamQian, We are using rest API style end point only. Still I didnt find any improvement after implementing the changes you mentioned - "If it's a rest API, I suggest you delete all the Settings for the soap message format except maxReceivedMessageSize" . – Venkatesh Kumar Jan 07 '20 at 10:17

0 Answers0