Having listened to recent azure podcasts (particularly the one on building low latency financial systems on azure) and reading all the hype about Service Fabric I decided to try to alter the 'Distributed computation code sample Monte Carlo simulation' pattern for my needs.
My scenario is: One request with a given starting state to run 10k full sports match simulations using a simplistic (computationally-wise) monte-carlo based model.
My first attempt was:
1 * Stateful 'Processor' Actor that receives the start state of the match and forwards it to 10k + Task Actors, along with relevant Aggregator ActorId
10K+ * StateLess 'Task' Actors that ran 1 simulation and passed the Result to their Aggregator Actor. Simulation time was small (~2ms)
100 * Stateful 'Aggregator' Actors that aggregated received simulations and passed to a finaliser Actor
1 * 'Finaliser' Actor that calculated the final result
Running the above on my dev box simply using Tasks takes < 100ms, but the above setup (running on the dev machine as a local cluster) took 50secs and more!
After debugging through one potential cause that i found was the amount of time it takes for the Processor Actor to send the initial tasks so i was wondering what sort of overhead there is in calling Service Fabric (I guess all sorts of Naming service calls are happening when i call an actor's methods) and whether the slowness was likely to be due to this and my number of tasks?
To eliminate other possibilities i did the following and noticed only very small differences in total time:
- Made all actors stateless to ensure that state management wasn't adding overheads.
- Created all ActorProxies in the Processor and stored their references for future calls to ensure Actor Activations weren't causing issues.
Does anybody have any suggestions about where to go from here, or has anybody tried to implement something similar?
Thanks, Alex