BoneCP connection pooling – Some useful Tips

Friends , while developing an application which require high availability of application. It is often a requirement to use any kind of connection pooling. BoneCP connection pooling is a database connection pooling which has a good features that i have explained in my earlier post.There are some minor fine tuning require to work with BoneCP.  which are listed below.

1. Always keep setPartitionCount to less then or equal to 3.

In order to reduce lock contention and thus improve performance, each incoming connection request picks off a connection from a pool that has thread-affinity, i.e. pool[threadId % partition_count]. The higher this number, the better your performance will be for the case when you have plenty of short-lived threads. Beyond a certain threshold, maintenence of these pools will start to have a negative effect on performance (and only for the case when connections on a partition start running out).

 

  • maxConnectionsPerPartitionThe number of connections to create per partition. Setting this to 5 with 3 partitions means you will have 15 unique connections to the database. Note that BoneCP will not create all these connections in one go but rather start off with minConnectionsPerPartition and gradually increase connections as required.
  • minConnectionsPerPartitionThe number of connections to start off with per partition.
  • acquireIncrementWhen the available connections are about to run out, BoneCP will dynamically create new ones in batches. This property controls how many new connections to create in one go (up to a maximum of maxConnectionsPerPartition). Note: This is a per partition setting.Default: 10

 

2. To keep alive the connection use

config.setIdleConnectionTestPeriodInMinutes(10);
config.setConnectionTestStatement("/* ping */ SELECT 1"):

so in this way the application will use the above query to perform test connection to server whenever require.

3. Always commit() after performing transaction to avoid unwanted errors.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s