开发者

Should the first call to a WCF service take an extraordinary amount of time?

I've got a WCF service operation that just does a LINQ query on a SQL database, looking up 1 of 35 records that have a matching Guid (it's really as simple as it gets). When I call this method from a simple sandbox application, it comes back right away. However, when I have it running in a windows service, the first call to the method takes about 25 seconds (I take a timestamp before and after the call), and the second call (identical in every way to the first, made immediately after the first, just开发者_开发问答 for testing purposes) comes back right away.

The call takes place inside of a ThreadPool.QueueUserWorkItem delegate, with other actions being performed before and after it, and it's the only thing in the entire delegate that is at all delayed.

Does the delay make sense, or is something going wrong here?.

Update: I've confirmed that the problem isn't with the method itself. I called a completely different service method first, which had that delay, and the two calls to the original method just after both execute instantaneously. So it really is whatever the first call to the server is that's causing the problem.


In your case the first call will do 2 things:

  • JIT compile the service
  • Cache the query / data in the database server

This can explain the difference. On some systems the first call can timeout, while the second takes only one or two seconds.


One thing you might want to check is to see if your ASP.NET Worker Process that is hosting the service has an "idle timeout", it to me seems like it is the initial startup of ASP.net that might be causing your issue.


Have you tried enabling WCF tracing? Look for lags in the activity boundaries in the Process action activity.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜