Open akauppi opened 9 years ago
Futures vs Actors has been widely debated. Both have pros and cons and I agree with many arguments on both sides of the debate. I think there is a lot of personal preference involved and I don't think there is a right answer.
A couple reasons you may want to use Actors:
All this said, I do like working with Futures. I'm not a huge fan of combining Actors and Futures with the ask pattern (which is what I was trying to avoid with this demo) . Here is my blog post explaining more about that. Things have changed a little since I wrote that post. If you use tools like kamon, AskTimeoutException
s will no longer be completely useless.
Actually, I'd love to see this done with akka's new reactive streams..
You probably know this, but I'll mention it anyways. Spray.io will soon become akka-http which is built on reactive streams. If you look at the spray website's other resources you'll see a ton of presentations talking about this change: http://spray.io/introduction/other-resources/
Reactive streams have all the benefits of actors because they are actually run with actors behind the scenes. They also integrate with actors. One big advantage to the reactive stream approach is it has backpressure built in which solves the big problems that async systems have been having. Also, I've noticed that actor code tends to be a bit disjoint sometimes where you have to jump from code file to code file to see how your messages are flowing through the system, reactive streams helps that a ton. I forked the project and am hoping to perhaps find time to play with your example and. Do you have any plans for playing with reactive streams yourself?
Also you can check out the typesafe podcast for info on how spray is changing: http://letitcrash.com/post/91840527142/typesafe-podcasts
Is there a reason why the code is using actors? If not, this sample may be pointing people in the wrong direction - when their best option would be to create routes returning
Future[HttpResponse]
s, instead of employing actors. Am I right?See Don't Use Actors for Concurrency