简体   繁体   English

如何针对数百个并发连接优化/设计WCF?

[英]How to optimize/design WCF for hundreds of concurrent connections?

I want to develop a TCP server application using WCF which must be highly scalable and high performance server that can handle at least 200 concurrent connections: getting raw data via GPRS from my clients. 我想使用WCF开发一个TCP服务器应用程序,该应用程序必须是高度可伸缩的高性能服务器,并且可以处理至少200个并发连接:从客户端通过GPRS获取原始数据。

My data includes: 我的数据包括:

public class  RawData
{
    public string deviceID { get; set; }
    public string timeStamp { get; set; }
    public string messageType { get; set; }
    public string driverId { get; set; }
    public string senosrs { get; set; }
    public string startStatus { get; set; }
    public string x { get; set; }
    public string y { get; set; }
    public string course { get; set; }
    public string speed { get; set; }
    public string satCount { get; set; }
    public string signal { get; set; }
    public string message { get; set; }
}

And my questions are: 我的问题是:

  1. What is the best binding I can use? 我可以使用的最佳绑定是什么?
    I want to callback my client through connections made to our server. 我想通过与服务器的连接来回调客户端。

  2. How can I inspect wcf packet size? 如何检查WCF数据包大小?
    I have used this tutorial: http://zamd.net/2008/08/15/calculating-wcf-message-size/ my packet was 500 long! 我使用了本教程:http: //zamd.net/2008/08/15/calculating-wcf-message-size/我的数据包有500长! Is it in bytes or some other units? 是字节还是其他单位?

  3. Is WCF good enough for our situation? WCF是否足以应付我们的情况? We use gprs as DataNetwork. 我们使用gprs作为DataNetwork。

  4. Is there a need to implement routing service in this situation? 在这种情况下是否需要实施路由服务?

  5. What is best encoding for this problem? 解决此问题的最佳编码是什么? Best compression*speed. 最佳压缩*速度。

In answer to your questions: 在回答您的问题时:

  1. netTcpBinding - it is the most performant binding because it's basically raw sockets. netTcpBinding-它是性能最高的绑定,因为它基本上是原始套接字。 It also supports duplex . 它还支持双工

  2. If you need it as a one off and not for production monitoring, try configuring wcf tracing . 如果您需要一次性使用它而不是用于生产监视,请尝试配置wcf tracing This can log absolutely every message using the channel. 这绝对可以使用该通道记录每条消息。

  3. Kinda. 均田。 200 concurrent incoming connections (if your service is stateless ) is fairly easy (though probably requiring a small scale out ), but duplex wcf is complex at best, and importantly does not scale well - you either need a single service instance for all clients, or you need some persistent backing store to synchronize the client callback delegates (though this could be achieved efficiently with caching ). 200个并发传入连接(如果您的服务是无状态的非常 容易 (尽管可能需要小规模的扩展 ),但是双工 wcf充其量是复杂的,而且重要的是扩展性不佳 -您要么为所有客户端都需要一个服务实例,或者您需要一些持久的后备存储来同步客户端回调委托(尽管这可以通过cache有效地实现)。

  4. Unless you need to dynamically change the endpoint based on message content, translate between network protocols, etc, then no I can't see any need to user wcf-routing in this scenario, other than as a kind of load balancer. 除非您需要根据消息内容动态更改端点,在网络协议之间进行转换等,否则在这种情况下,除了作为一种负载平衡器之外,我看不到用户需要wcf-routing And if you do need to scale out, you would probably be better off using an actual network load balancer. 而且,如果确实需要扩展,则使用实际的网络负载平衡器可能会更好。

  5. netTcpBinding uses binary encoding by default as long as both ends of the channel are WCF. 只要通道的两端均为WCF,netTcpBinding默认就使用二进制编码。 This is the most optimized binding in WCF. 这是WCF中最优化的绑定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM