commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Melih Utkan UNSAL <melihut...@yahoo.com>
Subject Re: [DBCP] getting connection from the pool takes long time
Date Sun, 22 Feb 2009 14:40:37 GMT
Thanks Mark

By the way, i made a mistake when i wrote the mail.

my configuration is like that;

config.minIdle = 10;
config.maxIdle = 50;

and PooledConnection.VALIDATEQUERY = "select col1 from table1"

However, i am anxious about enabling the evictor because it may cause performance problem.
Am i right?






________________________________
From: Mark Thomas <markt@apache.org>
To: Commons Users List <user@commons.apache.org>
Sent: Sunday, February 22, 2009 3:52:44 PM
Subject: Re: [DBCP] getting connection from the pool takes long time

Melih Utkan UNSAL wrote:
> GenericObjectPool.Config config = new GenericObjectPool.Config();
> config.maxActive = -1;

> config.minIdle = 50;
> config.maxIdle = 10;
minIdle > maxIdle doesn't make sense
With no evictor, these have no effect

> config.maxWait = -1;
> config.testOnBorrow = true;
> config.testOnReturn = true;

> config.testWhileIdle = true;
With no evictor, this has no effect

> config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
No need for this - pool is infinite

> config.timeBetweenEvictionRunsMillis = -1;

> config.minEvictableIdleTimeMillis = -1;
> config.softMinEvictableIdleTimeMillis=-1;
> config.numTestsPerEvictionRun = -1;
No need for these, there is no evictor

> GenericObjectPool connectionPool = new GenericObjectPool(null,config);
> ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(systemConnString,
systemUser, systemPassword);
> PoolableConnectionFactory
> poolableConnectionFactory = new
> PoolableConnectionFactory(connectionFactory, connectionPool, null,
> PooledConnection.VALIDATEQUERY, false, true);

What is PooledConnection.VALIDATEQUERY

> Class.forName("org.apache.commons.dbcp.PoolingDriver");
> PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
> driver.registerPool("example", connectionPool);
> 
> when i need a connection, i get it like that;
> 
> Connection con = DriverManager.getConnection("jdbc:apache:commons:dbcp:example");
> 
> when i do not need any more, i just close the connection like that;
> 
> con. close
> 
> 
> My applicaiton works fine but sometimes, it takes very long time (50000,60000,70000,80000,
90000 MILISECONDS)  getting a connection from the pool. 
> (It happens sometimes not always) And because of that ,performance is not acceptable.

> 
> What do you think the problem is?

Could be many things. My guess would be either -
- a connection leak is the root cause and the symptom you are seeing is
as a result of hitting some connection / cursor limit in Oracle.
- you are receiving connections that have been idle for so long, Oracle
has closed then and the delay you are seeing is the timeout on the
validation query

I would suggest the following:
- clean up your config
- enable the evictor thread
- monitor current connections in Oracle
- consider limiting the size of your connection pool
- test with the abandoned object pool to see if you have any connection
leaks
- Add some logging to your app to record size of the pool / connections
in use and check it agrees with Oracle

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


      
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message