设置连接池使Slick

设置连接池使Slick

本文介绍了设置连接池使Slick 3.0崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Slick 3.0与MySql一起使用,并且我要调整的性能越来越差。我用

I'm using Slick 3.0 with MySql and I'm getting terrible performance, which I want to tune. I initialize the database with

val db = Database.forConfig("horridDBStuff")

然后在 application.conf 我有

horridDBStuff = {
    url = "jdbc:mysql://my.db.address:3306/myschema"
    driver = "com.mysql.jdbc.Driver"
    connectionPool = disabled
    keepAliveConnection = true
    properties = {
        user = "me"
        password = "me"
    }
}

光滑的文档说,在部署中应该启用连接池,所以这就是我想要的尝试。但是,它没有提供如何执行此操作的示例。我尝试注释掉该行,或替换为 connectionPool =已启用 connectionPool = 10 。所有这些都使Slick崩溃并带有多页错误堆栈。有人知道如何正确配置connectionPool吗? (任何其他性能建议也将不胜感激-我尝试添加 numThreads = 10 似乎并没有多大改善,但至少不会使它崩溃;)

Slick documentation says that in deployment you should enable the connection pool, so that's what I want to try. However it doesn't give an example of how to do this. I've tried commenting the line out, or replacing with connectionPool = enabled, or connectionPool = 10. All of these just crash Slick with a multi-page error stack. Anyone know how to properly configure the connectionPool? (Any other performance suggestions would also be appreciated - I've tried adding numThreads=10 which doesn't seem to improve things much, but at least that doesn't crash it ;)

推荐答案

Slick 3.0使用默认情况下。 上有大量文档,用于调整信息。只要您不介意使用HikariCP,就根本不需要使用connectionPool参数。

Slick 3.0 uses HikariCP by default. There's a ton of documentation on its project page for tuning information. As long as you don't mind using HikariCP, you should not need a connectionPool param at all.

话虽如此,您可以在应用程序中设置connectionPool = HikariCP .conf并不会引发错误,尽管除了自我说明以外,这似乎是多余的。

That being said, you could could set connectionPool = HikariCP in your application.conf and that will not throw an error, though other than self-documentation, this seems redundant.

这篇关于设置连接池使Slick 3.0崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 22:40