1

Possible Duplicate:
ASMX Web Service slow first request

We are writing a full .NET/WPF/C# application using Microsoft's System.Web.Services.WebService class. We are seeing strange performance behaviours. I am no expert in the lower level workings of the class, so apologies if this is trivial.

The issue is the first webmethod call is very slow, and I'm not sure why or how to fix it. The performance test code does something like this:

ServiceSoapClient Svr = new ServiceSoapClient("ServiceSoap", url);

DateTime start = DateTime.Now;
bool connect = Svr.attemptConnection(true);
end = DateTime.Now;
Debug.WriteLine("server call: " + (end - start));

start = DateTime.Now;
connect = Svr.attemptConnection(true);
end = DateTime.Now;
Debug.WriteLine("server call 2: " + (end - start));

start = DateTime.Now;
connect = Svr.attemptConnection(true);
end = DateTime.Now;
Debug.WriteLine("server call 3: " + (end - start));

In this performance example, the first "server call" takes approximately 3 seconds! "server call 2", "server call 2", and any number after that take approximately 0.1 seconds. All "Svr.attemptConnection(true)" does is to take passed boolean and return it as is.

I am still doing research on this, but any help would be much appreciated. Why is the first call so slow and how can we change this?

Thx

Community
  • 1
  • 1
Nate
  • 41
  • 2
  • 7
    Is this IIS? Perhaps this is cold start of a worker process to handle your call. – Adam Houldsworth Aug 24 '11 at 14:04
  • If you call from a different computer first then is the first call still slows on the second computer. That would indicate if the delay was on the client or server end. – paparazzo Aug 24 '11 at 14:13
  • yes, this is IIS 6 running on Windows Server 2003 Web Edition. There is no special worker process that executes this call. – Nate Aug 24 '11 at 14:30
  • thanks James, it does look like a duplicate. – Nate Aug 24 '11 at 14:38
  • Looks like a compile to byte code on first call with each subsequent call able to leverage the already compiled code. We see this quite often in performance testing. If this only happens once after the server/service is rebooted you should be fine. Just tell the end users that the squirrels are slow in the morning when they first wake up ;) – James Pulley Aug 24 '11 at 14:42
  • I tired everything said in [ASMX Web Service slow first request](http://stackoverflow.com/questions/784918/asmx-web-service-slow-first-request) without success, I still have the performance issue. – Nate Aug 24 '11 at 15:47

0 Answers0