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

一、单生产者和多生产者
linux

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.git

上述的描述大体的意思是在多并发的系统中,若是选择基于单生产者的Disruptor,可以得到比多生产者更好的性能。github

二、可选择的等待策略并发

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(超线程技术)状态是须要关闭的。
app


参考:
异步

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

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

相关文章
相关标签/搜索