Grails连接池性能问题

Grails连接池性能问题,grails,connection-pooling,hikaricp,Grails,Connection Pooling,Hikaricp,在对我的项目进行性能分析期间,我发现了几个与连接池有关的问题。每个查询都运行以下代码以使用会话工厂的连接池: def sql = new Sql(sessionFactory.getCurrentSession().connection()) def resultList = sql.rows(sqlQuery,parameters) 每个线程中的第一个会话工厂请求通常需要200到300毫秒,而后续查询(即使是相同的查询)也需要50到80毫秒 我切换到HikariCP只是为了比较,性能时间缩短

在对我的项目进行性能分析期间,我发现了几个与连接池有关的问题。每个查询都运行以下代码以使用会话工厂的连接池:

def sql = new Sql(sessionFactory.getCurrentSession().connection())
def resultList = sql.rows(sqlQuery,parameters)
每个线程中的第一个会话工厂请求通常需要200到300毫秒,而后续查询(即使是相同的查询)也需要50到80毫秒

我切换到HikariCP只是为了比较,性能时间缩短了一半,主要是因为每个线程中的初始连接没有延迟。在默认的Grails连接池管理器(commons dbcp连接池根据)中,是什么导致每个线程中的第一个连接花费如此长的时间

数据源:

    dataSource {
        pooled = true
        logSql = true
        loggingSql = true//change this to true to get hibernate logging in your console
        dialect="org.hibernate.dialect.DB2Dialect"
        driverClassName = "com.ibm.db2.jcc.DB2Driver"
        username = "notReal"
        password = "notReal"
        url = 'NOTREAL'
        pooled = true
        readOnly = true
        properties {
            initialSize = 4
            minIdle = 1
            maxIdle = 8
            maxActive = 100
            maxWait = 2000
            maxAge = 60000
            minEvictableIdleTimeMillis=30000
            timeBetweenEvictionRunsMillis=30000
            abandonWhenPercentageFull = 50
            numTestsPerEvictionRun=3
            testOnBorrow=true
            testWhileIdle=true
            testOnReturn=true
            validationQuery="SELECT 1"
            validationInterval=500
        }
    }

hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = true
    cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
}
Grails版本:

Groovy/Grails Tool Suite 
Version: 3.6.2.RELEASE
Platform: Eclipse Kepler SR2 (4.3.2)

那是因为HikariCP岩石。