C# Web服务性能
我有两个负载平衡的应用服务器在IIS7上运行。我需要检查每个服务器有多少个webservice调用。我还需要在一个特定的实例中检查这一点。在.net中是否有一些东西可以与服务器进行通信,并在特定实例上为我提供快照。C# Web服务性能,c#,.net,C#,.net,我有两个负载平衡的应用服务器在IIS7上运行。我需要检查每个服务器有多少个webservice调用。我还需要在一个特定的实例中检查这一点。在.net中是否有一些东西可以与服务器进行通信,并在特定实例上为我提供快照。 谢谢您可以使用Perfmon添加有关呼叫数的统计信息。一旦你这样做,你也可以添加时间数据以及。。。然后,您可以在本地框上使用Perfmon,或使用任意数量的工具远程连接到它 很抱歉,我不能向您指出具体内容--我只看到它完成了,没有亲自完成:),但我认为它非常简单。和一些示例代码,展示
谢谢您可以使用Perfmon添加有关呼叫数的统计信息。一旦你这样做,你也可以添加时间数据以及。。。然后,您可以在本地框上使用Perfmon,或使用任意数量的工具远程连接到它
很抱歉,我不能向您指出具体内容--我只看到它完成了,没有亲自完成:),但我认为它非常简单。和一些示例代码,展示了如何实现性能计数器:
using System;
using System.Configuration;
using System.Diagnostics;
namespace TEST
{
// sample implementation
public static class PerformanceHelper
{
// update a performance counter value
public static void UpdateCounter(string WebMethodName, int count)
{
// to be able to turn the monitoring on or off
if (ConfigurationManager.AppSettings["PerformanceMonitor"].ToUpper() == "TRUE")
{
PerformanceCounter counter;
if (!PerformanceCounterCategory.Exists("SAMPLE"))
{
CounterCreationDataCollection listCounters = new CounterCreationDataCollection();
CounterCreationData newCounter = new CounterCreationData(WebMethodName, WebMethodName, PerformanceCounterType.NumberOfItems64);
listCounters.Add(newCounter);
PerformanceCounterCategory.Create("SAMPLE", "DESCRIPTION", new PerformanceCounterCategoryType(), listCounters);
}
else
{
if (!PerformanceCounterCategory.CounterExists(WebMethodName, "SAMPLE"))
{
CounterCreationDataCollection rebuildCounterList = new CounterCreationDataCollection();
CounterCreationData newCounter = new CounterCreationData(WebMethodName, WebMethodName, PerformanceCounterType.NumberOfItems64);
rebuildCounterList.Add(newCounter);
PerformanceCounterCategory category = new PerformanceCounterCategory("SAMPLE");
foreach (var item in category.GetCounters())
{
CounterCreationData existingCounter = new CounterCreationData(item.CounterName, item.CounterName, item.CounterType);
rebuildCounterList.Add(existingCounter);
}
PerformanceCounterCategory.Delete("SAMPLE");
PerformanceCounterCategory.Create("SAMPLE", "DESCRIPTION", new PerformanceCounterCategoryType(), rebuildCounterList);
}
}
counter = new PerformanceCounter("SAMPLE", WebMethodName, false);
if (count == -1)
counter.IncrementBy(-1);
else
counter.IncrementBy(count);
}
}
}
}
由…制成或制成?如果它是“made to”,那么Jeff的建议会起作用,就像抓取IIS日志一样,但是如果它是“made from”您将需要提出另一个方案,如记录所有调用或发布您自己的自定义性能计数器。感谢stackuser,但这并不能解决我需要从两台服务器获取统计数据的问题。它肯定会为您提供修改web服务以收集所需信息的构建块。在性能监视器中,您可以将有关exmample的cpu的负载数据组合在一起,并将其与您自己的测量值组合在一起。上面的代码只是web服务部件上的一个示例。