Cluster router example questions

55 views
Skip to first unread message

lapming.lee

unread,
Sep 29, 2015, 9:36:57 AM9/29/15
to Akka User List
I am looking at the example given by akka (http://doc.akka.io/docs/akka/snapshot/scala/cluster-usage.html#Cluster_Aware_Routers)

I have a 1 question for each group and pool router on how it routes its messages.  It is in regards to how messages are passed from router to routee.

Group router

  1. akka.actor.deployment {
  2.  /statsService/workerRouter {
  3.      router = consistent-hashing-group
  4.      routees.paths = ["/user/statsWorker"]
  5.      cluster {
  6.        enabled = on
  7.        allow-local-routees = false
  8.        use-role = compute
  9.      }
  10.    }
  11. }

  • class StatsService extends Actor {
  •  // This router is used both with lookup and deploy of routees. If you
  •  // have a router with only lookup of routees you can use Props.empty
  •  // instead of Props[StatsWorker.class].
  •  val workerRouter = context.actorOf(FromConfig.props(Props.empty),
  •    name = "workerRouter")
     
     
    ...etc
    }

Question:

If I have this configuration and this class on a master node.  Is it saying that within the actor with name "statsService", this is a child actor with name "workerRouter".  And the router should direct messages to all nodes that use the role cluster and select the routee

system.actorSelection("/user/statsWorker")


*System here would be the each node's local actor system



Pool router

  1. akka.actor.deployment {
  2.  /statsService/singleton/workerRouter {
  3.      router = consistent-hashing-pool
  4.      cluster {
  5.        enabled = on
  6.        max-nr-of-instances-per-node = 3
  7.        allow-local-routees = false
  8.        use-role = compute
  9.      }
  10.    }
  11. }

  1. system.actorOf(ClusterSingletonManager.props(
  2.  singletonProps = Props[StatsService],
  3.  terminationMessage = PoisonPill,
  4.  settings = ClusterSingletonManagerSettings(system).withRole("compute")),
  5.  name = "statsService")

  1. system.actorOf(ClusterSingletonProxy.props(singletonManagerPath = "/user/statsService",
  2.  settings = ClusterSingletonProxySettings(system).withRole("compute")),
  3.  name = "statsServiceProxy")

  • class StatsService extends Actor {
  •  // This router is used both with lookup and deploy of routees. If you
  •  // have a router with only lookup of routees you can use Props.empty
  •  // instead of Props[StatsWorker.class].
  •  val workerRouter = context.actorOf(FromConfig.props(Props[StatsWorker]),
  •    name = "workerRouter")
     
     
    ...etc
    }


Question:

Pool routers are a little different in that it doesn't have routees.path.  A StatsService singleton is created on each node with the role compute.  Where are the routees in this case?  Are they also created on all these nodes such that when I send a message to the singleton proxy, it is sending a message to StatsWorker on all the nodes with role compute?

Patrik Nordwall

unread,
Oct 5, 2015, 3:02:01 AM10/5/15
to akka...@googlegroups.com
On Tue, Sep 29, 2015 at 3:36 PM, lapming.lee <lapmi...@gmail.com> wrote:
I am looking at the example given by akka (http://doc.akka.io/docs/akka/snapshot/scala/cluster-usage.html#Cluster_Aware_Routers)

I have a 1 question for each group and pool router on how it routes its messages.  It is in regards to how messages are passed from router to routee.

Group router

  1. akka.actor.deployment {
  2.  /statsService/workerRouter {
  3.      router = consistent-hashing-group
  4.      routees.paths = ["/user/statsWorker"]
  5.      cluster {
  6.        enabled = on
  7.        allow-local-routees = false
  8.        use-role = compute
  9.      }
  10.    }
  11. }

  • class StatsService extends Actor {
  •  // This router is used both with lookup and deploy of routees. If you
  •  // have a router with only lookup of routees you can use Props.empty
  •  // instead of Props[StatsWorker.class].
  •  val workerRouter = context.actorOf(FromConfig.props(Props.empty),
  •    name = "workerRouter")
     
     
    ...etc
    }

Question:

If I have this configuration and this class on a master node.  Is it saying that within the actor with name "statsService", this is a child actor with name "workerRouter".  And the router should direct messages to all nodes that use the role cluster and select the routee

system.actorSelection("/user/statsWorker")


*System here would be the each node's local actor system


That is correct. You have started the routee actors yourself on each node in the cluster with
system.actorOf(Props[StatsWorker.class], "statsWorker")
The messages that are sent via the singleton proxy will be sent to the singleton instance, i.e. the StatsService actor. That actor delegates the messages to worker actors of the pool. The worker actors of the pool are created by the pool itself on other cluster nodes (it's called remote deployment).

/Patrik
 

--
>>>>>>>>>> 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.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--

Patrik Nordwall
Typesafe Reactive apps on the JVM
Twitter: @patriknw

lapming.lee

unread,
Oct 5, 2015, 3:17:43 AM10/5/15
to Akka User List
Thanks!  I finally understand pool routers!  : ) 
Reply all
Reply to author
Forward
0 new messages