Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is playframework truly asynchronous?

Best answer is in the comments section(so I can't give them points for the answer :( ).

I was wondering if playframework was asynchronous in this fashion(which would be truly asynchronous, or fully asynchronous). Yes, play is asynchronous on the front end allowing 1000 clients on 100 threads, but on the backend, there is no way to achieve this, or am I wrong(which I hope to be).....

public static void someRequest(String id) {

     //This method adds listener to a nio socket listener so it returns
     //IMMEDIATELY and page can't be rendered at this point
     fetchRemoteDataFromOtherSystem(id, new MyListener());

     // DO NOT RENDER PAGE YET but return so thread can be used for other requests
}

public class MyListener extends SomeListener {
    public void fireResponse(Response response) {
        renderPage(response);
    }
}

NOTICE that this would be extreme asynchronous behavior and also note that if you have a backend system that takes seconds to respond to each request, you now need about 100 less machines to serve the same amount of users. In normal contexts where backend system is very fast, there would be no performance difference of course.

thanks, Dean

like image 514
Dean Hiller Avatar asked Feb 04 '12 15:02

Dean Hiller


2 Answers

Have a look at Play 2.0. It's still a beta version, but it has some nice asynchronous stuff.

For the first Play, take a look at this documentation page, which covers Play's asynchronous features, and the Play Akka module (and while you're at it, also Akka itself :) ).

like image 145
Carsten Avatar answered Oct 17 '22 08:10

Carsten


play 2 is totaly asynchronous from ground up and it uses akka and netty. You can use play for both Your front end and services (eg: as rest). Also play is stateless, so, it's very easy to scale it up by adding servers.

like image 22
sirmak Avatar answered Oct 17 '22 09:10

sirmak