How to get started with WCF Performance profiling

2019-01-24 05:00发布

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.

5条回答
ら.Afraid
2楼-- · 2019-01-24 05:32

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.

查看更多
倾城 Initia
3楼-- · 2019-01-24 05:33

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.

查看更多
姐就是有狂的资本
4楼-- · 2019-01-24 05:36

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.

查看更多
趁早两清
5楼-- · 2019-01-24 05:49

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

查看更多
可以哭但决不认输i
6楼-- · 2019-01-24 05:49

Can you run it under a debugger?

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

查看更多
登录 后发表回答