These are chat archives for petabridge/akka-bootcamp

21st
Jul 2015
Mike Clark
@mclark1129
Jul 21 2015 00:05
I'm trying to build an app where a set of actors are listening to a stream of stock data. Each actor will be responsible for a particular symbol, as well as a set of criteria to watch for. There can be multiple actors per symbol, each monitoring a different set of criteria.
I'm having trouble figuring out the right topology, and how routing might work in this case. I plan on having a StockFeedActor that listens to an actual stream of stock data from the market, and I want to send ticks for a particular symbol to all actors that care about it.
I'm assuming this needs to be a group router, but I haven't found an example yet where I could set up a router that the StockFeedActor could just send data for different symbols into, without knowing explicitly which StockMonitorActors were out there.
Mike Clark
@mclark1129
Jul 21 2015 00:32
Can routees be added to and removed from a router at runtime?
Aaron Stannard
@Aaronontheweb
Jul 21 2015 00:32
hey @mclark1129, sorry for the delay - was waiting for a build :p
Mike Clark
@mclark1129
Jul 21 2015 00:33
No problem! Hopefully this isn't too broad of a question for chat. Just trying to apply the concepts from bootcamp to a sample project
Aaron Stannard
@Aaronontheweb
Jul 21 2015 00:34
this use case actually sounds like a good fit for the child-per-entity pattern, which we cover in this blog post and in our Design Patterns course: https://petabridge.com/blog/top-akkadotnet-design-patterns/
you can apply the child-per-entity pattern recursively
so you can have one child per stock symbol
one grand-child per each metric that you need to track
for that symbol
each parent knows how to route the message to the appropriate child, because the entity identifier (let's say, the ticker symbol in this case) is also the name of the child
Mike Clark
@mclark1129
Jul 21 2015 00:40
Ok, that makes some sense. I plan on adding and removing metrics at runtime, so if I had a parent who was in charge of managing all the criteria for say AAPL
Aaron Stannard
@Aaronontheweb
Jul 21 2015 00:40
you could send that parent commands to create or kill those actors for the metrics you want
Mike Clark
@mclark1129
Jul 21 2015 00:40
And that parent received a new stock price for AAPL. I would want to send it to all the criteria at the same time.
Would this be a BroadcastGroup?
and I would just have a wildcard path?
/user/coordinator/aapl/*?
or even just '*' I guess? If I was talking about relative paths from within the SymbolParentActor
Aaron Stannard
@Aaronontheweb
Jul 21 2015 00:44
the parent could just iterate over its children
Mike Clark
@mclark1129
Jul 21 2015 00:45
That's true, then just a Parallel.ForEach instead of actor paths
doing a child.Tell is good enough
Tell is a very low-overhead method, and it's asynchronous
you could also use a broadcast router that uses a wildcard actor selection, like you mentioned
if this application is performance-sensitive it might be interesting to test the performance impact of each
actor selections do have some overhead - they have to be resolved
Mike Clark
@mclark1129
Jul 21 2015 00:47
Hmm ok. So simplest case would just iterate over the collection synchronously and call Tell
Ultimately this would be a pretty large multi-user system
Aaron Stannard
@Aaronontheweb
Jul 21 2015 00:47
IActorRef.Tell is fairly low overhead, so yeah I'd use a regular foreach loop
Mike Clark
@mclark1129
Jul 21 2015 00:47
so the number of criteria being monitored per symbol could be in the thousands
Aaron Stannard
@Aaronontheweb
Jul 21 2015 00:47
got it
Mike Clark
@mclark1129
Jul 21 2015 00:48
I'll start that though, thanks!
Aaron Stannard
@Aaronontheweb
Jul 21 2015 00:48
no problem
Mike Clark
@mclark1129
Jul 21 2015 00:48
I'm hoping once I get something running on one node, I'll work on scaling it out.
Aaron Stannard
@Aaronontheweb
Jul 21 2015 00:49
feel free to email me at aaron@petabridge.com if you have questions
Damian Reeves
@DamianReeves
Jul 21 2015 03:03
So this whole commander example seems like a pattern I would want to follow if I was replacing a message queue as a command bus when doing cqrs. It seems to me if I combine a AtLeastOnceDelivery actor with the proper router type that this can be accomplished. Can any guidance be provided on this as a pattern? The EventStream would have been a good candidate for this, but it does not operate across cluster nodes as far as I can see.
Damian Reeves
@DamianReeves
Jul 21 2015 03:09
@Aaronontheweb change C# to:
       //var router = ActorSystem.ActorOf(Props.Create(() => new RemoteJobActor()).WithRouter(FromConfig.Instance), "tasker");
        var router = ActorSystem.ActorOf(Props.Empty.WithRouter(FromConfig.Instance), "tasker");
and Hocon to:
/tasker {
router = broadcast-group
routees.paths = ["/user/api"]
virtual-nodes-factor = 8
cluster {
enabled = on
max-nr-of-instances-per-node = 2
allow-local-routees = off
use-role = tracker
}
Damian Reeves
@DamianReeves
Jul 21 2015 03:42
That doesn't work in Webcrawler, but turns out I need to leave as cosistent-hash-group and upgrade lighthouse and webcrawler to Akka, Akka.Cluster, and Akka.Remote to latest
Aaron Stannard
@Aaronontheweb
Jul 21 2015 06:46
@DamianReeves what version are they all running currently?
Damian Reeves
@DamianReeves
Jul 21 2015 08:02
Now works with 1.0.3
Gerjan
@GerjanOnline
Jul 21 2015 14:16
Im getting Exception thrown: 'System.AggregateException' in mscorlib.dll
I am running lesson 3.4 now on my new Win10 machine and it gets stuck on different repos
I have turned on all the logging/debug, but nothing seems "wrong", Akka does not throw something explicitly
when using https://github.com/petabridge/akka-bootcamp as Repo, it always fails at user 34
Gerjan
@GerjanOnline
Jul 21 2015 14:22
now it fails at user 32, and https://github.com/Squirrel/Squirrel.Windows as Repo also got stukc
stuck*
Gerjan
@GerjanOnline
Jul 21 2015 15:00
probably because of the github API limit? But i do not like the error/exception handling
Aaron Stannard
@Aaronontheweb
Jul 21 2015 23:15
@GerjanOnline probably the Github API limit