Reputation: 355
I am facing a scenario that my application is handling requests in a queue i.e. one request at a time. When one request gets completed another one starts executing and so on. In order to simulate this I developed a small code.
I tried this scenario with default play settings in a fresh new application. I tried to simulate the load and hitting url multiple times from different tabs in browser.
This is my Akka Configuration
akka.actor.default-dispatcher.fork-join-executor.pool-size-max =64
//This is my Controller Action
import play.api.libs.concurrent.Execution.Implicits._
def sayHello = Action { implicit request =>
println("before")
Async {
Thread.sleep(20000)
WS.url("http://www.example.com").get().map { response =>
// This code block is executed in the imported default execution context
// which happens to be the same thread pool in which the outer block of
// code in this action will be executed.
Ok("The response code was " + response.status)
}
}
}
Behavior is same...Subsequent requests do not get into action until previous request has completed implying that only one request at a time is being executed.
Akka version 2.3.0 (Though it works same even with 2.2.3) Play version 2.2.1
Looking for help from community here..or I am doing something wrong?
![Thread details][1]
RMI TCP Accept-0 4:58.094 (100.0%) 0.0 (0.0%) 0.0 (0.0%) 0.0 (0.0%) 4:58.094 Attach Listener 4:58.094 (100.0%) 0.0 (0.0%) 0.0 (0.0%) 0.0 (0.0%) 4:58.094 Thread-7 4:58.094 (100.0%) 0.0 (0.0%) 0.0 (0.0%) 0.0 (0.0%) 4:58.094 Thread-6 4:58.094 (100.0%) 0.0 (0.0%) 0.0 (0.0%) 0.0 (0.0%) 4:58.094 process reaper 4:58.094 (100.0%) 0.0 (0.0%) 0.0 (0.0%) 0.0 (0.0%) 4:58.094 Signal Dispatcher 4:58.094 (100.0%) 0.0 (0.0%) 0.0 (0.0%) 0.0 (0.0%) 4:58.094 main 4:58.094 (100.0%) 0.0 (0.0%) 0.0 (0.0%) 0.0 (0.0%) 4:58.094 RMI TCP Connection(2)-192.168.5.29 4:57.261 (100.0%) 0.0 (0.0%) 0.0 (0.0%) 0.0 (0.0%) 4:57.261 RMI TCP Connection(1)-192.168.5.29 2:42.952 (68.1%) 0.0 (0.0%) 1:16.078 (31.8%) 0.0 (0.0%) 3:59.030 JMX server connection timeout 52 0.0 (0.0%) 0.0 (0.0%) 4:58.094 (100.0%) 0.0 (0.0%) 4:58.094 RMI Scheduler(0) 0.0 (0.0%) 0.0 (0.0%) 4:58.094 (100.0%) 0.0 (0.0%) 4:58.094 Thread-4 0.0 (0.0%) 0.0 (0.0%) 4:58.094 (100.0%) 0.0 (0.0%) 4:58.094 Finalizer 0.0 (0.0%) 0.0 (0.0%) 4:58.094 (100.0%) 0.0 (0.0%) 4:58.094 Reference Handler 0.0 (0.0%) 0.0 (0.0%) 4:58.094 (100.0%) 0.0 (0.0%) 4:58.094
regards,
Marut
Upvotes: 0
Views: 115
Reputation: 29433
Make sure you are running in production mode when testing this: play start
And double check your thread configuration based on the docs: http://www.playframework.com/documentation/2.2.x/ThreadPools
You will need to make sure you have sized your thread pools according to how many blocking requests you want to handle at a time. You can use jvisualvm
to see your thread usage.
Upvotes: 1