原文:http://fusesource.com/docs/broker/5.4/tuning/GenTuning-Protocols.html#GenTuning-Protocols-Compress
标签:ActiveMQ 性能优化
Overview:协议优化可以在不同的协议层,如下所示
TCP transport(TCP传输):一般而言,通过增加TCP层的Buffer大小是可以改善TCP层的性能。
- Socket buffer size -默认的TCP Socket buffer的大小是64KB。这个设计只是适合最初的TCP协议,这个大小对于当初的猫(modern)网络而言是最合适的。下面的经验可以用于估算出合适的TCP socket buffer的大小。
Buffer size = BandWidth(带宽) X Round-Trip-Time(往返时延)
Round-Trip-Time指的是从TCP发送一个包到接收到这个包的确认的时长(Ping的时间),典型的做法是加倍Socket buffer的大小到128K。
如例:
tcp://hostA:61617?socketBufferSize=131072
更多请参照Wikipedia的文章 Network Improvement.
- I/O buffer size—I/O buffer是用来缓存TCP和它上层协议(就像OpenWire)之间的数据的。默认的I/O buffer的大小是8K,你可以加倍这个大小去获得更好的性能。如例:
tcp://hostA:61617?ioBufferSize=16384
OpenWire protocol:OpenWire协议开放了几个选项进行来调整性能,如表格1.1所示
Table 1.1. OpenWire Parameters Affecting Performance
cacheEnabledtruecacheSize1024tcpNoDelayEnabledfalsetrue, disable the Nagles algorithm. The Nagles algorithm was devised to avoid sending tiny TCP packets containing only one or two bytes of data; for example, when TCP is used with the Telnet protocol. If you disable the Nagles algorithm, packets can be sent more promptly, but there is a risk that the number of very small packets will increase.tightEncodingEnabledtruetrue, implement a more compact encoding of basic data types. This results in smaller messages and better network performance, but comes at a cost of more calculation and demands made on CPU time. A trade off is therefore required: you need to determine whether the network or the CPU is the main factor that limits performance.