commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject Re: [dbcp] RE: MaxActive and MaxIdle
Date Sun, 19 Apr 2009 11:12:11 GMT
Ryunix wrote:
> Hi Phil,
> Since you had mentioned about the active and idle connection in dbcp, do you
> happen to know the reason why if I open the connection using 
> 'dbcp_datasource.getConnection()' and never call the connection.close(), the
> particular connection will always been treated by dbcp as 'active
> connection'?
>   

The dbcp numActive property name is probably not the best as it can be 
confusing in this sense.  What it counts is the number of connections 
that are checked out from the pool.  The invariant that the pool 
maintains is numActive + numIdle <= maxActive.   The second two property 
names can also be confusing, since "idle" to dbcp means sitting in the 
idle object pool and maxActive really bounds the sum above, which is in 
effect the total number of physical connections that the pool can have 
open from the database.  Connections that have been checked out, but 
"abandoned" by clients are included in the "active" count, as they meet 
the definition of numActive above.  Configuring abandoned connection 
removal can prevent pool starvation when badly coded applications fail 
to close connections checked out from the pool.

Phil
> Thanks
>
>
> Phil Steitz wrote:
>   
>> allen.irwin@smartintegration.com.au wrote:
>>
>> Sorry for the delayed response.  Since this list is shared for all 
>> commons components, it's best to prefix the subject line, as I have 
>> changed it above, to include the component name.  See responses to your 
>> questions below.
>>     
>>> Hello,
>>>
>>> I saw someone else ask this exact same question back in Dec but the reply
>>> they received never really answered the question, so I thought I'd try
>>> again.
>>>
>>> I am using the dbcp included within Tomcat 5.5.27.
>>>       
>> So should be dbcp 1.2.2,  pool 1.4
>>     
>>>   I configure it using
>>> context.xml with: maxActive="30" maxIdle="10"
>>>
>>> I always assumed that maxActive would limit the total amount of DB
>>> connections that could ever be open at one time (in this case 30). 
>>>       
>> That is correct.
>>     
>>>  Yet
>>> from what I see it seems like I am limited to maxActive + maxIdle
>>> connections open (in this case 40).  Is that true?
>>>   
>>>       
>> No, maxActive should limit the total number of connections, idle in the 
>> pool or checked out to clients.
>>     
>>> Also, the default behavior seems to be that the connections never close
>>> (or
>>> timeout) within the pool when they are not being used. 
>>>       
>> Yes, the default behavior is not to validate or time out connections 
>> while they are idle in the pool.  You can change this behavior by 
>> setting timeBetweenEvictionRunsMillis and minEvictableIdleTimeMillis to 
>> positive numbers.  The first of these determines how often (in 
>> milliseconds) the "idle object evictor" runs and the second (also in 
>> milliseconds) determines how long a connection can sit idle in the pool 
>> before it is eligible for "eviction."
>>     
>>>  I had my Tomcat
>>> server sit there for about an hour idle with no client requests incoming
>>> and when I ran netstat -a I still saw 39 connections open, they only
>>> closed
>>> when I killed Tomcat.  Do I have to turn on some kind of cleanup
>>> explicitly?
>>>   
>>>       
>> See comment above on timing out idle connections,  though be careful 
>> about setting this too aggressively as it can lead to connection churn.  
>> The number of open connections - 39 - looks too large for the maxActive 
>> setting above.   Are you sure all of the connections were opened by the 
>> connection pool?
>>
>> Phil
>>     
>>> thanks!
>>>
>>> --------------------------------------------------------------------
>>> myhosting.com - Premium Microsoft® Windows® and Linux web and application
>>> hosting - http://link.myhosting.com/myhosting
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>>   
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>>
>>     
>
>   


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


Mime
View raw message