在Play 2.x中配置actor的正确方法是什么?
问题描述:
我注意到了2.1和2.0的文档之间存在细微的差别:在Play 2.x中配置actor的正确方法是什么?
akka.default-dispatcher.core-pool-size-max = 64
akka.debug.receive = on
akka.default-dispatcher.fork-join-executor.pool-size-max =64
akka.actor.debug.receive = on
Akka's own documentation有core-pool-size-max
设置像2.0,但没有pool-size-max
像2.1。为什么在2.0和2.1之间变化?在Play中配置Akka的正确方法是?这是一个版本中的文档错误吗? (同时,我将尝试在我的Play 2.1配置中保留两种配置样式,并希望最好)。
答
首先,在您要链接到未发布的Akka版本快照文档(即快照)的情况下,请始终使用您正在使用的版本的文档。
这里的2.1.2文档:http://doc.akka.io/docs/akka/2.1.2/scala/dispatchers.html(也doc.akka.io访问)
当我们看那个页面,我们可以看到下的fork-join-执行和线程例如配置-pool执行人它说:“更多选项,请参阅配置的默认调度部分。”,链接:
我们在哪里可以找到:
# This will be used if you have set "executor = "thread-pool-executor""
thread-pool-executor {
# Keep alive time for threads
keep-alive-time = 60s
# Min number of threads to cap factor-based core number to
core-pool-size-min = 8
# The core pool size factor is used to determine thread pool core size
# using the following formula: ceil(available processors * factor).
# Resulting size is then bounded by the core-pool-size-min and
# core-pool-size-max values.
core-pool-size-factor = 3.0
# Max number of threads to cap factor-based number to
core-pool-size-max = 64
# Minimum number of threads to cap factor-based max number to
# (if using a bounded task queue)
max-pool-size-min = 8
# Max no of threads (if using a bounded task queue) is determined by
# calculating: ceil(available processors * factor)
max-pool-size-factor = 3.0
# Max number of threads to cap factor-based max number to
# (if using a bounded task queue)
max-pool-size-max = 64
# Specifies the bounded capacity of the task queue (< 1 == unbounded)
task-queue-size = -1
# Specifies which type of task queue will be used, can be "array" or
# "linked" (default)
task-queue-type = "linked"
# Allow core threads to time out
allow-core-timeout = on
}
因此得出结论,您需要设置defau lt-dispatcher使用"thread-pool-executor"
如果要使用ThreadPoolExecutor,则使用akka.default-dispatcher.executor = "thread-pool-executor"
,然后指定该线程池执行程序的配置。
这有帮助吗?
干杯, √
AMM,我不想改变执行者,仅仅调整了默认的一个作为例子Play的配置 - 我只是想知道,为什么对游戏2.1的文档从播放不同2.0 - 无论是真正的API更改,还是文档错误。无论如何,我只想设置'core-pool-size-max'或'pool-size-max'。 – ripper234 2013-05-12 15:17:15
但是您需要更改正确实施的设置。默认调度程序使用fork-join-executor,因此除非更改执行程序,否则必须更改设置。请参阅文档。 – 2013-05-12 20:37:44