I'm using code examples from this article by Rick Strahl: http://www.west-wind.com/weblog/posts/324917.aspx to make async calls to a WCF service, which works just great.
My problem is this: First call to the WCF Service takes in the vicinity of 20ms, whereas the next takes around 1sec 20ms (doing exactly the same and receiving the exact same data). If I repeat the process the result is the same all the time. Every other call takes one second longer than the first.
I've tried setting the InstanceContextMode on my service:
[ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.PerSession)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public abstract class AjaxPostBack : IAjaxPostBack
I've also set timers in the methods being called on the service, and the result is the same e开发者_StackOverflowvery time (of course some ms differences, but nothing significant)
"JSON_Took":"00:00:00.0012939","Set_took":"00:00:00.0000274"
(These values - JSON_Took & Set_took - are timers in the code behind methods. So not the total time from client-server-client. It's simply to illustrate that it's not a problem with the actual code being timeconsuming)
Any ideas?
Let me know if you need more information.
---- Interesting Update ----
I downloaded IE9 RC and also Firefox (I've been testing in Chrome) My results from the different browsers:
Firefox: All calls are consistent at approx ~1s 20ms to 1s 30ms
Chrome: Every other call fires at the speed of Firefox, and the rest at 1 second quicker
IE9: All calls are consistent at virtually no time at all (~20ms)
Opera: Pretty much the same as IE9 (~30ms)
Is this a webkit-issue? (I'm using $.ajax to call the WCF)
I wouldn't depend on timings from the devserver. What happens if you deploy your service to IIS (or even IIS Express)? The VS2010 DevServer isn't as reliable of a server for timings and won't be a good indicator for production performance.
Here's a good article (although slightly dated) discussing the differences between IIS and the Visual Studio Web Server (aka Cassini).
Glad this helps!
精彩评论