How do you configure Stash to not open as many DB connections?

Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 8, 2013

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.

2 answers

1 accepted

7 votes
Answer accepted
Bryan Turner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 9, 2013

Bob,

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,
Bryan Turner
Atlassian Stash

0 votes
Daniel R
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 9, 2013

Hello Bob,

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.

Thanks,

Daniel

Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 9, 2013

It is because I run multiple servers for testing.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events