问题描述
|
这怎么可能?我以为一种叫火而忘却的方法。该方法标记为单向。回调并发模式设置为Multiple,并且回调类的UseSychronizationContext设置为false。发送的数据不超过1KB,但是每次我同时发送大约30-40条小消息时,呼叫开始阻塞,最终其中一些超时。我已经以大约16000 /秒的速度对客户端->服务器调用进行了基准测试。当我尝试回拨给客户时,我每秒只能召集大约2个电话,而这是在OneWay电话中!
我对服务器的绑定配置如下所示:
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name=\"netNamedPipeBinding1\" receiveTimeout=\"23:00:00\" maxReceivedMessageSize=\"1048576\" maxBufferPoolSize=\"1048576\" maxConnections=\"500\">
<readerQuotas maxStringContentLength=\"99999999\" maxArrayLength=\"9999999\" maxBytesPerRead=\"999999\"/>
<security mode=\"None\"/>
</binding>
</netNamedPipeBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name=\"highThroughPut\">
<serviceThrottling maxConcurrentCalls=\"3000\" maxConcurrentInstances=\"3000\" maxConcurrentSessions=\"3000\"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name=\"OLII.Apps.Services.Data.DataServices.DataService\" behaviorConfiguration=\"highThroughPut\">
<endpoint bindingConfiguration=\"netNamedPipeBinding1\" address=\"net.pipe://localhost/DataListener\" binding=\"netNamedPipeBinding\" contract=\"OLLI.Apps.Services.ProxyClients.DataServerProxyClient.IDataListenerService\"/>
</service>
</services>
</system.serviceModel>
我的回调合同如下所示:
public interface IDataCallbackClient
{
[OperationContract(IsOneWay = true)]
void GetData(string file,int id);
}
我的客户端回调类如下所示:
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Multiple,UseSynchronizationContext = false)]
public class DataCallback : IDataCallbackClient
{
public void GetData(string file,int id)
{
//If I put Thread.Sleep(5000); When the server calls this method,the first few go through,and subsequent calls block. If I do a return statement here,all the calls go through really fast on the server side.
//Does some processing with file and id. It then goes back to server with data.
}
}
解决方法
我想到了。我有对我的服务的调用,该调用在此过程中阻塞了线程池并使之耗尽。我也在wcf服务内部调用线程池上的调用,这是一种不好的做法,因为这些方法是在线程池本身上调用的。看起来当您进行单向调用且线程池处于饥饿状态时,单向调用将超时,因为它没有要执行的线程。
谢谢