WCF:maxConcurrentCalls已经用尽了

Oli*_*ROT 6 performance wcf

我正在对在某个时刻挂起的WCF服务进行故障排除.服务行为如下:

[ServiceBehavior( InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple )]
Run Code Online (Sandbox Code Playgroud)

限制参数是:

<serviceThrottling maxConcurrentCalls="50" maxConcurrentSessions="50" maxConcurrentInstances="50" />
Run Code Online (Sandbox Code Playgroud)

以下是从挂起转储中获取的服务状态:

0:000> !mdt 0000000000c9f270 -r
0000000000c9f270 (System.ServiceModel.Dispatcher.ServiceThrottle)
   calls:0000000000c9f3d8 (System.ServiceModel.Dispatcher.FlowThrottle)
      capacity:0x32 (System.Int32)
      count:0x32 (System.Int32)
      mutex:0000000000c9f418 (System.Object)
         <NO FIELDS>
      release:0000000000c9f398 (System.Threading.WaitCallback)
         _target:0000000000c9f270 (System.ServiceModel.Dispatcher.ServiceThrottle)
            <RECURSIVE>
         _methodBase:NULL (System.Reflection.MethodBase)
         _methodPtr:0000064273dddf30 (System.IntPtr)
         _methodPtrAux:0000000000000000 (System.IntPtr)
         _invocationList:NULL (System.Object)
         _invocationCount:0000000000000000 (System.IntPtr)
         <NO FIELDS>
      waiters:0000000000c9f430 (System.Collections.Generic.Queue`1[[System.Object, mscorlib]])
         _array:0000000028d73e70 (System.Object[], Elements: 16)
         _head:0x1 (System.Int32)
         _tail:0xA (System.Int32)
         _size:0x9 (System.Int32)
         _version:0x22 (System.Int32)
         _syncRoot:NULL (System.Object)
      propertyName:0000000000c9f2b8 (System.String: "MaxConcurrentCalls")
      configName:0000000000c9f358 (System.String: "maxConcurrentCalls")
   sessions:0000000000c9f508 (System.ServiceModel.Dispatcher.FlowThrottle)
      capacity:0x32 (System.Int32)
      count:0x9 (System.Int32)

....

   instanceContexts:000000000105ffc8 (System.ServiceModel.Dispatcher.FlowThrottle)
      capacity:0x32 (System.Int32)
      count:0x32 (System.Int32)
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,maxConcurrentCalls已经耗尽,而会话数只有9.我想知道这是否可能是由于客户端代码中有关代理使用情况的故障,例如糟糕的异常处理?

鉴于服务的内存转储,有没有办法找到客户端IP地址?

TIA.

小智 2

找到了问题的根源。由于服务代码出现死锁,MaxConcurrentCalls 已耗尽。我们正在使用 c# lock 关键字,似乎有时当受锁保护的代码中发生奇怪的事情时,锁不会被释放......

不管怎样,感谢所有为这个话题做出贡献的人。