DBCP connection takes (very) long

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

DBCP connection takes (very) long

Peter Coppens
Hello,

Not sure this is the right forum to ask DBCP questions. If not I would appreciate if someone could tell me where I should ask the question.

Anyway, I have DBCP 1.2.1 and Tomcat 6.02 configured with a mySql backend.

I have configured the pool through a jndi datasource,

          <Resource name="jdbc/PurlDB" auth="Container" type="javax.sql.DataSource"
                  factory="org.apache.commons.dbcp.BasicDataSourceFactory"
                  initialSize="200"
                  maxActive="200"
                  maxIdle="200"
                  maxWait="10000"
                  username="user"
                  password="***"
                  driverClassName="com.mysql.jdbc.Driver"
                  url="jdbc:mysql://192.168.36.134/purlie"
                  />

The code to get the connection just invokes getConnection on the Datasource instance.


Everything works fine but when I start stress testing the tomcat servlet app, some of the connections take a very long time (e.g. >5 minutes). I have added logging to write out idle and active connections, and there always seem to be lots of idle connections left.

Would anybody have any guidance as on how to identify and hopefully fix the issue?

Thanks,

Peter
Reply | Threaded
Open this post in threaded view
|

Re: DBCP connection takes (very) long

Christian Hufgard
Hello Peter,

If the execution of the queries lasts a long time, this also might be
cause of deadlocks. The fact that you have a lot of idle connections
also indicates, that your application is not waiting for connections.

Have you tried logging execution time of each query?
How do you test your application? Maybe you have to less tomcat
workers so your requests are queued.

You could also test your application outside of tomcat to see, if
there are any problems.

Christian



Sunday, December 31, 2006, 3:12:09 PM, you wrote:


> Hello,

> Not sure this is the right forum to ask DBCP questions. If not I would
> appreciate if someone could tell me where I should ask the question.

> Anyway, I have DBCP 1.2.1 and Tomcat 6.02 configured with a mySql backend.

> I have configured the pool through a jndi datasource,

>           <Resource name="jdbc/PurlDB" auth="Container" type="javax.sql.DataSource"
>                  
> factory="org.apache.commons.dbcp.BasicDataSourceFactory"
>                   initialSize="200"
>                   maxActive="200"
>                   maxIdle="200"
>                   maxWait="10000"
>                   username="user"
>                   password="***"
>                   driverClassName="com.mysql.jdbc.Driver"
>                   url="jdbc:mysql://192.168.36.134/purlie"
>                   />

> The code to get the connection just invokes getConnection on the Datasource
> instance.


> Everything works fine but when I start stress testing the tomcat servlet
> app, some of the connections take a very long time (e.g. >5 minutes). I have
> added logging to write out idle and active connections, and there always
> seem to be lots of idle connections left.

> Would anybody have any guidance as on how to identify and hopefully fix the
> issue?

> Thanks,

> Peter



--
Best regards,
 Christian                            mailto:[hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: DBCP connection takes (very) long

Peter Coppens
Christian,

I have not timed query execution, but then these queries are really very simple and perform very well when Tomcat is not stress tested.  I am testing tomcat with jMeter.

I guess I can try to trim down the worker threads and see whether the overall performance benefits from that. At this stage I have set the #threads equal to the number of client threads but I can see that is not necessarily optimal.

Thanks for your answer and suggestions!

Peter




Christian Hufgard wrote
Hello Peter,

If the execution of the queries lasts a long time, this also might be
cause of deadlocks. The fact that you have a lot of idle connections
also indicates, that your application is not waiting for connections.

Have you tried logging execution time of each query?
How do you test your application? Maybe you have to less tomcat
workers so your requests are queued.

You could also test your application outside of tomcat to see, if
there are any problems.

Christian



Sunday, December 31, 2006, 3:12:09 PM, you wrote:


> Hello,

> Not sure this is the right forum to ask DBCP questions. If not I would
> appreciate if someone could tell me where I should ask the question.

> Anyway, I have DBCP 1.2.1 and Tomcat 6.02 configured with a mySql backend.

> I have configured the pool through a jndi datasource,

>           <Resource name="jdbc/PurlDB" auth="Container" type="javax.sql.DataSource"
>                 
> factory="org.apache.commons.dbcp.BasicDataSourceFactory"
>                   initialSize="200"
>                   maxActive="200"
>                   maxIdle="200"
>                   maxWait="10000"
>                   username="user"
>                   password="***"
>                   driverClassName="com.mysql.jdbc.Driver"
>                   url="jdbc:mysql://192.168.36.134/purlie"
>                   />

> The code to get the connection just invokes getConnection on the Datasource
> instance.


> Everything works fine but when I start stress testing the tomcat servlet
> app, some of the connections take a very long time (e.g. >5 minutes). I have
> added logging to write out idle and active connections, and there always
> seem to be lots of idle connections left.

> Would anybody have any guidance as on how to identify and hopefully fix the
> issue?

> Thanks,

> Peter



--
Best regards,
 Christian                            mailto:christian.hufgard@gmx.de


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