Reputation: 13
I'm currently evaluating play 2.0 framework in async scenario. I did an experiment as below:
def test = Action {
val futureResponse: Future[play.libs.WS.Response] = scala.concurrent.Future {
val remoteCall = WS.url("http://127.0.0.1:8080/slowweb/SlowServlet1").get();
remoteCall.get();
}
Async {
futureResponse.map(response => Ok("Got result: " + response.getBody()))
}
}
The ":8080/slowweb/SlowServlet1" is a simulation of a slow web service call, it takes 2s to return.
Then I run jmeter against the endpoint ":9000/test". I observed the following behaviour: If I run 50 threads in jmeter, the forkjoin pool size is 50; if I run 200 threads in jmeter, the forkjoin pool size is 200.
It looks to me the thread pool size is the same as the concurrent request size. What I expect is the thread pool size should be much smaller if using async approach.
Have I done something wrong?
Thanks
Upvotes: 1
Views: 152
Reputation: 21564
I don't know if it is related to your error, but your code could be simplified to this:
def test = Action {
Async {
val futureResponse: Future[play.libs.WS.Response] =
WS.url("http://127.0.0.1:8080/slowweb/SlowServlet1").get();
futureResponse.map(response => Ok("Got result: " + response.getBody()))
}
}
Upvotes: 1