在akka http服务器的play框架中使用更多线程

rjee0c15  于 2021-08-25  发布在  Java
关注(0)|答案(1)|浏览(395)

我们有一个web服务器,从去年开始在生产中运行,没有任何问题,但最近用户群激增,从那时起,我们看到工作时间严重缓慢,有时我们也看到服务器没有响应,所以这对我们来说是一个严重的问题。
我们观察到,db端的最大利用率为最多8个活动连接,而不是更多。因此,我们将问题缩小到“play framework或akka服务器只允许有限的线程池来管理所有负载,从而导致瓶颈”。
由于对play框架和akka http服务器还比较陌生,我们尝试了以下各种组合的配置,但在运行时仍然没有看到线程池的增加。始终为8。注意:在具有8个逻辑核的pc和具有6个核的生产服务器上,此“8”是一致的。
线程名称示例供参考:
application-akka.actor.default-dispatcher-3
下面是示例配置:


# akka.action.default-dispatcher.executor = "fork-join-executor" akka.action.default-dispatcher.executor = "thread-pool-executor"

# akka.action.default-dispatcher.throughput = 100 akka.action.default-dispatcher.thread-pool-executor.fixed-pool-size = 300

# akka.action.default-dispatcher.thread-pool-executor.core-pool-size-min = 2

# akka.action.default-dispatcher.thread-pool-executor.core-pool-size-factor = 2.0

# akka.action.default-dispatcher.thread-pool-executor.core-pool-size-max = 10

# akka.action.default-dispatcher.fork-join-executor.parallelism-max = 24

akka.http.host-connection-pool.max-connections = 20
2w3kk1z5

2w3kk1z51#

您的问题非常广泛,很难给出一个明确的答案,但除了akka线程池执行器的大小可能需要在阻止调用时有所增加外,还有一个数据库池配置:

play.db.prototype.hikaricp.maximumPoolSize = 20

我建议阅读官方文件的两部分:
https://www.playframework.com/documentation/2.8.x/accessingansqldatabase#using-a-customexecutioncontext
https://www.playframework.com/documentation/2.8.x/accessingansqldatabase#configuring-连接池

相关问题