简体   繁体   中英

WCF service binding settings

We have a WCF web service which is used fairly regularly on our site. Occasionally, we get a large amount of users to our site. I don't want the service to timeout and am OK if it runs for over a minute if needs be. I also want to set the amount of concurrent requests that can happen on the service.

I see there are lots of timeout settings that can be set on the binding - all with a default value of 1 minute. For a situation like this what timeout settings should I set and where can I set the max number of concurrent requests?

Thanks

In order to implement a scalable WCF web service, you need to, among other things, configure the proper concurrency mode, instancing model and service throttling setting.

Concurrency refers to the number of threads executing at the same time in a service instance. By default, one thread executes, but if clients call multiple methods and each takes more than a short amount of time, you might want to use multiple threads.

Instancing refers to the lifetime of a service instance. You can control instancing by setting the InstanceContextMode property of the ServiceBehavior attribute. There are three possible values for this property:

  • PerSession . The WCF runtime creates a new service object the first time a client calls the service. It keeps the object active for subsequent calls by the client. The runtime releases the object when the session ends. This is the default value for this property.
  • PerCall . The WCF runtime creates a new service object each time a client calls the service. It releases the object after the call.
  • Single . The WCF runtime creates a new service object the first time a client calls the service. It keeps the object active for subsequent calls by any client.

The service throttling configuration controls the max number of instances, session and/or calls based on the instancing and concurrency mode settings.

<behaviors>
  <serviceBehaviors>
    <behavior  name="Throttled">
      <serviceThrottling 
        maxConcurrentCalls="x" 
        maxConcurrentSessions="x" 
        maxConcurrentInstances="x"
      />

The following articles should help you evaluate the various settings and choose the option best suited for your scenario.

http://msdn.microsoft.com/en-us/library/ff183865.aspx
http://msdn.microsoft.com/en-us/library/ms731379%28v=vs.110%29.aspx
http://msdn.microsoft.com/en-us/library/vstudio/ms735114%28v=vs.100%29.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM