Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #762 from nraychaudhuri/998_akka_dispatcher

configuring actor system and dispatchers
  • Loading branch information...
commit d1f2e401ac5fccc3ce9580799617c8335fd551ac 2 parents 2bfde8c + f40c88a
@jroper jroper authored
View
56 documentation/manual/detailledTopics/configuration/ThreadPools.md
@@ -66,7 +66,7 @@ The default thread pool can be configured using standard Akka configuration in `
```
play {
akka {
- event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
+ event-handlers = ["akka.event.Logging$DefaultLogger", "akka.event.slf4j.Slf4jEventHandler"]
loglevel = WARNING
actor {
default-dispatcher = {
@@ -90,7 +90,7 @@ In certain circumstances, you may wish to dispatch work to other thread pools.
```scala
object Contexts {
- implicit val myExecutionContext: ExecutionContext = Akka.system.dispatchers.lookup("my-context")
+ implicit val myExecutionContext: ExecutionContext = Akka.system.dispatchers.lookup("akka.actor.my-context")
}
```
@@ -135,7 +135,7 @@ Below we outline a few common profiles that people may want to use in Play Frame
### Pure asynchronous
-In this case, you are doing no blocking IO in your application. Since you are never blocking, the default configuration of one thread per processor suits your use case prefectly, so no extra configuration needs to be done. The Play default execution context can be used in all cases.
+In this case, you are doing no blocking IO in your application. Since you are never blocking, the default configuration of one thread per processor suits your use case perfectly, so no extra configuration needs to be done. The Play default execution context can be used in all cases.
### Highly synchronous
@@ -166,43 +166,45 @@ This profile is recommended for Java applications that do synchronous IO, since
This profile is for when you want to do a lot of synchronous IO, but you also want to control exactly how much of which types of operations your application does at once. In this profile, you would only do non blocking operations in the default execution context, and then dispatch blocking operations to different execution contexts for those specific operations.
-In this case, you might create a number of different execution contexts for different types of opreations, like this:
+In this case, you might create a number of different execution contexts for different types of operations, like this:
```scala
object Contexts {
- implicit val simpleDbLookups: ExecutionContext = Akka.system.dispatchers.lookup("simple-db-lookups")
- implicit val expensiveDbLookups: ExecutionContext = Akka.system.dispatchers.lookup("expensive-db-lookups")
- implicit val dbWriteOperations: ExecutionContext = Akka.system.dispatchers.lookup("db-write-operations")
- implicit val expensiveCpuOperations: ExecutionContext = Akka.system.dispatchers.lookup("expensive-cpu-operations")
+ implicit val simpleDbLookups: ExecutionContext = Akka.system.dispatchers.lookup("akka.actor.simple-db-lookups")
+ implicit val expensiveDbLookups: ExecutionContext = Akka.system.dispatchers.lookup("akka.actor.expensive-db-lookups")
+ implicit val dbWriteOperations: ExecutionContext = Akka.system.dispatchers.lookup("akka.actor.db-write-operations")
+ implicit val expensiveCpuOperations: ExecutionContext = Akka.system.dispatchers.lookup("akka.actor.expensive-cpu-operations")
}
```
These might then be configured like so:
```
-akka {
- actor {
- simple-db-lookups {
- fork-join-executor {
- parallelism-factor = 10.0
+play {
+ akka {
+ actor {
+ simple-db-lookups {
+ fork-join-executor {
+ parallelism-factor = 10.0
+ }
}
- }
- expensive-db-lookups {
- fork-join-executor {
- parallelism-max = 4
+ expensive-db-lookups {
+ fork-join-executor {
+ parallelism-max = 4
+ }
}
- }
- db-write-operations {
- fork-join-executor {
- parallelism-factor = 2.0
+ db-write-operations {
+ fork-join-executor {
+ parallelism-factor = 2.0
+ }
}
- }
- expensive-cpu-operations {
- fork-join-executor {
- parallelism-max = 2
+ expensive-cpu-operations {
+ fork-join-executor {
+ parallelism-max = 2
+ }
}
}
- }
+ }
}
```
@@ -210,4 +212,4 @@ Then in your code, you would create futures and pass the relevant execution cont
### Few specific thread pools
-This is a combination between the many specific thread pools and the highly synchronised profile. You would do most simple IO in the default execution context and set the number of threads there to be reasonably high (say 100), but then dispatch certain expensive operations to specific contexts, where you can limit the number of them that are done at one time.
+This is a combination between the many specific thread pools and the highly synchronized profile. You would do most simple IO in the default execution context and set the number of threads there to be reasonably high (say 100), but then dispatch certain expensive operations to specific contexts, where you can limit the number of them that are done at one time.
View
26 framework/src/play/src/main/resources/reference.conf
@@ -6,35 +6,11 @@ promise.akka.actor.typed.timeout=5s
play {
akka {
- event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
+ event-handlers = ["akka.event.Logging$DefaultLogger", "akka.event.slf4j.Slf4jEventHandler"]
loglevel = WARNING
actor {
-
- deployment {
-
- /actions {
- router = round-robin
- nr-of-instances = 24
- }
-
- }
-
retrieveBodyParserTimeout = 1 second
-
- actions-dispatcher = {
- fork-join-executor {
- parallelism-factor = 1.0
- parallelism-max = 24
- }
- }
-
- websockets-dispatcher = {
- fork-join-executor {
- parallelism-factor = 1.0
- parallelism-max = 24
- }
- }
default-dispatcher = {
fork-join-executor {
View
2  framework/src/play/src/main/scala/play/api/libs/concurrent/Akka.scala
@@ -59,7 +59,7 @@ class AkkaPlugin(app: Application) extends Plugin {
lazy val applicationSystem: ActorSystem = {
applicationSystemEnabled = true
- val system = ActorSystem("application", app.configuration.underlying, app.classloader)
+ val system = ActorSystem("application", app.configuration.underlying.getConfig("play"), app.classloader)
Logger("play").info("Starting application default Akka system.")
system
}
View
2  framework/test/integrationtest/test/FunctionalSpec.scala
@@ -79,7 +79,7 @@ class FunctionalSpec extends Specification {
browser.goTo("/conf")
browser.pageSource must contain("This value comes from complex-app's complex1.conf")
browser.pageSource must contain("override akka:2 second")
- browser.pageSource must contain("akka-loglevel:DEBUG")
+ browser.pageSource must contain("akka-loglevel:WARNING")
browser.pageSource must contain("promise-timeout:7000")
browser.pageSource must contain("None")
browser.title must beNull
Please sign in to comment.
Something went wrong with that request. Please try again.