views:

268

answers:

4

Hi,

We are thinking on moving our Rest API Server (it is inside the web service, on Symfony PHP) to Scala for several reasons: speed, no overhead, less cpu, less code, scalability, etc. I did't know Scala until several days ago but I've been enjoying what I've been learning these days with the Scala book and all the blog posts and questions (it's not so ugly!)

I have the following options:

  • build the Rest API Server from scratch
  • use a tiny Scala web framework like Scalatra
  • use lift

Some things that I will have to use: HTTP requests, JSON output, MySQL (data), OAuth, Memcache (cache), Logs, File uploads, Stats (maybe Redis).

What would you recommend? Thanks!

+1  A: 

I'm going to recommend Unfiltered. It's an idiomatic Web framework that does things "the Scala way" and is very beautiful.

Max A.
thanks, I will try akka first, as it seems to have a bigger community and support
fesja
n8han rules !! :)
oluies
+2  A: 

I would add two more options: akka with built-in JAX-RS support, and simply using JAX-RS directly (probably the Jersey implementation). While arguably less "Scala-y" than others (relying upon annotations to bind parameters and paths), JAX-RS is a joy to use, cleanly solving all of the problems of web service coding with minimal footprint. I've not used it via akka, I would anticipate it being excellent there, getting impressive scalability via it's continuation-based implementation.

Dave Griffith
thanks! I will check on AKKA with JAX-RS as @Brent and you said. It really seems to be very light with minimal footprint which is really important for an API, if you want to go really fast.
fesja
+4  A: 

Take a look at the AKKA REST module.

Examples:

Scala API example with Actors

Pinky REST/MVC framework

Also Lift makes it simple to provide REST services.

oluies
thanks! I will check on AKKA, as it seems to be very light and scalable
fesja
N.B I hope someone gets around of integrating or porting http://restfulie.caelum.com.br/ to Scala. One option now is using Restfulie as a frontend to Scala on JRuby.
oluies
+1, I use Akka at work to power a high-performance API server. The downside of using JAX-RS with Akka is that JAX-RS comes loaded with a ton of Java idiosyncrasies that don't fit very cleanly into a pure-Scala project. Still, Akka makes the entire deal worth it.
Max A.
+2  A: 

All good answers so far. One point in Lift's favor is its RestHelper, which can make it quite easy to write short, elegant API methods. In addition, all the other things you want to do should be quite straight-forward to implement in Lift. That being said, Memcache might be not be necessary.

pr1001
thanks! why don't you think memcache is necessary? It depends of course, but we have several queries that are very likely to be done constantly, so it's time we win and less load on the database.
fesja
I'm really just going off of what David Pollak said yesterday. Basically, the caching within Lift removes many use-cases of memcache. Here's his message and there are a few other posts in the thread about memcache: http://groups.google.com/group/scala-base/msg/4b11cbd357bfecf0
pr1001