开发者

What actor based web frameworks are available for Scala?

I need to build very concurrent web service which will expose REST based API for JavaScript (front end) and Rails (back end). Web service will be suiting data access API to MongoDB.

I already wrote an initial implementation using NodeJS and would like to try Scala based solution. I'm also considering Erlang, for which every web framework is actor based.

So I'm 开发者_开发问答looking for web framework explicitly build using Actors in order to support massive load of requests I'm very new to Scala and I don't quite understand how Actor might work if almost all frameworks for Scala are based on Java servlets which creates a thread on each request which will just exhaust all resources in my scenario.


  1. If you're really going to have 10k+ long active connections at a time, then any standard Java application server/framework (maybe, except for Netty) will not work for you - all of them are consuming lots of memory (even if any kind of smart NIO is used). You'd better stick to a clustered event-loop based solution (like node.js that you've already tried), mongrel backed with zeroMQ, nginx with the mode for writing into MQ polled by Scala Actors, etc.

  2. Among the Scala/Java frameworks, Lift has a good async support for REST (though it's not directly tied to actors). OTOH, LinkedIn uses Scalatra + stdlib actors for their REST services behind Signal ,and feels just fine.


Another option is Play framework. The latest 1.1 release supports Scala. It also supports akka as a module.


As far as Scalatra itself, they have been working on a new request abstraction called SSGI (akin to the Servlet/Rack/WSGI/WAI layer), that they said should ennable them to break from solely running as a Servlet and also run on top of something built with Netty. See thread here. http://github.com/scalatra/ssgi

There's some other interesting frameworks at the Scalatra level of simplicity since designed from the ground up to support asynchronous web services (won't tie up a thread per request):

https://github.com/jdegoes/blueeyes - Not a servlet; built on Netty. ("loosely inspired by ... Scalatra")

http://spray.cc/ - Built on Akka actors, Akka Mist. Servlet 3.0 or Jetty continuations ("spray was heavily inspired by BlueEyes and Scalatra.")

And at a lower level: https://github.com/rschildmeijer/loft - "Continuation based non-blocking, asynchronous, single threaded web server." Not production-ready, but rather interesting-looking. Continuations require the compiler plugin.


http://liftweb.net/ Indeed, a request starts off as a servlet, but then lift uses comet support found in many servlet containers to break away from the thread, keeping the request context (which the container then doesn't destroy) which then can be used to output data in actors.

http://akkasource.org also has support for rest, but it will block the thread until the actor finishes with its work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜