使用Akka 1.3的演员时,我需要照顾生产者 - 消费者的费率匹配吗? [英] Do I need to take care of producer-consumer rate-matching when using Akka 1.3's actors?
问题描述
当使用Akka 1.3时,我需要担心当生成消息的actors比生成消息的actors更快地处理时会发生什么?
When using Akka 1.3, do I need to worry about what happens when the actors producing messages are producing them faster than than the actors consuming them can process?
没有任何机制,在长时间运行的进程中,队列大小将增长以消耗所有可用内存。
Without any mechanism, in a long running process, the queue sizes would grow to consume all available memory.
文档说默认分派器是ExecutorBasedEventDrivenDispatcher。
The doc says the default dispatcher is the ExecutorBasedEventDrivenDispatcher.
这个分派器有五个队列配置:
This dispatcher has five queue configuration:
- 边界LinkedBlockingQueue
- 无界LinkedBlockingQueue
- 边界ArrayBlockingQueue
- 无界ArrayBlockingQueue
- SynchronousQueue
- Bounded LinkedBlockingQueue
- Unbounded LinkedBlockingQueue
- Bounded ArrayBlockingQueue
- Unbounded ArrayBlockingQueue
- SynchronousQueue
和四个超载策略:
- CallerRuns
- 中止
- 舍弃
- DicardOldest
- CallerRuns
- Abort
- Discard
- DicardOldest
这是正确的机制吗?如果是,这个调度员的默认设置是什么?
Is this the right mechanism to be looking at? If so, what are this dispatchers' default settings?
推荐答案
分派器有一个任务队列。这与您的问题无关。事实上,你想要尽可能多的邮箱入列。
The dispatcher has a task queue. This is unrelated to your problem. In fact, you want as many mailboxes to be enqueued as possible.
你可能要找的是: http://doc.akka.io/docs/akka/1.3.1/scala/dispatchers.html#Making_the_Actor_mailbox_bounded
这篇关于使用Akka 1.3的演员时,我需要照顾生产者 - 消费者的费率匹配吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!