To answer your basic question, Actors are cheap to create and you shouldn't really worry about reusing them. You should use as many of them as is necessary to make your code function properly while being easy to write/maintain. It sounds like an Actor per-Node, as you have implemented, is easiest for you and there is no problem with writing your code that way from an Akka best practices viewpoint, so you might as well continue with it.
:: atomly :: [ [email protected] : www.atomly.com : http://blog.atomly.com/ ... [ atomiq records : new york city : +1.347.692.8661 ... [ e-mail [email protected] for atomly info and updates ... On Thu, Sep 25, 2014 at 1:08 PM, Idris Mokhtarzada <[email protected]> wrote: > Hi, > > I'm just starting to tinker with Akka, so forgive my ignorance. I'm > having trouble determining when I should be creating new actors every time > vs. re-using actors and maybe running them in round-robin pools or > something. Below is my use case.. any advice would be very helpful. > > This is a Spring MVC webapp, and I'm using Akka to traverse a tree which > is associated with some user data. These trees have 4 different node types > (including the root), so I have the following actor classes defined: > > - Root: 1 actor class for the "root" node.. this basically calls the > "Children" actor below > - Children: 1 actor class to process the children of internal nodes > - Leaf: 1 actor class to process the leaf nodes > > As I traverse the tree, each actor is generating some HTML and sending > back to the parent. At the Children nodes, these are concatenated together > and sent back to the parent. > The advantage I'd like to gain with Akka is I'd like to be able to scale > processing of the leaf nodes horizontally, to multiple threads, and > possibly multiple servers. > > Currently, at every node in the tree, I'm calling context.actorOf(...) to > get the child actors. My question is whether I should be doing that, or > whether it's better to call context.actorOf(...) only ONCE per actor TYPE, > and then setup a routing pool to scale. More generally, when do you want > to create new actors vs. re-use actors from a pool? Any help on this topic > would be greatly appreciated. > > Thanks! > Idris > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
