What is the correct way to configure the pool size of HikariCP for Play w/ and w/o Slick?
I've tried this with slick:
slick.dbs.default.db.minimumIdle=30
slick.dbs.default.db.maximumPoolSize=30
(other properties like connectionTestQuery seem to work this way)
And w/o Slick I've tried various combinations of:
play.db.default.minimumIdle=30
play.db.default.maximumPoolSize=30
And:
play.db.default.prototype.hikaricp.minimumIdle=30
play.db.default.prototype.hikaricp.maximumPoolSize=30
I've seen the documentation, but nothing seems to stick.
Description. Generic defaults. spring.datasource.hikari.maximum-pool-size=50. Specifies number of database connections between database and application. This property controls the maximum size that the pool is allowed to reach, including both idle and in-use connections.
Summary. "HikariCP is solid high-performance JDBC connection pool. A connection pool is a cache of database connections maintained so that the connections can be reused when future requests to the database are required. Connection pools may significantly reduce the overall resource usage." - You can find out more here.
spring.datasource.hikari.maxLifetime: This property controls the maximum lifetime of a connection in the pool. An in-use connection will never be retired, only when it is closed will it then be removed. The minimum allowed value is 30000ms (30 seconds). Default: 1800000 (30 minutes)
Hikari is a JDBC DataSource implementation that provides a connection pooling mechanism. Compared to other implementations, it promises to be lightweight and better performing. For an introduction to Hikari, see this article.
To configure Hikari Connection Pool you can use the application.properties file. Here is a sample configuration: spring.datasource.hikari.autoCommit: This property controls the default auto-commit behavior of connections returned from the pool. It is a boolean value. Default: true
In this tutorial, we introduce HikariCP and show how to set up HicariCP connection pool in Java applications. In our applications, we make requests to the MySQL database. HikariCP is solid high-performance JDBC connection pool.
spring.datasource.hikari.minimumIdle: This property controls the minimum number of idle connections that HikariCP tries to maintain in the pool. If the idle connections dip below this value and total connections in the pool are less than maximumPoolSize, HikariCP will make a best effort to add additional connections quickly and efficiently.
Default: 1800000 (30 minutes) spring.datasource.hikari.minimumIdle: This property controls the minimum number of idle connections that HikariCP tries to maintain in the pool.
I think the correct syntax is
play.db.default.hikaricp.minimumIdle=30
play.db.default.hikaricp.maximumPoolSize=30
but this does not seem to work with Slick
Furthermore, be aware that any configuration under play.db is not considered by Play Slick.
You can try something like
slick.dbs.default.db.numThreads=30
slick.dbs.default.db.queueSize=30
Don't take it a wrong way, actually in slick 3.x, the pool size is decided by numThreads value in configuration, the min size is numThreads, and the max size is numThreads * 5, the configuration value of pool size simple not use at its HikariCP wrapper.
SBT Dependancy HikariCP Connection Pool
// https://mvnrepository.com/artifact/com.zaxxer/HikariCP
libraryDependencies += "com.zaxxer" % "HikariCP" % "2.3.2"
Use HikariDatasource with imports , and use setMaximumPoolSize() method of hikari config, like below
import com.zaxxer.hikari.HikariDataSource
import com.zaxxer.hikari.HikariConfig
var datasource: HikariDataSource = null
var hc: HikariConfig = new HikariConfig();
hc.setMinimumIdle(--- anything ,depends)
hc.setMaximumPoolSize(300 or anything)
-- set other properties like jdbc url ,user name , password ,database name etc which are needed
set hikari config object to hikari data sourse
var ds: HikariDataSource = new HikariDataSource(hc);
datasource = ds
and use datasource .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With