13.5 小结
13.5 Summary
13.5 小结
?
In general, message performance can be ?improved by asking ActiveMQ to do ?less.
Consider the overhead of persisting ?messages and the cost of ?transporting both
messages and ?client acknowledgments ?over the ?wire. If ?possible, use reliable
messaging or ?batching of ?messages in ?transactions to ?reduce the ?overhead of
passing ?a receipt ?from the ?broker to ?the producer ?that it ?has received ?a
message. You can reduce the amount ?of work the ActiveMQ broker does ?by setting
suitable ?memory limits ?(more is ?better) and ?deciding whether ?producer flow
control is suitable for your application. The message consumer has to work twice
as hard as the message ?producer, so optimizing delivery with ?a MessageListener
and using ?straight-through message ?processing together ?with an acknowledgment
mode or transactions ?that allow acknowledgments ?to be batched ?can reduce this
load.
?
通常,可以通过减少ActiveMQ的一些额外操作来改善消息程序的性能.由持久化消息而代理的
额外开销以及通过网络传输消息和客户端的消息确认带来的开销即可见一斑.如果可能的话,
使用可靠消息或者使用事务来进行消息分区,以便减少因代理传递消息回执给消息生产者告知
代理已经收到消息了而代来的额外开销.你可以设置适合的内存限制(越多越好)以及确定
消息生产者流控制是否适合你的程序,从而减少ActiveMQ代理要做的工作.消息消费者的工作量
是消息生产者的2倍,因而使用MessageListener来优化消息分发同时设置合适消息确认模式或
使用事务来批量发送消息确认从而使用直通消息处理模式可以减轻消息消费者的负担.
?
In ?this ?chapter ?you ?learned ?about ?some ?general ?principles ?for improving
performance ?with any ?JMS-based application. ?We also ?dove into ?some of ?the
internals ?of ?ActiveMQ ?and ?how ?changes ?to ?the ?configuration ?can increase
performance. We learned when and when ?not to use those options, and ?their side
effects. We also brought the different aspects of performance tuning together in
an example real-time data feed application.
?
本章中你已经了解了一些基本的优基于JMS程序的通用原则.另外,本章内容还深入到了ActiveMQ
的内部并了解了如何修改配置才能提升程序性能,并了解了合适该用合适不该用这些选项,已经
使用这些选项的副作用.最后,我们还将不同的性能调优方法应用到了一个实时的数据源示例程序
中.
?
You should now have a better understanding of where the performance ?bottlenecks
may occur when using ActiveMQ, and when and why to alleviate them. We’ve ?shown
how ?to ?tune your ?message ?producers and ?message ?consumers, as ?well ?as the
configuration parameters and their impact on your application architecture. ?You
should be able to make the right architectural decisions for your application to
help performance, and ?have a good ?understanding of the ?downsides in terms ?of
guaranteeing delivery and how ActiveMQ can be used to mitigate them.
?
至此,你应该能更好的了解使用ActiveMQ时的性能瓶颈在什么地方,以及合适并且为什么要减轻
瓶颈.我们已经展示了如何调整消息生产者和消费者的配置选项以及调整这些选项对应用程序
架构的影响.你应当能够为你的应用程序选择正确的的架构以便提升性能,并且也应当能够更好的
理解保证消息准确不误分发对性能带来的负面影响以及如何使用ActiveMQ来减轻这种负面影响.
?
In the next and final chapter of this section, we’ll look at how to administer and
monitor ActiveMQ brokers using JMX, the ActiveMQ web console, and much more.
?
在下一章,也是本书最后一章中,我们将看到如何使用JMX,ActiveMQ web控制台以及更多其他工具
来管理和监控ActiveMQ代理.