gpt4 book ai didi

.net - 如何在 IIS 中使用性能计数器和 WCF 服务?

转载 作者:行者123 更新时间:2023-12-03 03:22:37 25 4
gpt4 key购买 nike

嗨,

我在 IIS7 中有一个 WCF 服务,它通过 TCP(WAS) 与 winform 应用程序进行通信,现在我需要监视性能。

我已将其添加到 web.config 文件中:

  <system.serviceModel>
<diagnostics performanceCounters="All" />

打开性能监视器后,我使用 winform 运行了一些测试,以确保该服务已激活。

然后,我打开性能监视器(实时),右键单击并添加计数器。我展开 ServiceModelService 4.0.0.0 并选择“调用”和“调用持续时间”,还选择“所选对象实例”列表框中所述的服务 (svc),然后单击“添加”按钮。

在 ServiceModelOperation 4.0.0.0 下选择“调用”和“调用持续时间”时,没有可供选择的实例或操作? ServiceModelEndpoint 4.0.0.0 也是如此吗?

单击“确定”时,将添加两个计数器 (ServiceModelService)。

然后,我单击“解冻显示”并启动进行几次调用的 winform 应用程序,但是我在性能监视器中看不到任何内容。我尝试右键单击其中一个性能计数器并选择“缩放所选计数器”,但这没有任何作用?

目标只是查看 WCF 服务的执行情况(速度、持续时间、数量、连接等),并且检查各个操作也很棒。

请帮忙!

注意:这是我尝试遵循的文章:http://dkochnev.blogspot.com/2011/06/wcf-framework-40-monitoring-service.html

最佳答案

看起来这可能是性能计数器工作方式的错误(或设计功能)。经过一番探索后,我在 MSDN forums 上找到了这个:

I have the same problem. It appears that Microsoft truncates the tail end of the operation name when naming the counter instance. They replace the truncated part with some sort of 2-digit base-10 magic number. I'm guessing it's a hash, but who knows how it's actually generated. The rub is that this number is not guaranteed unique and can cause collisions in counter names. If such a collision happens, it seems to cause all Endpoint and Operation counters to vanish (at least for me).

I have two methods named UpdateMarkupChunk and UpdateMarkupCancel. If I comment out one or the other so that the other doesn't exist, they both resolve to UpdateMarkupC53 in the counter instance name. When I comment them both in, none of the counter instances appear for ServiceModelEndpoint or ServiceModelOperation.

Can you suggest a workaround for this, Microsoft? I have a production service already in place that I would like to monitor, and changing the operation names is not an option.

微软的回应是:

You are correct. And this behaviour is by design. There is a limit on the length of a performance counter instance's name.

Operation performance counters are found under the ServiceModelOperation 4.0.0.0 performance object when viewing with the Performance Monitor (Perfmon.exe). Each operation has an individual instance. That is, if a given contract has 10 operations, 10 operation counter instances are associated with that contract. The object instances are named using the following pattern:

(ServiceName).(ContractName).(OperationName)@(first endpoint listener address)

When a Windows Communication Foundation (WCF) counter instance name exceeds the maximum length, WCF replaces a portion of the instance name with a hash value.

因此,似乎由于最大名称限制,当只有两位数的哈希后缀时,哈希冲突的可能性很大,并且当计数器的两个实例具有相同的名称时,它会删除​​整个计数器这实际上是不可能的。

这有点令人沮丧。因此,除非微软修复这个问题(长哈希值,或者通过性能计数器更好地处理冲突),或者提供合适的解决方法,否则我们就是盲目工作。

关于.net - 如何在 IIS 中使用性能计数器和 WCF 服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9518223/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com