Thursday 15 August 2013

java - How-to create 1 million actors in parallel? -



java - How-to create 1 million actors in parallel? -

this learning example.

i have actor holds list of 1 1000000 ids (this stripped downwards example. in real life these actors represent bank accounts , send them "tell" or "broadcast" messages. want maintain them @ same time in memory)

i want actor create 1 1000000 kid actors (one each id)

is there more parallel way code?

receive (msg,..) { ids.stream().foreach( id -> { context().actorof(myactor.props(id)); } ); }

and why not utilize broadcastrouter children?

val children = system.actorof(props[childrenactor].withrouter( broadcastrouter(nrofinstances = amountofchildren)))

this in case need send messages children every single time. in case need send both broadcast , individual messages children, can utilize consistenthashingrouter instead map messages children ids.

java scala akka

No comments:

Post a Comment