Reputation: 1334
I am working on a web-app that accepts user input and use a cluster to do parallel computation on the input. Akka-cluster is used to facilitate this.
I am currently using Play Framework to manage HTTP request in my web-app. From this, I am thinking of submitting user input to a frontend Akka actor which forwards the request to several backend actors to calculate the intermediate results in parallel. Then I have another actor that aggregates the intermediate results before finally returning the final result to the user. Each calculation can take from several minutes to an hour. (I got the idea of using frontend and backend actor from this example)
My concern is, the frontend actor has to accept the request from each user and gives the progress report of the job. My first thought is to use the 'ask' pattern but I think this is not the right approach as that means only one user can be the server at a time. So I am currently thinking of using asynchronous 'tell' to serve the request.
My questions are: is this the right approach to the problem? If I am using 'tell', then how do I notify the user when the job has finished? Also, since I am using Play Framework, is it possible to integrate the frontend actor with Play to show update to the web page?
Upvotes: 1
Views: 168
Reputation: 1356
Not sure what do you mean about blocking 'ask' pattern
. If you talk about the ?
or ask
methods to await a response from actors, it is based on Futures which are async and nonblocking so its pretty safe to use in Play, it is a common approach indeed.
In the other hand, if the response is going to take very long, lets say more than 20s, I discourage that in order to not keep to many open connections and to improve user experience. Also Akka encourage the use of tell
so I would go for a server-side pushing technologies (websockets?) or even email messages if it could be even longer.
Upvotes: 1