What I want to do is to test the performance of two methods:
- using a single thread pool and submit one big runnable contains all the work.
- divide work into different stages, each stage uses an actor
In test#1, I created a fixed thread pool with 40 threads, and a runnable contains 1 file io, 80ms sleep, 150ms cpu-spin. Then I submitted 10000 tasks, it costs 50s to finish all the tasks.
In test#2, I created four actors, everyone with its own dispatcher. the configuration is as below:(four actors have same configuration, I only paste one):
stage1-pool {
type = Dispatcher
executor = "thread-pool-executor"
thread-pool-executor {
fixed-pool-size = 10
}
throughput = 100
}
akka.actor.deployment {
/stage1Actor {
dispatcher = stage1-pool
router = round-robin-pool
nr-of-instances = 10
}
}
stage1 actor contains 1 file-io, 20ms sleep; stage2,3,4 actors each contains 20ms sleep and 50ms cpu-spin. so you can see the overall work in test1 and test2 are the same. Then I again submitted 10000 job to this topo. and It takes sooooo long(no specific time, I shutdown it down after several mins).
Please correct me if the whole experiment is wrong, and please tell me why akka in this user case is so slow.
the test code and thread view from jProfile can be found : https://github.com/legatoo/actors-vs-single-thread-pool.
Thank you so much.