commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sheng Huang <SHu...@tlg.ca>
Subject RE: [dbcp] Should number of active connections plus idle connecti on equals t o number of connections?
Date Thu, 13 Nov 2003 00:05:09 GMT
Hi Rodney,

Thank you very much for your reply. Now I totally understand these
parameters. So I can just use getNumActive() to real-time profile my
application. If there are no active database requests, this method should
always return 0. Or else, there exists connection leaking problem. 

I am eager to know this because I plan to use four connections with an
expectation of medium website traffic based on the following caculation:
4*5*60*60*8=576,000 page hits per work day.
(4 concurrent users, 5 requests per seconds (average page response time of
my site), 60 seconds, 60 minutes, 8 work hours). If my connection number or
other estimation is not realistic, please give me advice.

Have a good day.

Best regards,
Sheng

-----Original Message-----
From: Rodney Waldhoff [mailto:rwaldhoff@apache.org]
Sent: November 12, 2003 5:46 PM
To: Jakarta Commons Users List
Subject: [dbcp] Should number of active connections plus idle connection
equals t o number of connections?


(prefixing [dbcp] to the subject line to make sure it catches the eye
of the right folks)

I think the answer to your question is no.

getNumActive will return the number of connections you have borrowed but
not yet returned.

getMaxActive will return the maximum number of connections you should be
able to borrow at the same time.

In other words, it should be the case that getNumActive() <=
getMaxActive() at all times

getNumIdle will return the number of connections sitting idle in the pool,
ready to be borrowed.

It is possible to borrow connections when getNumIdle is 0, it just means a
new connection will need to be created.

getMaxIdle will return the maximum number of connections that can be idle
in the pool at any time.

If you return (close) a connection when
getNumIdle() == getMaxIdle(), then an idle connection will be discarded.

As with num/maxActive, it should always be the case that getNumIdle() <=
getMaxIdle() at all times.

On Wed, 12 Nov 2003, Sheng Huang wrote:

> Dear Sir or Madam,
>
> I have DBCP configured as follows:
>   		   <parameter>
>     			<name>maxActive</name>
>     			<value>4</value>
>   		   </parameter>
>   		   <parameter>
>     			<name>maxIdle</name>
>     		   	<value>4</value>
>   		   </parameter>
>   		   <parameter>
>     			<name>maxWait</name>
>     			<value>-1</value>
>   		   </parameter>
>
> And I have a testPool.jsp containing the following code:
>     out.println("We have a connection pool and it has " +
> connectionPool.getMaxActive() + " max active connections.<BR>");
>     out.println("We have a connection pool and it has " +
> connectionPool.getMaxIdle() + " max idle connections.<BR>");
>     out.println("We have a connection pool and it has " +
> connectionPool.getNumActive() + " active connections.<BR>");
>     out.println("We have a connection pool and it has " +
> connectionPool.getNumIdle() + " idle connections.");
> However, after I started my application, I got
> We have a connection pool and it has 4 idle connections.
> We have a connection pool and it has 4 idle connections.
> We have a connection pool and it has 0 active connections.
> We have a connection pool and it has 1 idle connections.
> Should getNumActive()+getNumIdle()=getMaxActive() since I set
> maxActive=maxIdle? Is this an indication of connection leaking? Thank you
> very much for your help.
>
> Best regards,
> Sheng
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

-- 
- Rod <http://radio.weblogs.com/0122027/>

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

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


Mime
View raw message