keepmoving
keepmoving

Reputation: 2043

How the connection pool works

I am working on spring based application where I manage connection pool to manage connection between MySQL and Java application.

Connection pool configuration looks like this:

<bean id="dataSource"
     class="org.apache.commons.dbcp.BasicDataSource" >
     <property name="driverClassName" value="${database.driver}" />
     <property name="url" value="${database.url}" />
     <property name="username" value="${database.user}" />
     <property name="password" value="${database.password}" />
     <property name="initialSize" value="20" />
     <property name="maxActive" value="100" />
     <property name="maxIdle" value="50" />
     <property name="minIdle" value="10" />
</bean>

Now my questions are:

1) I have two different applications having the same configuration, then how many connection pool will mysql maintain, it will one for all application having maxactive1=100 or it will based on per application. In my case 2* 100 = 200(maxactive).

2) what can be best maxactive value if i have 500 requests in 1 sec?

Upvotes: 0

Views: 949

Answers (1)

StanislavL
StanislavL

Reputation: 57381

1) MySQL doesn't know about your connection pools. MySQL has own option for max allowed connections. And the number should be bigger than sum of connections required by all the connection pools. So in your case 2*100.

2) best maxactive value depends on multiple factors. 500 requsts per second if one request is processed 1 second requires 500 connections. But if the request processing time is 0.1 sec 50 connections would be enough.

Upvotes: 1

Related Questions