UDP和TCP的优缺点比较
UDP vs TCP, how much faster is it?
http://*.com/questions/47903/udp-vs-tcp-how-much-faster-is-it
其中这段话是重点:
In some applications TCP is faster (better throughput) than UDP.
This is the case when doing lots of small writes relative to the MTU size. For example, I read an experiment in which a stream of 300 byte packets was being sent over Ethernet (1500 byte MTU) and TCP was 50% faster than UDP.
The reason is because TCP will try and buffer the data and fill a full network segment thus making more efficient use of the available bandwidth.
UDP on the other hand puts the packet on the wire immediately thus congesting the network with lots of small packets.
You probably shouldn't use UDP unless you have a very specific reason for doing so. Especially since you can give TCP the same sort of latency as UDP by disabling the Nagle algorithm (for example if you're transmitting real-time sensor data and you're not worried about congesting the network with lot's of small packets).
之前网上很多老文章都说关闭Nagle算法可以提高tcp通信性能,但是这应该看场景,如果客户端和服务端之前的小包消息频率不高,禁用nagle确实可以提高性能,但是反之:客户端服务端之间大部分时间都不是空闲而是不停收发消息,那么禁用nagle就降低性能了,如果是分布式服务器的应用场景,各个服务器之间用tcp通信,那么肯定不能禁用nagle,毕竟服务器压力较大时内部通信肯定极度频繁。
上一篇: 如何恢复Mysql数据库_MySQL
推荐阅读
-
C#获取Windows进程监听的TCP/UDP端口实例
-
Thinkphp模板标签if和eq的区别和比较实例分析,thinkphpeq
-
java 中String.equals和==的比较
-
java和c/c++ 数据类型长度的比较
-
Oracle In和exists not in和not exists的比较分析
-
为什么企业的应用系统中用 PHP 较少,而 Java,.NET 比较多?且IT经理似乎也更偏爱 Java 和 .NET ?
-
浅谈java的TCP和UDP编程(附实例讲解)
-
Hibernate 和 Mybatis 两者相比的优缺点 博客分类: SSH相关问题
-
深入浅析ArrayList 和 LinkedList的执行效率比较
-
传输层:剖析TCP和UDP协议 博客分类: 编程技术 网络协议网络应用应用服务器数据结构算法