ASMX Web Service slow first request

后端 未结 7 1781
迷失自我
迷失自我 2020-11-27 16:33

I have a bunch of .NET Webservices running in one IIS Application. These webservices are consumed by another IIS Application (frontend). The first call is pretty slow, about

相关标签:
7条回答
  • 2020-11-27 17:31

    After several hour of insane testing, i has been able to reduce the webservice first-run execution time to bare minimum from two host in the same IP class (below 300msec)....

    I experienced at first an initial delay of 2-3 sec at first webservice call, than any subsequent call from the same process to be very fast.

    The key for understanding the delay in my case was how client handles WEB PROXY !!

    This is my new binding in app.config file:

      <basicHttpBinding>
        <binding name="CreateContextSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
            receiveTimeout="01:00:00" sendTimeout="01:00:00" allowCookies="false"
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="16777216" maxBufferPoolSize="524288" maxReceivedMessageSize="16777216"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="false">
          <readerQuotas maxDepth="32" maxStringContentLength="1048576" maxArrayLength="16384"
              maxBytesPerRead="65536" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    

    The first webcall execution i suppose to be much slower because transport channel need to discover proxy configuration on initialization, in order to transparently connect to internet. This is usually not needed into intranet environment, thus i have changed these binding settings to avoid use the default proxy (automatically discovered from explorer settings):

    bypassProxyOnLocal="false"

    useDefaultWebProxy="false"

    The first-call connection time is now reduced by a large amount. Hope this helps.

    0 讨论(0)
提交回复
热议问题