如何应用WCF服务的性能配置?

问题描述 投票:0回答:1

我有一个已连接的WCF服务,其中客户端配置代码如下:

var method = typeof(XmlSerializer).GetMethod("set_Mode", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
method.Invoke(null, new object[] { 1 });
BasicHttpsBinding httpBd = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport);
httpBd.MaxReceivedMessageSize = Int32.MaxValue;
httpBd.MaxBufferSize = Int32.MaxValue;
var client = new FindServicePortTypeClient(httpBd,
new EndpointAddress(_settings.Url));

var bd = client.Endpoint.Binding as BasicHttpsBinding;
bd.Security.Mode = BasicHttpsSecurityMode.Transport;
bd.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

client.ClientCredentials.UserName.UserName = _settings.User;
client.ClientCredentials.UserName.Password = _settings.Password;

在服务上,我必须配置一些性能指标,例如“关系深度”。我该如何实现

performance wcf configuration metrics throttling
1个回答
0
投票
在WCF中,您可以使用ServiceThrottlingBehavior来控制WCF服务性能。使用此行为,您可以微调Windows Communication Foundation应用程序的性能。

您可以在配置文件中配置这些属性的值。

<behaviors> <serviceBehaviors> <behavior name="Throttled"> <serviceThrottling maxConcurrentCalls="1" maxConcurrentSessions="1" maxConcurrentInstances="1" /> <serviceMetadata httpGetEnabled="true" httpGetUrl="" /> </behavior> </serviceBehaviors> </behaviors>

MaxConcurrentSessions:服务主机接受的最大会话数。默认值为处理器计数的100倍。MaxConcurrentCalls:服务中活动消息的上限。默认值为处理器计数的16倍。MaxConcurrentInstances:一次最多服务中InstanceContext对象的数量。默认值为MaxConcurrentSessions的值和MaxConcurrentCalls的值之和。

Windows Communication Foundation包含大量性能计数器,可帮助您评估应用程序的性能。有关性能计数器的更多信息,请参考以下链接:

https://docs.microsoft.com/en-us/dotnet/framework/wcf/diagnostics/performance-counters/

© www.soinside.com 2019 - 2024. All rights reserved.