Hi Roland,

My understanding is (and if this understanding is incorrect that is the 
root cause of all my problems) that the things such as number of actors 
instances, type and configuration of the thread pool, type of the 
dispatcher etc. all all controlled by the routers. Without using the 
routers Akka system will only have one instance of each actor without any 
way to tweak that actor's behavior. Let's assume that in my (hypothetical) 
scenario Actor1 processes tens of millions of messages, but processes them 
very quickly. Actor2. Processes much fewermessages, but each message 
processing takes time. Actor3 could be something in-between. So I may want 
to have large number of instances of Actor1 and may be less for Actor2, but 
for Actor2 I want to use pinned dispatcher. Can I achieve all this without 
using multiple routers?


On Saturday, August 20, 2016 at 4:58:14 AM UTC-4, √ wrote:
>
> On Aug 20, 2016 9:22 AM, "Roland Kuhn" <goo...@rkuhn.info <javascript:>> 
> wrote:
> >
> > Hi Mark,
> >
> > before we can move on, there is one important thing to do: as far as I 
> can see you are describing a broken solution, not the real problem. Please 
> let us take a step back to find a real solution.
> >
> > Interjection about Routers
> >
> > Routers are somewhat like actors that create some other actors—the 
> Routees for which you supply the Props—in order to distribute an incoming 
> stream of messages to them. The Router itself is an actual actor with a 
> name (the one you gave and that you use in the config) and a behavior; its 
> ActorRef, however, is a magical one, highly specialized in order to bypass 
> the Router actor for the dispatch of those messages you want to send. This 
> is only useful if you try to send more than about 3 million messages per 
> second to that Router; if you send less than that number please do not use 
> routers. Instead, create a normal actor and do the routing in there.
> >
> > The child actors created by the Router of course are real actors 
> themselves, and they also need names within the namespace of their parent 
> (which is the Router actor). These names cannot be given by you because how 
> would you tell the Router actor how it should name its own children? This 
> is another reason for not using Routers because they are highly specialized 
> for a purpose that I am pretty certain you don’t need here.
> >
> > Now to the problem
> >
> > From what I know you have three actors: actor1, actor2, actor3. Each of 
> these has a function, and each of these may or may not send messages to the 
> other two. There is absolutely no reason that actor2 should be a child of 
> actor1 if you only want to send messages from actor1 to actor2.
> >
> > So, start out with the following (and no, do not use system.actorOf in 
> here):
> >
> > // Using Scala because writing this in Java would only obscure the 
> intent 
> > // with useless boilerplate; I’m sure that you can extract the meaning.
> >
> > case class TheLineup(actor1: ActorRef, actor2: ActorRef, actor3: 
> ActorRef)
> >
> > class TheBoss extends Actor {
> >   val actor1 = context.actorOf(Props(new Actor1), "actor1")
> >   val actor2 = context.actorOf(Props(new Actor2), "actor1")
>
> "actor2"
>
> >   val actor3 = context.actorOf(Props(new Actor3), "actor1")
>
> "actor3"
>
> >
> >   // introduce the three actors to each other so they can talk
> >   val lineup = TheLineup(actor1, actor2, actor3)
> >   actor1 ! lineup
> >   actor2 ! lineup
> >   actor3 ! lineup
> >
> >   // route incoming messages to the appropriate destination
> >   def receive = {
> >     case msg =>
> >       if (shallGoTo1(msg)) actor1 ! msg
> >       else if (shallGoTo2(msg)) actor2 ! msg
> >       else if (shallGoTo3(msg)) actor3 ! msg
> >   }
> >
> >   ...
> > }
> >
> > TheBoss will be responsible for handling failures in the three actors, 
> and you should probably also watch them and handle the Terminated messages.
> >
> > I hope this helps,
> >
> > Roland
> >
> >> 20 aug. 2016 kl. 05:11 skrev Mark Kaberman <mkab...@gmail.com 
> <javascript:>>:
> >>
> >> Here. My apologies: it wasn't Roland, but Konrad Malawsky. The issue I 
> am investigating is that if I use multiple routers in my path Akka creates 
> huge amount of actor's class  instances and the system runs out of memory 
> If I have three routers in my path with nr-of-instances 10 each Akka will 
> create 1000 actor class instances. My paths have tens of hops and number of 
> actors ends up being huge. Roland suggested here to create all actors as 
> children of the supervisor which essentially allows only one router.
> >>
> >> On Friday, August 19, 2016 at 10:39:50 PM UTC-4, Justin du coeur wrote:
> >>>
> >>> On Fri, Aug 19, 2016 at 4:23 PM, Mark Kaberman <mkab...@gmail.com> 
> wrote:
> >>>>
> >>>> The fact that actor names are generated by Akka is also a concern. 
> According to Roland Kuhn that should be avoided. 
> >>>
> >>>
> >>> Hmm?  Where does Roland say that?  There are lots of perfectly 
> ordinary circumstances in which the Actor's name is generated by Akka, and 
> routing seems like one of the cases where I would expect that to be the 
> case...
> >>
> >>
> >> -- 
> >> >>>>>>>>>> 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 akka-user+...@googlegroups.com <javascript:>.
> >> To post to this group, send email to akka...@googlegroups.com 
> <javascript:>.
> >> Visit this group at https://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 akka-user+...@googlegroups.com <javascript:>.
> > To post to this group, send email to akka...@googlegroups.com 
> <javascript:>.
> > Visit this group at https://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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to