We are using BasicHttpBinding
in a service and also we have set the concurrency mode to multiple and instance context mode to single like below
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single,
ConcurrencyMode =ConcurrencyMode.Multiple)]
public class Service1 : IService1
We have consumed this service in console through reference. We are having an issue that after some time we are seeing messages are pilled in IIS worker process.
For example -> In 1 minute , it is showing as only one thread in worker process in IIS but after some time we are seeing multiple request in IIS?
Could anyone help here like why after some time we are seeing messages queued up in IIS?
Below is binding in config
<binding name="BasicHttpBinding_Common"
closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false"
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single,
ConcurrencyMode =ConcurrencyMode.Multiple)]
Specifies the number of service instances available for handling calls that are contained in incoming messages: InstanceContextMode.Single -Only one InstanceContext object is used for all incoming calls and is not recycled subsequent to the calls. If a service object does not exist, one is created.
Specifies whether a service class supports single-threaded or multi-threaded modes of operation: ConcurrencyMode.Multiple - The service instance is multi-threaded. No synchronization guarantees are made. Because other threads can change your service object at any time, you must handle synchronization and state consistency at all times. It is your responsibility to guard your state with locks. The service implementation must be thread-safe to use this concurrency mode.
You may try adding UseSynchronizationContext = false
to your ServiceBehavior
. If that doesn't help you can try adding ReleaseServiceInstanceOnTransactionComplete=true
or false
to your ServiceBehavior
. I am not sure you can set to true if InstanceContextMode is multiple.
Since with ConcurrencyMode.Multiple No synchronization guarantees are made, and the default value for UseSynchronizationContext is true, it may be trying to process all calls on the same thread causing the queue.
There could also be some issue with the code you are using to call the service. Without seeing that we would not know.
It could just be taking a little time to spin up a thread for each call?? In your pic, the longest request is only 5.5 seconds. (I know that is long for a simple call.)
This might be insigtful as well: https://stackoverflow.com/a/4698956/2016162
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With