Wednesday, March 11, 2009

.NET Web Services incredibly slow

Recently I was working with a customer that had very poor performance with an application using web services.
After studying the network trace, it seemed like every call would lag some 20 seconds between the time it goes out from one server and the time when it reaches the other server.
However, when doing the same call manually, we would not experience such a lag.

Traces within the application would not show any lag either.

Thankfully it is possible to activate traces at the .Net Framework level as explained here.

basically you can add the following to your machine.config file
      <source name="System.Net" tracemode="includehex" maxdatasize="1024">
          <add name="System.Net"/>
      <source name="System.Net.Sockets">
          <add name="System.Net"/>
      <source name="System.Net.Cache">
          <add name="System.Net"/>
      <add name="System.Net" value="Verbose"/>
      <add name="System.Net.Sockets" value="Verbose"/>
      <add name="System.Net.Cache" value="Verbose"/>
      <add name="System.Net"
    <trace autoflush="true"/>

Add it for example just before the </configuration> tag.
then restart your .NET application (if it is hosted in IIS, IISRESET)

You can also change network.log for C:\network.log.

This will give you great details about what .NET is doing after the call left your part of the code.

In my case, the application was running as a service under a specified user account which had an invalid proxy server defined in its Internet Options, thus every call was timing out trying to use that proxy before being successull with the DIRECT route.

Don't forget to remove it once you're done debugging :) 

No comments:

Post a Comment