我有一个客户端-服务器应用程序,可以将市场数据从服务器传送到客户端。现在我遇到了两个问题: 1. 糟糕的回调性能。我达到了每秒最多 1.5K 回调 2. 当一个客户端开始“卡住”时 - 所有用户开始缓慢地检索数据(每秒 200 次回调)。这是我的服务器绑定:
<netTcpBinding>
<binding name="Net_Tcp_Binding" receiveTimeout="10:00:00" sendTimeout="00:00:30"
maxConnections="100">
<readerQuotas maxArrayLength="2147483647" />
<security mode="None" />
</binding>
</netTcpBinding>
和服务合同(95% 的数据使用 MarketDepthUpdate 和 EntityUpdate 交付):
namespace TradePlatform.DataDeliveryContracts.ServiceContracts
public interface ITradeServiceCallback
{
[OperationContract(IsOneWay = true)]
void InstrumentUpdate(InstrumentInfo instrument);
[OperationContract(IsOneWay = true)]
void OrderUpdate(OrderInfo order);
[OperationContract(IsOneWay = true)]
void OrderFailedUpdate(OrderFailInfo orderFailed);
[OperationContract(IsOneWay = true)]
void MyTradeUpdate(MyTradeInfo myTrade);
[OperationContract(IsOneWay = true)]
void TradeUpdate(TradeInfo trade);
[OperationContract(IsOneWay = true)]
void PortfolioUpdate(DSPortfolioInfo portfolio);
[OperationContract(IsOneWay = true)]
void PositionUpdate(PositionInfo position);
[OperationContract(IsOneWay = true)]
void MarketDepthUpdate(MarketDepthShortInfo marketDepth);
[OperationContract(IsOneWay = true)]
void DisconnectUser();
[OperationContract(IsOneWay = true)]
void UserUpdate(UserInfo user);
[OperationContract(IsOneWay = true)]
void FileUpdate(FileDataInfo file);
[OperationContract(IsOneWay = true)]
void SimulationDataUpdate(SimulationModeData simulationData);
[OperationContract(IsOneWay = true)]
void MessageUpdate(MessageId message, params object[] parameters);
[OperationContract(IsOneWay = true)]
void EntityUpdate(DataUpdateInfo updateInfo);
[OperationContract(IsOneWay = true)]
void Ping();
}
这是客户:
NetTcpBinding binding = new NetTcpBinding
{
Security = { Mode = SecurityMode.None },
MaxReceivedMessageSize = 2147483647
};
binding.ReaderQuotas = new XmlDictionaryReaderQuotas();
binding.ReaderQuotas.MaxArrayLength = 2147483647;
binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
binding.SendTimeout = new TimeSpan(0, 10, 0);