1

That's probably more a design rather than implementation question. Let's say I have the folowing actor hierarchy, which forms an Akka cluster

                  ApiActor               [API Role]
                     |
              MasterCoordinator          [API Role]
              |                 |
SceduledJobCoordinator [Schd]  StreamingJobCoordinator [Stream]
      |            |                 |             |
SchdJobActor SchdJobActor     StreamJobActor StreamJobActor  

(I intentionally did not place seed node to save space) Api roles can be also redundant

So the workflow is obvious - users interactively/by scripting start bunch of different jobs on different worker nodes. Jobs are "fire and forget"-type, users do not wait for results, results are being written to database. Then bad thing happens - API node gets restarted or worse (destroyed, flooded, eaten by Godzilla etc). I understand that i cannot keep child actors alive, since they are part of parent actor state which is not valid anymore. If i understand correctly even router actor already acts as a parent to it's routees? Question: what is the best way of decoupling worker actors from api actors? if it's possible at all

if not then I suppose i will have to implement some kind of worker actor recovery workflow?

Thanks in advance

Maxim Podkolzin
  • 378
  • 2
  • 10
  • Does those actors have some in-memory state, you'd like to keep upon restart? Because this sounds like a standard scenario, where you can build a (clustered) router that will be started when actor system starts. Optionally routees placement can be configured by using akka cluster roles. – Bartosz Sypytkowski Nov 08 '16 at 21:47
  • Worker actors are statefull, they store essentially work progress (last database row id written for example) So you mean that worker actors will be restarted no matter what, and I have to figure out a way to restore the state? As far as I understand if I create router all routees are considered children and if router is restarted then all children are restarted. – Maxim Podkolzin Nov 09 '16 at 00:48
  • > if router is restarted then all children are restarted Yes, but the state they've kept in memory will be lost. Unfortunately your ASCII drawing is not self explanatory, please tell what are relations between those actors i.e. why API actor is a root parent for everything else? – Bartosz Sypytkowski Nov 11 '16 at 10:54
  • Is what you describe best modelled as an Actor Hierarchy? If you have child actors that are decoupled from their parents, in my mind they cease to be child actors. I would just model them as their own group of actors to which you can send messages. If you want to have a pool of actors to route through then you could to store a list of 'destination' actor addresses within the ApiActor andimplement your own basic round robin using a cyclical counter. – Doug Bruce Nov 14 '16 at 09:52
  • Sorry for my drawing, it's indeed not very descriptive. I consider 2 possible scenarios 1) Actor hierarchy. Master-coordinator is a parent, worker artors are children and they get restarted if parent for some reasons crashes. So I will have to come up with method preserving worker actors state and restoring it once worker actor is restarted 2) Decoupling Master coordinator from workers. In this case I cannot use router, since router will act as parent for all its routees (basically scenario 1), is my understanding correct? How do I send messages to worker actors then, using ActorSelection? – Maxim Podkolzin Nov 15 '16 at 23:16

0 Answers0