Hi Anton, sorry it took me so long to dig through to to this email. I think this is simply a case of the second implementation of something being better since you grasped the domain batter, while implementing the first iteration :-) We do not recommend Actors as "solve it all", however the points at which they shine are allowing parallelism / distribution (even in clusters, due to the location transparency).
Performance wise it's tough to say anything without looking through the code, but I don't think Akka itself was at fault since actor messaging easily can take millions of messages per second in a jvm (you don't mention clustering so I assume in memory). Perhaps you have been using a lot of effectively synchronous (as in ask and await for a response) or blocking calls in your Actor implementation, which made it hard for Akka to maximise its usefulness? We'd have to dig deeper in your impl to find the answer I guess :-) All in all, it's a design question - one can build highly (or poorly) performant code using any model, I do believe Actors help with modeling of problems with inherent distribution and concurrency. On Wed, May 20, 2015 at 7:41 PM, Anton Khodakivskiy <[email protected] > wrote: > Hi > > I've recently attempted to build a bitcoin trading bot for Coinbase > exchange. At first using Actors felt natural for this sort of problem. > There is asynchronous incoming and outgoing messages (exchange tick data, > placing, cancelling orders), a lot of state (managing order book, following > own orders), all the auxiliary tools that introduce even more state and > more interactions (simulator for backtesting). > > My current actor implementation involves 5-7 actors that send one another > messages. Coding the system was fun and it seems to work fast enough (in > simulation mode I can process 1 exchange message in 50 mics on average). > But... the resulting system is not deterministic. There are many actors, > significant message flow. This results in all sorts of race conditions. One > of the manifestations of this problem is that the backtest results between > the runs are drastically different. It almost seems like butterfly effect - > one actor sends a message a tad earlier and all the subsequent order flow > is totally different. > > I started addressing these race conditions, and after a while I realized > that my system is now deterministic and... completely linear. After this I > ditched Akka and reimplemented everything in conventional Scala, employing > some category theory tricks. State monad in particular turned out to be > quite useful. It's also worth noting that message processing time went down > from 50 mics to ~10, which allows me to run backtests 5 times faster. > > Now my questions: is there a chance that I misunderstood and misused the > actor model? Or is it the nature of my problem (trading bot) that doesn't > really require such a sophisticated solution as actor model? What kind of > problems can actually benefit from using actors? Is there good open source > example projects to learn from? > > Thanks, > > Anton > > -- > >>>>>>>>>> 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. > -- Cheers, Konrad 'ktoso' Malawski Akka <http://akka.io/> @ Typesafe <http://typesafe.com/> -- >>>>>>>>>> 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.
