1

我注意到了2.1和2.0的文檔之間存在細微的差別:在Play 2.x中配置actor的正確方法是什麼?

2.0

akka.default-dispatcher.core-pool-size-max = 64 
akka.debug.receive = on 

2.1

akka.default-dispatcher.fork-join-executor.pool-size-max =64 
akka.actor.debug.receive = on 

Akka's own documentationcore-pool-size-max設置像2.0,但沒有pool-size-max像2.1。爲什麼在2.0和2.1之間變化?在Play中配置Akka的正確方法是?這是一個版本中的文檔錯誤嗎? (同時,我將嘗試在我的Play 2.1配置中保留兩種配置樣式,並希望最好)。

回答

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",然後指定該線程池執行程序的配置。

這有幫助嗎?

乾杯, √

+0

AMM,我不想改變執行者,僅僅調整了默認的一個作爲例子Play的配置 - 我只是想知道,爲什麼對遊戲2.1的文檔從播放不同2.0 - 無論是真正的API更改,還是文檔錯誤。無論如何,我只想設置'core-pool-size-max'或'pool-size-max'。 – ripper234 2013-05-12 15:17:15

+0

但是您需要更改正確實施的設置。默認調度程序使用fork-join-executor,因此除非更改執行程序,否則必須更改設置。請參閱文檔。 – 2013-05-12 20:37:44

相關問題