Why is WCF Data Service performing better while Fiddler is running?
Asked Answered
C

3

8

I have a Windows application that is connecting to a WCF Data Service hosted on the same machine.

The first thing that occurs when the application starts is a query that returns 0 to 3 results. Here's the code:

var environments = ctx.Environments
.AddQueryOption("$filter", "Environment eq '" + ConfigurationManager.AppSettings["environment"] + "'")
.AddQueryOption("$expand", "Departments, SecurityGroups");

The very next thing I do is check if (environments.Count() == 0) which takes about 10 seconds to evaluate. It seems to be slowest the first time, but always takes more than 6 seconds. However, if I'm running Fiddler, I always get the results back immediately.

Why does running Fiddler make it faster?

Cirque answered 23/8, 2012 at 21:40 Comment(11)
Fiddler shouldnt have any side effects in your application. You should make investigation in some other places.Adiabatic
@DarthVader: I wouldn't think so either, and I especially wouldn't expect an increase in performance with it running. Nevertheless, it's happening.Cirque
why dont you debug your app and see what s causing the delay? and debug while fiddler is running. see the difference.Adiabatic
Debug my app...why didn't I think of that? No, seriously, that was about the most useless comment I have ever read. :) If you read my post you'll see that I've done that. Debugging the app is what revealed the difference. When environments.Count() evaluates with Fiddler running, it takes a fraction of the time that it takes when Fiddler is not running. Nothing else is different. I know it sounds flaky and that's why I posted here - to see if anyone else has experienced this or has an explanation.Cirque
How is the WCF Data Service hosted? In IIS? Cassini? IIS Express? I'm not sure why Fiddler would make a difference here, but the first thought that occurred to me is that it sounds like the time difference is related to spinning up the Web host. Can you check to see whether whatever you're hosting with is terminating in the longer scenarios?Merrymerryandrew
The WCF Data Service is running in another instance of VS2010 using Cassini. The first time I run and hit the Count() method it takes about 15 seconds, each time I run after that about 3 seconds. If Fiddler is running it takes roughly 0.4 seconds every time including the first. If I set a breakpoint on the line containing the call to Count(), run up to the breakpoint, then start Fiddler I get the 0.4s response. So as long as Fiddler is running when I call Count() it works great. Any advice?Cirque
Is fiddler set on streaming mode, or non-streaming? Not very likely, but it would affect the queuing on the server perhaps.Peg
Maybe there is some routing/DNS issue in your network. Using Fiddler means using a proxy which helps to avoid such issues.Giggle
Is the service running over https or http?Lechery
Your environments variable contains a stored expression tree that does not get evaluated until the Count property is accessed; this is normal deferred execution in Linq (because it implements functional programming concepts). Perhaps when you are running Fiddler you do something else also that causes the deferred execution to take place without you being aware of it. For example, in debugging, accessing any of the properties on the variable will cause the evaluation to take place, so when you look at Count, it appears to have run fast.Translocation
Have you tried setting a breakpoint in your web service code to see whether it's actually hitting it? Alternatively, if you can run SQL Profiler or something similar whilst your app is running you should see the queries come though and that will also tell you whether the lag is down to your database or not.Sufficiency
C
0

I appreciate all of the answers, but in the end it appears something was wrong with my VS 2010 develoment environment. I was able to deal with the slow first response by keeping Fiddler up and running, but after installing the Telerik suite of controls, my apps were taking nearly a minute to load a form while debugging. Suspecting this was related to the other issue, I installed VS 2012 and upgraded my projects and now everything works as expected.

Thanks again for your responses.

Cirque answered 26/11, 2012 at 15:42 Comment(0)
N
1

When you run fiddler it acts as a proxy for all the network calls, right? So probably this proxy responds faster than the real DNS host. What is the connection time out you've set in the binding configuration?

Natty answered 1/10, 2012 at 13:42 Comment(0)
J
0

As weismat suggest, it could be DNS issues. If you're using DNS names in your WCF URL, try using loopback ip instead (127.0.0.1) or your local IP.

Jer answered 27/9, 2012 at 13:38 Comment(0)
C
0

I appreciate all of the answers, but in the end it appears something was wrong with my VS 2010 develoment environment. I was able to deal with the slow first response by keeping Fiddler up and running, but after installing the Telerik suite of controls, my apps were taking nearly a minute to load a form while debugging. Suspecting this was related to the other issue, I installed VS 2012 and upgraded my projects and now everything works as expected.

Thanks again for your responses.

Cirque answered 26/11, 2012 at 15:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.