简体   繁体   中英

apache-commons-dbcp connection pooling maxActive parameter

We are using Apache DBCP 1.4 for database connection pooling, with Java back-end, in our application. We set the value for maxActive = 20(by default), there was a scenario where requests needed more than 20 connection for execution. At that time application gets hang/unresponsive.

I have increased the value to maxActive = 50. Then execution completes successfully. In documentation of Apache DBCP, I have seen we can put the value of maxActive = -1, and this will not set upper limit on connection creation. Can I set maxActive = -1, if not can you please help me understand why it is not desirable and also what can be descent value we can set for maxActive so that my application do not gets hang/unresponsive.

Motivations to limit the number of connections in a db-Pool

  • The maximum number of connections clients might create to a DBMS normally is limited. By limiting the number of connections a node can use at the same time, you can calculate the hard limit and avoid meeting it.
  • if your application has a connection leak, this will hopefully lead on a single node to an error, not on the complete cluster, so you can handle it earlier, not when the DBMS stops working because all possible connections a dangling.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM