Tuesday Feb 10, 2009

JDBC Pool Manager - Max Pool Size Tuning

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.
Steps

  • 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


Clustered environment


  • 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. Jdbc Rule Manager


Setting target as mycluster

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

instance1 log from admin console

and "instance2" to 60 based on their instance weights.

instance2 log from admin console


  • 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.

instance1 log from admin console after instance addition
instance2 log from admin console after instance addition
instance3 log from admin console after instance addition

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.

JDBC Pool Manager - Steady Pool Size Tuning

Sun has recently announced the "GlassFish Enterprise Manager". I would talk about a particular feature : "Performance Advisor". One of the management rules of Performance Advisor is the JDBC Pool Manager. Jdbc pool manager tunes the steady pool size and maximum pool sizes of jdbc connection pools based on the load. This blog would briefly talk about steady pool size tuning.


 Example


Consider a cricket website. On a non–match day, there will be a minimum number of requests to this website. On a match–day, even if it is a working day, people tend to use such websites to check the runs and number of wickets. The number of requests will pour in as a result and for maximum resource utilization, the steady pool size needs to go up. If done manually, the administrator will have to configure this steady pool size.


 After  a while, number of requests are bound to come down. As a result, the steady pool size would have to be brought down. This constant recomputing of steady pool size based on the load is automated by the JDBC Pool Manager.


How is it Configured?


Assume there is a jdbc connection pool : cricket–info–pool. jdbc/cric is the resource that references this pool. The cricket–info–pool is set to a default steady pool size of 8. An application that uses the jdbc resource to get information from a database is set up. Client access this application to retrieve information. JDBC Pool Manager rule can set up from admin GUI.



  • The Default Max Connections is the maximum number of connections that can be provided from the pool at any point of time.

  • The management rule tunes the steady pool size in Sampling Frequency number of seconds.

  • The sample size denoted by Number of Samples is used to calculate the moving average value for number of connections.


Marking cricket-info-pool under PoolNames will configure the rule for this connection pool.  Click on Save after entering all the details.The domain needs to be restarted now, as the rule is configured for the target "server".


On domain restart, you can observe from the server.log that the steady pool size is recalculated to a certain value. After a while, assuming there are 500 client requests for a period of 10 minutes.



The steady pool size is recalculated every 60 seconds (default sampling frequency) to a new value suitable for the current number of requests.

About

shalini_m

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today