Disruptor技术调研之配置参数一览

1、单生产者和多生产者

One of the best ways to improve performance in concurrect systems is to ahere to the Single Writer Princple, this applies to the Disruptor.  If you are in the situation where there will only ever be a single thread producing events into the Disruptor, then you can take advantage of this to gain additional performance.

上述的描述大致的意思是在多并发的系统中,如果选择基于单生产者的Disruptor,能够获得比多生产者更好的性能。

2、可选择的等待策略

1)Disruptor默认的等待策略是BlockingWaitStrategy。内部是使用lock和condition来进行线程间的协作的。相对于其他的策略是最慢的但对cpu的使用是最保守的,也是所有选项中一致性行为最高的。
2)和BlockingWaitStrategy一样,SleepingWaitStrategy尝试保守的使用cpu,通过使用busy wait loop(在循环中调用LockSupport.parkNanos(1))。在linux系统上会让线程等待大概60µs的时间,生产者线程不需要做额外的动作。事件在生产者和消费者间传输的延时会高点,使用场景如在对低延时要求不要,但对生产者线程影响最小的时候使用。比如异步的logging。
3)YieldingWaitStrategy是可以在低延时系统中使用的策略之一,内部使用了Thread.yield()来让其他排队的线程能够执行。在需要高性能并且事件处理线程比cup的内核数少的场景下推荐使用的,比如开启了hyper-threading(超线程)。
4)BusySpinWaitStrategy是性能最高的策略,但是对部署的环境要求也是最高的,当事件处理线程比物理cup内核少的情况下才能被使用,对hyper-threading(超线程技术)状态是需要关闭的。


参考:

https://github.com/LMAX-Exchange/disruptor/wiki/Getting-Started#single-vs-multiple-producers

https://github.com/LMAX-Exchange/disruptor/wiki/Getting-Started#alternative-wait-strategies


转载于:https://my.oschina.net/u/914290/blog/661660

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值