Saturday 15 May 2010

Deliberate Blocking in Akka Actors -



Deliberate Blocking in Akka Actors -

i understand akka actors should not block in order remain reactive messages, how construction service want monitor process running indefinite period of time?

for example, using amazon kinesis connector library. create connector given configuration, inherits runnable, , phone call run() method. connector runs indefinitely, pulling info kinesis, , writing amazon s3. in fact, if runnable returns, error, , needs restarted.

approach (1) create kid actor each kinesis connector running, , if run() method returns, throw exception, supervising actor notices exception , restarts kid actor. 1 connector per kid actor per thread.

approach (2) kid actor wrap kinesis connector in future, , if future returns, actor restart connector in future. conceivably single actor manage multiple connectors, mean each future executing in separate thread?

which approach in line philosophy of akka, or there other approach people recommend? in general, want grab problems connector, , restart it. in total there not more half dozen connectors running in parallel.

i take approach 1. should noted though actors not have dedicated thread default share thread pool (the called dispatcher, see: http://doc.akka.io/docs/akka/2.3.6/scala/dispatchers.html). means blocking inherently unsafe because exhausts threads of pool not letting other non-blocked actors run (since blocked actors not set thread pool). hence should separate blocking calls fixed size pool of dedicated actors, , should assign these actors pinneddispatcher. latter step ensures these actors not interfere each other (they each have dedicated thread) , ensures these actors not interfere rest of scheme (all of other actors run on dispatchers, on default-dispatcher). sure though limit number of actors running on pinneddispatcher since number of used threads grow number of actors on dispatcher.

akka akka-supervision

No comments:

Post a Comment