【问题标题】:How to optimize/design WCF for hundreds of concurrent connections?如何为数百个并发连接优化/设计 WCF?
【发布时间】:2014-09-29 06:13:50
【问题描述】:

我想使用 WCF 开发一个 TCP 服务器应用程序,它必须是高度可扩展的高性能服务器,可以处理至少 200 个并发连接:通过 GPRS 从我的客户端获取原始数据。

我的数据包括:

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; }
}

我的问题是:

  1. 我可以使用的最佳绑定是什么?
    我想通过连接到我们的服务器来回调我的客户端。

  2. 如何检查 wcf 数据包大小?
    我用过这个教程: http://zamd.net/2008/08/15/calculating-wcf-message-size/ 我的包有500长!是字节还是其他单位?

  3. WCF 是否适合我们的情况?我们使用 gprs 作为数据网络。

  4. 这种情况是否需要实现路由服务?

  5. 什么是解决这个问题的最佳编码?最佳压缩*速度。

【问题讨论】:

  • 你们都在同一个网络上吗?
  • 是的,所有客户端在同一个网络,gprs APN

标签: c# wcf wcf-binding tcp-ip


【解决方案1】:

回答您的问题:

  1. netTcpBinding - 它是性能最高的绑定,因为它基本上是原始套接字。它还支持duplex

  2. 如果您需要它作为一次性而不是用于生产监控,请尝试配置wcf tracing。这可以绝对记录使用该通道的每条消息。

  3. 有点。 200 个并发传入连接(如果您的服务是 stateless)是 fairly easy(虽然可能需要一个小的 scale out),但是 duplex wcf 充其量是复杂的,重要的是 @987654328 @ - 您要么需要所有客户端的单个服务实例,要么需要一些持久的后备存储来同步客户端回调委托(尽管这可以通过 caching 有效实现)。

  4. 除非您需要根据消息内容动态更改端点,在网络协议之间进行转换等,否则在这种情况下我看不到任何需要用户wcf-routing,除了作为一种负载均衡器。如果确实需要向外扩展,最好使用实际的网络负载均衡器。

  5. netTcpBinding 默认使用二进制编码,只要通道两端都是 WCF。这是 WCF 中最多的 optimized 绑定。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-02
    • 1970-01-01
    • 1970-01-01
    • 2018-08-01
    • 2012-04-24
    • 2012-11-03
    • 1970-01-01
    相关资源
    最近更新 更多