ChatGPT解决这个技术问题 Extra ChatGPT

What are the differences between Scala middleware choices?

Note: Unfortunately this question was closed, but I'm trying to maintain it for if someone else comes along with the same question.

I've been looking for a good solution to developing a service in Scala that will sit between mobile devices and existing web services.

The current list of viable options are:

Finagle

Spray

BlueEyes

Akka

Play2 Mini

Unfiltered

Lift

Smoke

Scalatra

There are probably more options out there. How does one decide which one to use? What are the traits (excuse the pun ;-) of a good Scala middleware choice. On the one side, I would like to go for Akka, because it is part of the TypeSafe Scala stack, but on the other, something like Finagle has a rich set of libraries and makes plumbing so easy. Spray looks nice and simple to use.

Any advice, insights or experience would be greatly appreciated. I'm sure someone out there must have some experience with some of these that they won't mind sharing.

UPDATE:

I would love for this question to be reopened. A good answer to this question will help new Scalateers to avoid related pitfalls.

UPDATE 2:

These are my own experiences since asking this question:

Finagle - I used Finagle for a project and it's rock solid.

Spray - In my latest project I'm using Spray and I'm extremely happy. The latest releases are built on Akka 2 and you can run it directly with the Spray-can library which removes the need for a web server. Spray is a set of libraries, rather than a framework and is very modular. The Learn about Spray: REST on Akka video gives a great overview, and this blog at Cakesolutions shows a really nice development approach and architecture.

UPDATE 3:

Life moves pretty fast. If you don't stop and look around once in a while, you could miss it. - Ferris Bueller

These days the choice has become simpler. In my humble opinion Spray has won the battle. It is being integrated into Akka to become the next Akka HTTP. I have been using Spray now on multiple projects and can honestly say that it's fantastic and best supported software I have ever encountered.

This does not answer the initial question, but at least gives some indication on why Spray seems like the best choice in most cases. It is extremely flexible, non-blocking and very stable. It has both client-side and server-side libraries and a great testkit. Also, have a look at these stats to get an idea on performance: Web Framework Benchmarks

Thanks for adding finagle @ErnestFriedman-Hill . If you could, I would love for you to explain why users marked this question as not constructive. I have not used any of the above systems in production yet, have spent a week on reviewing them and other, and would have loved insights on other experiences.
Basically because StackOverflow isn't designed for discussion questions. A good SO question has a specific, verifiable answer, one that's not open to debate. Yours is a perfectly respectable question, but it's just not what SO wants to see. These are three examples from the FAQ that you're not supposed to ask here: “What’s your favorite ______?” “I use ______ for ______, what do you use?” “I’m curious if other people feel like I do.” Your questions seems to be sort of a hybrid of these three counterexamples.
@ErnestFriedman-Hill I may be wrong, but maybe this is a question with a verifiable answer. When I asked this question, I ended up using Finagle. The project ended fine, and runs like clockwork, but I'm still wondering if a Akka based service would not have been better. I still don't know the answer, and really hope you gents will consider reopening it.
A tip on how to make questions like this somewhat valid, ask: "what are the differences between these frameworks?"

A
Adrian Rodriguez

I personally started with spray a long time ago and tried everything else there was out there for Scala. While Scala, spray, akka, shapeless, and scalaz certainly have a bit of a learning curve, once you start digging in and really learning how you are supposed to use the technologies, they make sense and I immediately saw the benefits especially for the kind of work I'm doing right now.

Personally I think nothing really stands up to spray for building both servers, rest apis, http clients, and whatever else you want. What I love about spray is that they built with akka in mind. It may have been a really early project when I first started using it, but the architecture made sense. Those guys knew what they were doing in terms of exploiting the benefits of using an actor model and not having any blocking operations.

While actors might take a bit getting used to, I do like them. They have made my systems very scalable and cheap to run because I don't need as beefy hardware as in the past. Plus, spray has that spray-routing DSL so making a rest api is relatively simple as long as you follow the rules ... don't block. That of course means don't go and pull in apache commons http client to make client requests from the api or actors because you will be going back to blocking models.

So far I am very happy with spray, typesafe, and akka. Their models just naturally lend themselves to building very resilient systems that come back up on their own if anything should happen and you take a fail-fast approach. The one beef that I have with spray (and it's not spray's fault) is the damn IDE support for the routing DSL. I absolutely despise Eclipse and have always been an IDEA user. When I started using the Scala plugin, everything seemed ok. Then my routing dsl naturally evolved into way bigger beasts. Something about the way IDEA parses that code makes it shit its pants anytime it encounters anything with spray-routing or shapeless. It's to the point where it's unusable (I type 2-3 letters and have to wait 5 minutes to regain control).

So, for any spray-routing or heavy shapeless code, I fire up emacs with ensime, ensime-sbt, and scala-mode2. Now if I could only get a Cassandra library with the quality of astyanax and built using a more non-blocking architecture.


This is an old answer. Did you get that Cassandra library?
a
aglavina

Here you can find a great list of scala resources with a brief description of all the alternatives you listed.

From my own experience, I use Scalatra and it is tiny, simple and effective for things like uri mapping and calling web services.