12

I'm trying to figure out how to profile a WCF service so I can identify any bottlenecks.
I have found a bit of information on line, but nothing that assumes no prior knowlege which is where I'm at.

What are recomended FREE tools?

- visual studio tools
- clrprofiler 

Here is information I found using vsperfcmd.exe to profile wcf service and according to this it is very simple, but I need to fill in the gaps on where to start. My assumptions are to copy VsPerfCLREnv and VsPerfCmd to the server that hosts my wcf service and perform some configuraiton steps that I'm not quite sure on. I'm also not quite sure how I would be able to see the call stack to evaluate the performance of each call.

clrprofiler seems a bit simpler. I assume I would copy clrprofiler.exe to the server, File->Profile Service and add the name and start/stop commands. (is this a friendly name or filename or the service display name?) I assume I would then run my tests against the service and I could see the call stack in clrprofiler. Does that sound correct?

[edit]
I'm not so interested in testing the network since this is on a test server, and this is a large wcf project with multiple devs on it and I am unable to make changes to the project for the sole purpose of monitoring the performance. I want to focus on the performance of the actual methods within it.

Any assistance on getting started is greatly appreciated.

earthling
  • 5,084
  • 9
  • 46
  • 90
  • You can also use "Perfmon" - www.codeproject.com/Articles/431917/WCF-Service-Performance-Monitoring-using-Perfmon – Milan Raval Aug 24 '12 at 12:41

5 Answers5

6

For WCF it is not enough to profile your code only as bunch of things happen on the channel stack (security, deserialization, formatting etc). A good way to visualise that is by using WCF Tracing at verbose level and then using the service trace viewer to see how long it is taking at each step of message processing. Read here on how to configure and use WCF tracing. This is the single most thing that has hepled me with diagnosing WCF issues.

Of course all other code profiling, DB profiling etc. are valid approach as well. You may even use a tool like SoapUI to test your network communication and client side performance overhead for a more end-to-end benchmark.

softveda
  • 10,858
  • 6
  • 42
  • 50
  • Yes. The way I handle asynchronous situations is 1) use random-pause on threads to make sure they are as efficient as possible, and then 2) do detailed message logging, merged across processes. I won't say studying message traces is easy, but it is effective. To me, it was surprising how fast an asynchronous message-passing protocol could be made to run. – Mike Dunlavey Oct 15 '10 at 00:39
  • thanks, I'm looking into the wcf tracing, but I'm not sure what to look for in the output. I'm primarily interested in the performance bottlenecks of the server vs network communication and client. I have a few target methods I want to analyze and see where improvements might be made. – earthling Oct 15 '10 at 18:50
  • 1
    If you open the trace in service trace viewer you will see all activities in a soap message processing. One of them is Execute User Code activity and see how much time is spend. This will give you idea how much time your code is taking to execute. But indeed if you need to drill down performance bottleneck in your code you have to use a profiler like the built-in Visual Studio profiler or the excellent nants performance profiler from RedGate. – softveda Oct 15 '10 at 21:13
  • That's what I figured. I'm trying to use the built-in profiler in VS2010, but as soon as I add the dll to the solution and mark it to instrument, I can no longer connect to the service. I can see on the server that the original dll is being backed up and a new copy put in place. – earthling Oct 15 '10 at 22:01
5

some things I've learned that someone might find helpful:

you cannot remote profile a service, even over your local network. The profiler must be running on the same machine as the service. (This actually took me quite a while to figure out. Maybe obvious to you, but it was never spelled out so I kept trying to do it)

Visual Studio didn't work for me to profile my WCF service. I was able to get a bit of help from the VS profiler team, but never came out of it with a working solution.

VS was slow to connect and disconnect the profiler and often instrumented my binaries and left them in a corrupted state.

.net binaries do not need to be instrumented since they contain the metadata of the methods which is odd that visual studio kept hosing my binaries trying to instrument them.

I also tried the VS standalone profiler but this is very complex to use and requires reboots of my server.

I ended up getting an internal profiler to work (after getting a private build from the team) so I'm not sure how many profilers out there are designed to work with a WCF service.

I actually set the profiler to watch the WAS service and then added my additional binaries to the profiler.

process explorer is useful when troubleshooting if the profiler is connected or not. Use it to look at inetinfo.exe environment

earthling
  • 5,084
  • 9
  • 46
  • 90
1

Can you run it under a debugger?

Can you stand a simple, old-fashioned, method that just works? Here's one.

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135
1

In addition to Mike's comments, you can use the built-in WCF performance counters to see a number of performance-related metrics and you can also see call times on a WCF trace. Once you know which operations are 'slow' it's usually easier to add some custom timing/logging code to those operations than using a general purpose profiler for something like this. This coming from someone who used to work on commercial profilers.

1

Tools you should look into: svctracelogviewer (and turn on tracing in both your service and clients). SoapUI for simulating load (and do analysis) and Fiddler, an excellent HTTP sniffer/diagnostics tool.

larsw
  • 3,790
  • 2
  • 25
  • 37
  • do you know how to use fiddler to monitor the wcf traffic? I'm using the wcf test client and don't get any info in fiddler. – earthling Oct 15 '10 at 19:01
  • Are you trying to use Fiddler against a service running on localhost? If so, look into the documentation what you need to do in order to get it to work. – larsw Oct 18 '10 at 13:22
  • The service is hosted on a test server. Now that I think about it, I'm not sure if this is possible with fiddler since the service is using tcp binding. Perhaps this is a question better left for a new thread. – earthling Oct 18 '10 at 17:00