ripper234
ripper234

Reputation: 229988

What is the correct way to configure actors in Play 2.x?

I noticed a slight difference between the documentation for 2.1 and 2.0:

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 documentation has a core-pool-size-max setting like 2.0, but no pool-size-max like 2.1. Why did this change between 2.0 and 2.1? Which is the correct way to configure Akka in Play? Is this a documentation bug in one of the versions?

(In the meantime, I'm going to try and stick both config styles in my Play 2.1 config and hope for the best).

Upvotes: 2

Views: 1922

Answers (1)

Viktor Klang
Viktor Klang

Reputation: 26579

First of all, always use the documentation for the version you're using, in your case you're linking to the snapshot documentation which is for an unreleased Akka version (i.e. a snapshot).

Here's the 2.1.2 docs: http://doc.akka.io/docs/akka/2.1.2/scala/dispatchers.html (also accessible from doc.akka.io)

When we look at that page, we see that under the example configuration for fork-join-executor and thread-pool-executor it says: "For more options, see the default-dispatcher section of the Configuration.", linking to:

Where we can find:

  # 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
  }

So to conclude, you need to set the default-dispatcher to use the "thread-pool-executor" if you want to use the ThreadPoolExecutor, by akka.default-dispatcher.executor = "thread-pool-executor" and then specify your configuration for that thread-pool-executor.

Does that help?

Cheers, √

Upvotes: 1

Related Questions