我在AWS ECS上测试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 :(得分:0)
可能,是的。我认为那是线程名称。
如果您在服务器上执行a thread dump,它是否有很多开放线程?
看起来您的服务器每个连接泄漏一个线程。
(在开发机器上调试和诊断它可能要容易得多,而不是在EC2 VM上。尝试在本地重现它。)
答案 1 :(得分:0)
根据此akka-http github问题,似乎没有问题:https://github.com/akka/akka-http/issues/722
答案 2 :(得分:-1)
对于你的问题,请查看此评论:
Akka http server dispatcher number constantly increasing
关于调度员:
将默认调度程序用于健康检查等操作是没有问题的。
线程由您指定的调度程序控制,如果未指定,则由 default-dispatcher 控制。 default-dispatcher 设置如下,这意味着线程池大小介于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操作需要很长时间并阻止其他操作,下面是如何在Akka HTTP中为它们指定自定义调度程序: http://doc.akka.io/docs/akka-http/current/scala/http/handling-blocking-operations-in-akka-http-routes.html