I build my play service with Play2.4 and default netty server. I started the service on a server with a 8 cores processor, and use the below command to test.
ab -c 2000 -n 20000 <test_url>
It takes 12.856s to complete when i set parallelism-factor
as 1.0.
it takes 39.95s to complete when i change parallelism-factor
to 2.0.
CPU and Memory usages are very low for both cases.
The test covers I/O operations, it seems more threads can save I/O waiting time and process more requests. But why more threads slow down the processing? How can I improve the throughput ?
test code as below.
public Result checkPerformance() {
Random random = new Random();
int skip = random.nextInt(20000);
// do some database query
return ok("request completed");
}
the thread settings in application.conf as below
akka {
actor {
default-dispatcher {
fork-join-executor {
parallelism-factor = 2.0 # 1.0
parallelism-min = 8
parallelism-max = 40
}
}
}
}