Do I need to take care of producer-consumer rate-m

2019-05-26 06:12发布

问题:

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.

The doc says the default dispatcher is the ExecutorBasedEventDrivenDispatcher.

This dispatcher has five queue configuration:

  • Bounded LinkedBlockingQueue
  • Unbounded LinkedBlockingQueue
  • Bounded ArrayBlockingQueue
  • Unbounded ArrayBlockingQueue
  • SynchronousQueue

and four overload policies:

  • CallerRuns
  • Abort
  • Discard
  • DicardOldest

Is this the right mechanism to be looking at? If so, what are this dispatchers' default settings?

回答1:

The dispatcher has a task queue. This is unrelated to your problem. In fact, you want as many mailboxes to be enqueued as possible.

What you might be looking for is: http://doc.akka.io/docs/akka/1.3.1/scala/dispatchers.html#Making_the_Actor_mailbox_bounded