how to tune number of threads started by workers i

2019-04-16 22:37发布

I created an application that uses Akka with RoundRobin routers. The application takes a list of files and the processes them in parallel. My issue is that regardless of the number of workers that I specify the application processes only 12 files at a time. Is there a certain setting that I need to change ?

   val workers = context.actorOf(Props[ItemProcessingWorker].withRouter(RoundRobinRouter(nworkers)))

update: I tried to send the params via config programmatically.. still not working.

    val conf1 = ConfigFactory.load(ConfigFactory.parseString("""
 akka {
  default-dispatcher {
    # Dispatcher is the name of the event-based dispatcher
    type = Dispatcher
    # What kind of ExecutionService to use
    executor = "fork-join-executor"
    # Configuration for the fork join pool
    fork-join-executor {
      # Min number of threads to cap factor-based parallelism number to
      parallelism-min = 32
      # Parallelism (threads) ... ceil(available processors * factor)
      parallelism-factor = 1.0
      # Max number of threads to cap factor-based parallelism number to
      parallelism-max = 32
    }
    # Throughput defines the maximum number of messages to be
    # processed per actor before the thread jumps to the next actor.
    # Set to 1 for as fair as possible.
    throughput = 1000
  }}

 """))
 val system = ActorSystem("MySystem2",conf1)

2条回答
疯言疯语
2楼-- · 2019-04-16 23:23

ok I got this resolved, I was missing a sub configuration instead of

akka {
  default-dispatcher {
    type = Dispatcher
    executor = "thread-pool-executor"
    throughput = 1000    
    fork-join-executor {
      parallelism-min = 32
      parallelism-factor = 0.5
      parallelism-max = 64
    }
  }
}

it should be

akka {
  actor{
    default-dispatcher {
      type = Dispatcher
      executor = "thread-pool-executor"
      throughput = 1000    
      fork-join-executor {
        parallelism-min = 32
        parallelism-factor = 0.5
        parallelism-max = 64
      }
    }
  }
}
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-04-16 23:29

In your resources/application.conf try changing the values of the default-dispatcher

akka {
      default-dispatcher {
        # Dispatcher is the name of the event-based dispatcher
        type = Dispatcher
        # What kind of ExecutionService to use
        executor = "fork-join-executor"
        # Configuration for the fork join pool
        fork-join-executor {
          # Min number of threads to cap factor-based parallelism number to
          parallelism-min = 16
          # Parallelism (threads) ... ceil(available processors * factor)
          parallelism-factor = 2.0
          # Max number of threads to cap factor-based parallelism number to
          parallelism-max = 32
        }
        # Throughput defines the maximum number of messages to be
        # processed per actor before the thread jumps to the next actor.
        # Set to 1 for as fair as possible.
        throughput = 20
      }
}
查看更多
登录 后发表回答