如何调整AKKA中工人启动的线程数? [英] how to tune number of threads started by workers in AKKA?

查看:541
本文介绍了如何调整AKKA中工人启动的线程数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个将Round路由器与Akka结合使用的应用程序.该应用程序获取文件列表并对其进行并行处理.我的问题是,无论我指定该应用程序有多少工作人员,一次只能处理12个文件.我需要更改某些设置吗?

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)))

更新:我试图以编程方式通过config发送参数..仍然无法正常工作.

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)

推荐答案

好,我已解决此问题,但缺少子配置 代替

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

应该是

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

这篇关于如何调整AKKA中工人启动的线程数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆