Akka stream - transfer of an input-output stream to another dispatcher

In my stream there is an even combination of steps with reference to the CPU and IO (each stage of IO is accompanied by a stage of CPU). I want to make I / O operations a different dispatcher than the rest of the stream.

In the Akka application, based on a traditional actor, I could put my IO participants on a fixed thread pool manager with a large number of threads, while processor-bound actors in pool pool forks with a small number of threads (several multiple, ideally 1, from the number of cores). This should reduce the time spent switching threads for processor-bound entities, while increasing throughput due to the large number of threads blocking IO.

Is this understanding correct? If not, why? If so, how can I put my associated IO steps (threads) in a separate dispatcher from the rest of the thread?

I tried disabling autocomplete and it really helps. But it still has less bandwidth than the nearly equivalent Akka counterpart.

+6
source share
1 answer

By default, all stages of the flow are performed on the same actor, you can note that the stages must be performed on a separate dispatcher using attributes, for example:

stage.withAttributes(ActorAttributes.dispatcher("dispatcher-name")) 

It will also introduce asynchronous borders around this stage, effectively running it in its own actor. To avoid having an asynchronous border become expensive, the scene will now actually send demand for 16 elements at the same time from the upstream, so this is what you should be aware of.

The buffer size can be changed using an additional attribute, in which case it will behave like fused steps, since it requests one element at a time, please note that this can lead to too much cost, depending on the use case.

 stage.withAttributes(Attributes.inputBuffer(1, 1)) 

Relevant parts of documents:

+9
source

All Articles