2016-12-30 53 views
0

我正在测试AWS ECS上的akka​​ http服务。每个实例都添加到负载均衡器中,负载均衡器定期向健康检查路由发出请求。由于这是一个测试环境,我可以控制没有其他流量进入服务器。我注意到这表明“默认调度员”数量持续增加的调试日志:Akka http服务器调度程序编号不断增加

[DEBUG] [01/03/2017 22:33:03.007] [default-akka.actor.default-dispatcher-41200] [akka://default/system/IO-TCP/selectors/$a/0] New connection accepted 
[DEBUG] [01/03/2017 22:33:29.142] [default-akka.actor.default-dispatcher-41196] [akka://default/system/IO-TCP/selectors/$a/0] New connection accepted 
[DEBUG] [01/03/2017 22:33:33.035] [default-akka.actor.default-dispatcher-41204] [akka://default/system/IO-TCP/selectors/$a/0] New connection accepted 
[DEBUG] [01/03/2017 22:33:59.174] [default-akka.actor.default-dispatcher-41187] [akka://default/system/IO-TCP/selectors/$a/0] New connection accepted 
[DEBUG] [01/03/2017 22:34:03.066] [default-akka.actor.default-dispatcher-41186] [akka://default/system/IO-TCP/selectors/$a/0] New connection accepted 
[DEBUG] [01/03/2017 22:34:29.204] [default-akka.actor.default-dispatcher-41179] [akka://default/system/IO-TCP/selectors/$a/0] New connection accepted 
[DEBUG] [01/03/2017 22:34:33.097] [default-akka.actor.default-dispatcher-41210] [akka://default/system/IO-TCP/selectors/$a/0] New connection accepted 

这种趋势不会反转,并起身到几万很快。这是正常行为还是指示问题?

编辑:我已经更新了日志片断表明调度线程数远远偏离了我所期望的。

编辑#2:这里是健康检查路线代码:

class HealthCheckRoutes()(implicit executionContext: ExecutionContext) 
    extends LogHelper { 

    val routes = pathPrefix("health-check") { 
    pathEndOrSingleSlash { 
     complete(OK -> "Ok") 
    } 
    } 
} 

回答

0

也许,是的。我认为这是线程名称。

如果你在服务器上做a thread dump,它是否有很多开放的线程?

它看起来像你的服务器每个连接泄漏一个线程。

(它可能会更易于调试和诊断此开发机器上,而不是在EC2 VM尝试在本地复制它。)

+0

感谢您的评论,我的恐惧也是线程泄漏。我会尝试在本地重现并执行线程转储。 – novon

+0

有趣的是,我无法在当地复制。默认的调度程序线程数始终低于合理的数字(〜20)。也许这与负载均衡器运行状况检查使用的http请求机制有关。 – novon

-1

对于你的问题,检查此评论:

Akka http server dispatcher number constantly increasing

关于调度员:

它是使用像健康检查操作默认调度程序没有问题。

线程由您指定的调度程序控制,或者如果未指定默认调度程序默认调度被设置如下,这意味着线程池的大小是8之间,以64或等于(数量的处理器* 3)

default-dispatcher { 
    type = "Dispatcher" 

    executor = "default-executor" 

    default-executor { 
    fallback = "fork-join-executor" 
    } 

    fork-join-executor { 
    # Min number of threads to cap factor-based parallelism number to 
    parallelism-min = 8 

    # The parallelism factor is used to determine thread pool size using the 
    # following formula: ceil(available processors * factor). Resulting size 
    # is then bounded by the parallelism-min and parallelism-max values. 
    parallelism-factor = 3.0 

    # Max number of threads to cap factor-based parallelism number to 
    parallelism-max = 64 

    # Setting to "FIFO" to use queue like peeking mode which "poll" or "LIFO" to use stack 
    # like peeking mode which "pop". 
    task-peeking-mode = "FIFO" 
    } 

Dispathcer文件: http://doc.akka.io/docs/akka/2.4.16/scala/dispatchers.html

配置参考: http://doc.akka.io/docs/akka/2.4.16/general/configuration.html#akka-actor

BTW运营需要很长的时间,并阻止其他操作,这里是如何指定阿卡HTTP定制的调度为他们: http://doc.akka.io/docs/akka-http/current/scala/http/handling-blocking-operations-in-akka-http-routes.html

+0

的问题是,我看到默认的调度程序线程数渐入几万......例如'default-akka.actor。default-dispatcher-41246' – novon

+0

我明白了。您能否粘贴Akka HTTP代码进行健康检查? – XoYo24

+0

当然,我已将路由器代码添加到我的原始帖子中。 – novon