JDBC Pool Manager - Max Pool Size Tuning
By shalini_m on Feb 10, 2009
Max pool size is the maximum number of connections to the database at any point of time. This value can be configured as a jdbc connection pool attribute "max–pool–size". The default value of this attribute is 32.
Some databases have license restrictions on how many connections it can allow. This attribute is configured based on such parameters. This parameter can also be configured from the Performance Advisor page in administration console of GlassFish. Some important points to note here :
- If one or more jdbc connection pools are selected in the JDBC Pool Manager, there is an option to specify a "Max Connections" value for each pool according to the requirement.
- The Default Max Connections set to a certain value overrides the settings of the max–pool–size of the selected jdbc connection pools.
On a clustered environment, when new instances are added to the cluster, the max–pool–size on each instance may need a reconfiguration. This should also be based on the instance weights. A particular instance may have a higher instance weight, say, to provide faster service to privileged customers.
- Create a node–agent called na1
- Create a cluster "mycluster" with 2 instances "instance1" (weight 40) and "instance2" (weight 60)
- Start the cluster "mycluster"
- Create a new JDBC Connection pool "mypool" with default settings
- Create a new JDBC resource referring the above connection pool for target "mycluster" : "jdbc/myresource"
- Create an application that refers this jdbc resource on "mycluster" target
- In the performance advisor link of admin console, specify the default max connections for "mypool" as 100. Enable this rule on "mycluster" by choosing "mycluster" for target.
After these steps, the "mycluster" should be restarted to see the max pool size reconfiguration in each of the instances "instance1" and "instance2".
You would see, for "instance1", the max pool size is recalculated to 40
and "instance2" to 60 based on their instance weights.
- Add another new instance "instance3" to "mycluster" with weight of 100.
- Restart "mycluster".
Once the cluster is restarted with the new instances addition, the max pool size of instance1 becomes 20, instance2 becomes 30 and instance3 becomes 50. This is based on the instance weights and the default max connections value we specified for the jdbc connection pool. instance3 gets more number of max connections to the database since its instance weight is higher.
This is a very useful rule to configure the maximum pool size of jdbc connection pools on cluster startup. Manual intervention is prevented and this easy–to–use feature can be configured to avoid errors in complex cluster scenarios.