I know how to create my own ExecutionContext or import a global playback platform. But I must admit that I am far from being an expert on how several context / executionServices functions will work in the opposite direction.
So my question is: for the best performance / behavior of my service, which should I use ExecutionContext?
I checked two options:
import play.api.libs.concurrent.Execution.defaultContext
and
implicit val executionContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()))
Both results lead to comparable characteristics.
The action I'm using is implemented in playframework 2.1.x. SedisPool is my own object with additional future packaging for the regular sedis / jedis client pool.
def testaction(application: String, platform: String) = Action {
Async(
SedisPool.withAsyncClient[Result] { client =>
client.get(StringBuilder.newBuilder.append(application).append('-').append(platform).toString) match {
case Some(x) => Ok(x)
case None => Results.NoContent
}
})
}
, Node.js Go. , . , Java ( redis jedis ). gatling. "" redis, " ".
fyrie (, , API), , Sedis.
. playframework/ scala.
? - ? scala , , .
.
- !
, :
Runtime.getRuntime(). AvailableProcessors() * 20
15% 20% ( ), , Node.js, ( ). :
- 15x 25x 20, , . ? ?
- , ? " "?
- 20x /jvm, ?
-
.
http://www.playframework.com/documentation/2.1.0/ThreadPools
IO -, , Akka.dispatchers, *.conf ( ).
,
implicit val redis_lookup_context: ExecutionContext = Akka.system.dispatchers.lookup("simple-redis-lookup")
,
akka{
event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
loglevel = WARNING
actor {
simple-redis-lookup = {
fork-join-executor {
parallelism-factor = 20.0
#parallelism-min = 40
#parallelism-max = 400
}
}
}
}
5% - ( ) , JVM "". , .
. ?