Stash seems to open about 20 DB connections on startup. How can this be lowered to a more reasonable number. I am running Stash 2.2 and 2.3.
I'm one of the Stash developers. As noted by Daniel, Stash by default idles with 16 connections, in 4 pools of 4 connections, and may create up to 80 connections maximum (20 connections in 4 pools). Stash uses multiple pools to reduce lock contention around acquiring connections, which improves its performance when under heavy load. Stash provides a lot of different knobs for adjusting how it uses the database. These can all be overridden in stash-config.properties. For each property I list below I show the value it has by default.
db.pool.partition.count=4 : This setting controls how many pools Stash uses, with a minimum of 1. Lower values will open fewer connections, but will have increased contention for acquiring connections.
db.pool.partition.connection.maximum=20 : For each parition, this controls the maxmimum number of connections allowed. That means the absolute maximum is db.pool.partition.count times this value.
db.pool.partition.connection.minimum=4 : For each partition, this controls the minimum number of connections that are kept open at all times. Stash will heartbeat these connections to prevent them from idling out. That means the absolute minimum is db.pool.partition.count times this value.
Adjusting the minimum and maximum may also require adjusting:
db.pool.acquireIncrement=2 : When a pool approaches exhaustion, if it currently has fewer connections open than the maximum allowed, this controls the number of connections opened and added to the pool.
db.pool.partition.connection.threshold=10 : When the number of open, free connections in a pool drops to or below this threshold, as a percentage of the maximum, new connections will automatically be opened. When adjusting the minimum and maximum, be careful to ensure the minimum exceeds this threshold. For example, if you lower the minimum to 1 and leave the maximum at 20, 1 is not 10% of 20, so the system will automatically open acquireIncrement more connections until the threshold is exceeded. This threshold is strictly greater than, so a minimum of 1 and a maximum of 10 will also trigger immediately opening additional connections.
Lastly, for heartbeating, Stash provides the following:
db.pool.idle.maxAge=30 : Defines the number of minutes a connection is allowed to remain open before it is closed, down to the configured minimum for each pool.
db.pool.idle.testInterval=10 : Defines the number of minutes a connection is allowed to be idle before a simpe test SQL statement is automatically run on it to prevent the connection from timing out. These heartbeat connections do not reset the maxAge counter; they just prevent the RDBMS server from closing connections out from under Stash.
Stash's database pooling is provided by BoneCP, if you'd like to read more about how it works.
Hope this helps,
By default, Stash is designed to idle with this many connections. Is there a reason you don't consider this reasonable? We have a set of properties to ultimately reduce the number of connections but I'm checking to see if there are any ramifications to reducing this number.
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs