Perfmon showing 2.1 billion Instances of my WCF service
I've a WCF service that only about 15-20 clients are calling once every three minutes. I have PerfMon hooked up to it, and it's showing that I have 2147483698 Instances. That can't be, can it? I have maxConcurrentInstances="1000"
in the web.config and I'm using Multiple and PerSession Concurrency and InstanceMode respectively.
Edit More Info It is hosted in IIS 6 and is using an endpoint with WsHttpBinding:
<wsHttpBinding>
<binding name="WSHttpBinding_IWCFService"
maxBufferPoolSize="524288" maxReceivedMessageSize="1048576">
<readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Mes开发者_JAVA技巧sage">
<message clientCredentialType="Certificate" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
I have the Concurrency set to Multiple to because I want the Service Objects that are created to be able to handle more than one request at a time (ie multiple threads). I suppose I could make the InstanceMode Single, instead of PerSession, but would that make a difference here?
Edit Next Morning
So, I got on this morning and opened PerfMon, everything was flatlined at 0. I removed then created the the service in IIS, and also restarted the service by modifying the config. I then watched the Instances climb up to 1000 (the max in my config), at which point no more calls were coming in. I restarted the service again using the config, the number of Instances immediately dropped to 0, then 5 seconds later shot up to 2 billion again. I feel like part of this might just be that Perfmon doesn't know how to handle whatever madness is being thrown at it from the WCF service.The problem does seem to be that the channel is not always being closed properly in this particular version of the client and unfortunately, I can't get to them all at the moment. (I have another version of the client and service that has about 130 clients and this isn't a problem.) Is there some configuration I could set the service up as to help the problem? From what I've read, Single InstanceMode and Multiple Concurrency would be appropriate. It would solve the Instance problem and still give me asynchronous access, and I don't have to worry about cross threading issues because the service methods only update tables in a DB.
Thoughts?It sounds like the instances are not being disposed of correctly.
As a test you could append the following line of code to the implementation (in the service) of the method(s) being called by the clients, and see if the number of instances reduces:
OperationContext.Current.InstanceContext.
ReleaseServiceInstance();
You could also try switching to per-call and get rid of the concurrency stuff (I can't tell from your question if that option would be suitable for what you are doing)? Per call will create a separate instance for every method call that a client makes, and dispose of the instance afterwards.
There is a nice article that goes into all the details of instance management here, hopefully you will find something helpful there :)
精彩评论