TCP可靠性与Udp的负担,严重的,高性能服务器 [英] Tcp Reliability versus Udp Burdens for serious, high-performance server

查看:527
本文介绍了TCP可靠性与Udp的负担,严重的,高性能服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

速度,优化和可扩展性的UDP和TCP协议之间的典型对比。 TCP吹捧可靠性的一点点额外的开销的缺点,而且速度优良。一旦TCP套接字是实例化,保持套接字打开需要的部分的开销。但相对于UDP,该协议实际上有更多的开销,人们经常描述的负担?我还听说,有可扩展性问题,使用TCP ...但互联网(网页/服务器)运行在TCP - 那么它是什么有关TCP抑制的可扩展性?

Speed, optimization, and scalability are the typical comparisons between the Udp and Tcp protocols. Tcp touts reliability with the disadvantage of a little extra overhead, but speed is good to excellent. Once a Tcp socket is instanced, keeping the socket open requires some overhead. But compared to the oft described burdens of Udp, which protocol actually has more overhead?. I've also heard that there are scalability issues with Tcp...yet the Internet (Web pages/servers) runs on Tcp - so what is it about Tcp that inhibits scalability?

好了...所以UDP不需要保持连接开放的开销。但是,它要求你写的额外的方法,以确保所有的数据包到达那里,希望能在您希望收到的订单。如果一个数据包不能完全接受,那么你必须告诉客户端或服务器重新发送。而且你还必须保持某种形式的部分数据包信息采集,重建部分消息,并检查一个完整的消息之前的消息,终于可以被处理。更何况如果消息的第二部分永远不会使它,你要么说重新发送整个事情,或者重新发送我们缺少,或任何部分。

Okay...so Udp doesn't require that overhead of keeping a connection open. But, it requires that you write extra methods to ensure all of the packet gets there, hopefully in the order that you want it received. If a packet isn't received in full, then you have to tell the client or server to resend. And you also have to keep some sort of message collection for partial packets, rebuild the partial messages, and check for a complete message before the message can finally be processed. Not to mention if the second part of a message never makes it, you have to either say resend the entire thing, or resend the part we are missing, or whatever.

基本上,我的问题是:

  1. 为什么我会选择UDP,TCP上的严重,有消息增加了额外开销的高性能服务器 检查和手动ACK与源源不断的开销?
  2. 如果TCP是魔兽世界的喜欢够好,为什么不是TCP更广泛接受的的协议,用于游戏服务器?
  1. Why would I choose Udp over Tcp for a serious, high-performance server with the added "overhead" of message checking and manual ACK versus the "overhead" of a continuous stream?
  2. If Tcp is good enough for the likes of World of Warcraft, why isn't Tcp more widely accepted as the protocol to use for a game server?

注:我不反对执行UDP,选择一台服务器。我们正在使用C#.Net的3.5框架。所以,我也将是处理使用UDP的负担的兴趣的最佳实践。我还使用了异步方法在插槽的水平,而不是使用的TcpListener,TcpClient的,等等等等。

Note: I am not opposed to implementing Udp options for a server. We are using C# on .Net 3.5 framework. So I would also be interested in the best practices for dealing with Udp burdens. I am also using the asynchronous methods at the socket level rather than using TcpListener, TcpClient, etc. etc.

推荐答案

嗯,我会建议读了一些。有很多地方看亲的和反对的TCP主场迎战UDP,反之亦然,这里有几个:

Well, I would recommend reading up some more. There are plenty places to look at the pro's and con's of TCP vs. UDP and vice versa, here are a few:

  • What Are The Advantages Of Using TCP Over UDP?
  • When should I use UDP instead of TCP?
  • TCP and UDP
  • What are the advantages of UDP over TCP?

不过,这种联系可能你最感兴趣,因为它是直接对网络游戏编程:

However, this link may interest you the most, as it is directly about networked game programming:

如果我要引用一些小的:

If I were to quote something small:

的决定似乎是pretty的明确的话,   TCP做我们想要的一切和它的   超级好用,而UDP是一个巨大的   屁股痛了才code   从头开始一切自己。所以   很明显,我们只需要使用TCP吧?

The decision seems pretty clear then, TCP does everything we want and its super easy to use, while UDP is a huge pain in the ass and we have to code everything ourselves from scratch. So obviously we just use TCP right?

错误。

使用TCP是最坏的可能   错误,你可以开发一个时许   网络游戏!要理解为什么,你   需要查看TCP实际上是在做   上述IP使一切看起来那么   简单!

Using TCP is the worst possible mistake you can make when developing a networked game! To understand why, you need to see what TCP is actually doing above IP to make everything look so simple!

我还是建议做自己的研究,对此事虽然并确保的协议,该协议服需要在这一天结束。这是说,它似乎是,大多数游戏都使用UDP为他们的数据的情况。凡是不断更新整个国家并不需要保证数据包传输的开销。

I still recommend doing your own research on the matter though, and make sure which of the protocols suits your needs at the end of the day. This being said, it does seem to be the case that majority of games use UDP for their data. Anything that updates the entire state continuously does not need the overhead of guaranteed packet delivery.

这篇关于TCP可靠性与Udp的负担,严重的,高性能服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆