Scala: corePoolSize to maximize the Actor performance

I'm trying to make a Scala application server based on the classic worker pool model. Given that:

  1. the machine has a quad-core processor
  2. there is a scheduler actor which is dedicated to blocking network I/O to listen
  3. worker actors are all non-blocking.

What would be the best value for corePoolSize to maximize the performance? Ideally the performance is maximized when the size of the worker thread pool is equal to the number of processor cores. So in this case, I guess the best value would be 5 (1 for the scheduler and the other 4 for the workers), or alternatively I could set the value to 4 and override the scheduler method of the scheduler actor so that it will not share the thread pool with the workers.

Is this correct? Any advice appreciated. Thanks!

Answers


Just some hints.

Ideally the performance is maximized when the size of the worker thread pool is equal to the number of processor cores.

Not really. Here is how you could estimate the number of threads at which you can get maximum throughput:

N = C * U * (1 + W/C) 

where N = number of threads, C = number of CPU cores, U = target CPU utilization rate, W/C = Waiting time to Computing time ratio (waiting time means IO etc.).

Note however that the above equation only considers CPU, and CPU isn't the only resource to manage. Tuning for response time would also be a bit different matter.

The cliche answer is that you have to test in order to see what't the best option. You can probably use the above formula as a starting point. Note also that core pool size != max pool size.


Need Your Help

Expressjs response as JSON and Xml

xml json node.js express node-mysql

What i am doing:: I am trying to generate json and xml output for a dataset from database

Custom X86_64 calling convention to C function call

c assembly x86-64 calling-convention libffi

I've to do an interface (say, a wrapper) that allow a call from X86_64 assembly code using his calling convention to C function, with other calling convention. The best thing would be to be pretty "