aniban
aniban

Reputation: 709

How to apply performance configuration of WCF Service?

I have a connected WCF service, where the client configuration code is as below:

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;

On the service I have to configure some performance metrics like "relation deepness". How can I achieve this

Upvotes: 0

Views: 216

Answers (1)

Ding Peng
Ding Peng

Reputation: 3964

In WCF, you can use ServiceThrottlingBehavior to control WCF service performance.Using this behavior, you can fine-tune the performance of your Windows Communication Foundation application.

You can configure the values of these properties in the configuration file.

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

MaxConcurrentSessions:The maximum number of sessions a service host accepts. The default is 100 times the processor count. MaxConcurrentCalls:The upper limit of active messages in the service. The default is 16 times the processor count. MaxConcurrentInstances:The maximum number of InstanceContext objects in the service at one time. The default is the sum of the value of MaxConcurrentSessions and the value of MaxConcurrentCalls.

Windows Communication Foundation includes a large set of performance counters to help you gauge your application's performance.For more information about Performance Counters,Please refer to the following link:

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

Upvotes: 1

Related Questions