Akka: acting spawning versus filling in mailboxes

If you want to do lengthy calculations at the same time (on the same machine), Akka actors can help.

One approach is to create a new actor for each part of the work. Sort of

while(true) {
    val actor = system.actorOf(Props[ProcessingActor])
    (actor ? msg).map { 
        ... 
        system.stop(actor)
    }
}

The second idea is to configure a certain number of participants behind the router. Then send all messages to the router.

val router = system.actorOf(Props[ProcessingActor].withRouter(RoundRobinRouter(nrOfInstances = 5)))
while(true) {
    (router ? msg).map { ... }
}

I wonder what is better if the system is overloaded (the speed of incoming messages is higher than the processing speed)?

What will last longer? And both will explode the system with OOMError?

+3
source share
1 answer

Actor Future. , . , actor/router. , Future Promise. , . , . , system.actorOf ​​.

+4

All Articles