HikariCOnfig.getConnection() is taking maximum time

768 views
Skip to first unread message

Gaurav Manwani

unread,
Sep 2, 2019, 3:37:22 AM9/2/19
to HikariCP

HI,

I am doing load testing on our API that has MYSQL as DB and SPRING BOOT as framework.
i have done custom configuration of MYSQL for my API.
As i am using AWS RDS for mysql, on load test i have observed that
HikariConfig.getConnection() is taking around 91% of response time on load.

I have made two mysql connections, one for READ and one for WRITE.
This is my Configuration for HIKARICP for write and same is for read also:


hikariConfig.setDriverClassName(writeDatasourceDriveClassName);
hikariConfig.setJdbcUrl(writeDatasourceUrl);
hikariConfig.setUsername(writeDatasourceUsername)
hikariConfig.setPassword(writeDatasourcePassword);
hikariConfig.setMaximumPoolSize(50);
hikariConfig.setPoolName("writeConnectionPool");
hikariConfig.addDataSourceProperty("cachePrepStmts", true);
hikariConfig.addDataSourceProperty("prepStmtCacheSize", 256);
hikariConfig.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
hikariConfig.addDataSourceProperty("useServerPrepStmts", true);


Can anyone help me out regarding this, as i want to reduce time for HikariConfig.getConnection().

Thanks
Gaurav




Jens

unread,
Sep 8, 2019, 2:03:30 PM9/8/19
to HikariCP
hikariConfig.setMaximumPoolSize(50);

You have 50 connections in your pool as a maximum. If you have high load and all connections are handed out of the pool then getConnection() will bock until some application code has returned a connection to the pool.

Given you have made a load test, I would assume that all 50 connections are busy and additional requests have to wait.

Alternative: your application forgets to call connection.close() somewhere in which case you have a connection leak. This can also cause your pool to think you have 50 busy connections as they are never returned to the pool. You can figure that out by using HikariCP leakDetectionThreshold parameter. Configure it to the duration of your slowest query + some small constant to avoid false positives.

-- J.
Reply all
Reply to author
Forward
0 new messages