I have a standard play 2! application which communicates with the front-end via JSON. All requests are routed to controllers. Now the controllers import some heavy duty calculation classes.
So if a user requests a calculation, it might take 5 secs for the controller method to get the results back from the actual calculation class, as the calculation is iterative and takes time.
Doesn't this mean then that the server is blocked for these 5 secs? It cannot service any other user? Is 20 people are using this calculation tool simultaneously, it could become difficult for others to even load the home page served by same server due to the long queue... Am i right in this line of thinking and what could be a possible solution?
Your assumptions are correct. Play 2 uses a few thread pools which are each allocated to specific things. See here
So like you said, with the default configuration and assuming you are calling your calculation class synchronously, if more than 24 people hit your site at the same time, you Play 2 app will start to block.
I specifically mentioned 24 people because Play's default thread pool configuration is set to 1 thread per core up to a max of 24 threads. See here for more options. Hence if you block all 24 threads you're going to start having problems in terms of site responsiveness.
There are a few solutions:
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments