正如标题所说,我得到了一个定义了这种服务行为的WCF服务器:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
Run Code Online (Sandbox Code Playgroud)
我'使用命名管道绑定,我的客户端以这种方式连接:
NetNamedPipeBinding binding = new NetNamedPipeBinding();
const int maxValue = 0x40000000; // 1GB
binding.MaxBufferSize = maxValue;
binding.MaxReceivedMessageSize = maxValue;
binding.ReaderQuotas.MaxArrayLength = maxValue;
binding.ReaderQuotas.MaxBytesPerRead = maxValue;
binding.ReaderQuotas.MaxStringContentLength = maxValue;
// receive timeout acts like a general timeout
binding.ReceiveTimeout = TimeSpan.MaxValue;
binding.SendTimeout = TimeSpan.MaxValue;
ChannelFactory<IDatabaseSession> pipeFactory = new ChannelFactory<IDatabaseSession>(binding, new EndpointAddress("net.pipe://localhost/DatabaseService"));
IDatabaseSession dbSession = pipeFactory.CreateChannel()
Run Code Online (Sandbox Code Playgroud)
我开始的每个客户端执行上面的代码,并且对于每个客户端,CPU使用率提高了25%(实际上不是为5.客户端,但此时可执行的服务覆盖了整个CPU容量的近100%).
我正在寻找的是一种资源(网站/列表或只是你强大的知识)告诉我CreateChannel实际上做了什么(关于资源分配问题).
提示:即使没有实际进行通信,CPU使用率也会增加,只创建了Channel.
WCF 本身不太可能使用那么多资源,特别是因为您说即使没有通信也会发生这种情况。我的猜测是,这是服务的问题,而不是客户的问题。如果有的话,请查看服务构造函数。还可以尝试不同的InstanceContextMode和值ConcurrencyMode。
| 归档时间: |
|
| 查看次数: |
782 次 |
| 最近记录: |