Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set HikariCP pool size with Play

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.

like image 371
codefinger Avatar asked Dec 15 '15 17:12

codefinger


People also ask

What is default Hikari pool size?

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.

How does HikariCP connection pool work?

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.

What is Hikari Max lifetime?

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)

What is Hikari connection pool in spring boot?

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.

How to configure Hikari connection pool in spring?

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

What is hicaricp connection pool in Java?

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.

What is minimumidle in Hikari spring?

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.

What are the default and minimum idle settings in hikaricp?

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.


Video Answer


3 Answers

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
like image 98
Salem Avatar answered Nov 15 '22 11:11

Salem


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.

like image 43
Tom Avatar answered Nov 15 '22 09:11

Tom


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 .

like image 42
Swadeshi Avatar answered Nov 15 '22 10:11

Swadeshi