我正在使用c3p0的弹簧应用程序的这些连接设置。 在峰值负载时,应用程序挂起。在用户上传xml文件和应用程序的峰值负载数量解组并保存在数据库中时,文件非常大,通常需要20到30秒才能完成。应用程序开始花费更多时间(负载启动2分钟后),从40s到200s完成整个过程,并在峰值负载3分钟后停止响应。
INITIAL_POOL_SIZE=25 NUM_HELPER_THREAD=6 ACQUIRE_INCREMENT=5 MAX_IDLE_TIME_EXCESS_CONNECTIONS=0 PREFERRED_TEST_QUERY=SELECT 1 FROM DUAL IS_TEST_CONNECTIONON_CHECKIN=TRUE IS_TEST_CONNECTIONON_CHECKOUT=FALSE IS_DEBUG_UNRETURNED_CONNECTION_STACK_TRACES=TRUE IDLE_CONNECTION_TEST_PERIOD=300 #MaxPoolSize
MAX_CONNECTIONS=150 MIN_POOL_SIZE=25 MAX_STATEMENTS_PER_CONNECTION=100 MAX_STATEMENTS=1000
IDLE_CONNECTION_TEST_PERIOD=300 MAX_CONNECTION_AGE=1944000
请建议!!
使用acquireIncrement初始化C3p0 - > 5,acquireRetryAttempts - > 30,acquireRetryDelay - > 500,autoCommitOnClose - > false,automaticTestTable - > null,breakAfterAcquireFailure - > false,checkoutTimeout - > 0,connectionCustomizerClassName - > null,connectionTesterClassName - > com.mchange.v2.c3p0.impl.DefaultConnectionTester,dataSourceName - > 2upg5n90m6dhnua9spyw | 6ae354b6,debugUnreturnedConnectionStackTraces - >是的,描述 - > null,driverClass - > oracle.jdbc.driver.OracleDriver,factoryClassLocation - > null,forceIgnoreUnresolvedTransactions - > false,idleConnectionTestPeriod - > 300,initialPoolSize - > 25,jdbcUrl - > XXX,maxAdministrativeTaskTime - > 0,maxConnectionAge - > 1944000,maxIdleTime - > 0,maxIdleTimeExcessConnections - > 0,maxPoolSize - > 150,maxStatements - > 1000,maxStatementsPerConnection - > 100,minPoolSize - > 25,numHelperThreads - > 6,numThreadsAwaitingCheckoutDefaultUser - > 0,preferredTestQuery - > SELECT 1 FROM DUAL,propertyCycle - > 0,testConnectionOnCheckin - > true,testConnectionOnCheckout - > false,unreturnedConnectionTimeout - > 0,usesTraditionalReflectiveProxies - >错误的]
配置:
<bean id="dataSourceFactory" class="com.common.CLDataSourceFactory"/>
<bean id="dataSource" factory-bean="dataSourceFactory" factory-method="createInstance"/>
来自CLDataSourceFactory的代码
private static final CLDataSource INSTANCE = new CLDataSource();
private static final Logger LOGGER = Logger.getLogger(CLDataSourceFactory.class);
/** This is the JVM shutdown hook to close the data source. */
static {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
LOGGER.info("JVM shutdown hook [CLSourceFactory's close data source] has been initiated.");
INSTANCE.close();
LOGGER.info("CLDataSourceFactory's close data source has been completed.");
} catch (Exception ex) {
LOGGER.error("Exception occured while CLDataSourceFactory's close data source: " + ex, ex);
}
}
});
}
public CLDataSource createInstance() {
return INSTANCE;
}