java - Tomcat Datasource configuration Connection timeout and Max Active to Idle connection ratio -


i having web application load balanced on 4 servers. these 3 servers connect common database max connections setup 600.

my current database pool configuration in tomcat follows:

<resource name="jdbc/appdb"                           auth="container"                           type="javax.sql.datasource"                           maxactive="100"                           maxidle="30"                           maxwait="10000"                           removeabandoned ="true"                           removeabandonedtimeout="300"                           testonborrow="true"                           validationquery="select 1"                           logabandoned ="true"                           username="username"                           password="password"                           driverclassname="com.mysql.jdbc.driver"                           url="dbconnectionurl"                  /> 

but configuration gives exception: connection timeout : waiting idle object.

i have monitored database server, effective utilization of connections 350 only.

if calculate backwards, have total 400 connections used actively. gives me 200 database connections available db.

hence, not able understand why exception coming.

can suggest better configuration ? should ideal ratio of maxactive , maxidle ?

update:

i found related link: there not enough idle connections in tomcat jdbc pool

but can not risk setting maxidle or maxactive -1(infinite) because have multiple instances running, , might make uneven distribution of connections. may cause 1 instance perform nicely , other may fail due lack of connections.

first off, maxidle doesn't have problem, defines how many connections kept in pool not actively used - excess connections dropped. illustrate this: imagine @ t1 80 connections in use; @ t2 30 connections still in use, meaning 50 connections put pool. maxidle setting of 30 causes pool close 20 of 50 idle connections.
if @ t3 50 connections in use again, "idle pool" contain 10 connections. number of connections in idle pool not actively increased!

to make clear: maxactive maximum number of connections pool provides. maxidle not add bunch of connections on top of that; means keep around number of connections base load, speeding connection usage (if maxidle 0, each connection returned pool closed, thwarting idea of connection pool).

to suggest proper ratio case kind of hard, depends on load curve application has face. problem facing (the pool not return idle, i.e. "free" connection), wouldn't matter if you'd set -1, pool exhausted.

so fix problem, either need increase maxactive or need find ways use connections more efficiently.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -