データベース接続のチューニング
Jira uses a database connection pool, based on Apache Commons DBCP (DataBase Connection Pool), to manage Jira's access to its underlying database.
In earlier Jira versions, the database connection pool was handled purely through the Apache Tomcat application server running Jira. However, from Jira version 4.4, Jira's dbconfig.xml
file provides a set of database connection pool settings to Tomcat, which in turn are used by Tomcat to manage Jira's database connection pool. From JIRA version 5.1, the number database connection pool settings defined in Jira's dbconfig.xml
file substantially increased.
The information on this page can help you tweak Jira's database connection pool settings. You can do this by using the Jira configuration tool or by directly editing Jira's dbconfig.xml
file, as described below.
The Advanced tab of the Jira Configuration Tool makes it easier to both configure and control Jira's database connection pool. The Database monitoring page (accessible to Jira system administrators) provides a visual tool for monitoring Jira's database connection usage.
接続プールアーキテクチャー
Whenever Jira needs to access (i.e. read from or write to) its database, a database connection is required.
A database connection is a large and complex object that handles all communication between Jira and its database. As such, database connections are time consuming to establish and consume a significant amount of memory on both the client (the Jira application) and database server.
To avoid the impact of creating a new database connection for each database access request made by Jira, a pool of pre-established database connections is maintained. Each new database access request made by Jira uses a connection from this pool of pre-established connections, as required. Hence:
- Jira の起動時にはプール内で Jira とそのデータベース間の最小限のデータベース コネクションが確立されます。
- When Jira needs to access its database, Jira:
- プールに対してデータベース接続を要求します
- そのデータベース接続を使用してデータベースの読み出しまたは書き込みを行います
- 処理が終了するとデータベース接続をプールに戻します。
If the frequency of Jira's database access requests begin to exceed the number of available database connections in the pool, extra connections are automatically created to handle the load.
Conversely, if the frequency of Jira's database access requests begin to drop below the number of available database connections in the pool, connections can be automatically closed to release resources back to the system.
最近のデータベースは多数の接続を比較的簡単に処理することが可能で、メモリーさえ十分にあれば同時接続可能数は数百にもなります。ただし、クライ アント側では接続は大量のメモリーを消費します。従って、最大接続数をそれよりずっと小さい数に制限して、接続する必要が生じたアプリケーションがほぼ待 つことなく接続を利用できるようにするのが一般的です。
Jira のデータベース コネクションの調整
- Jira のインストール環境をシャットダウンします。
- 次のいずれかを行います。
- Use the Jira configuration tool to tune Jira's database connections.
- Start the Jira configuration tool:
- Windows: コマンド プロンプトを開いて、Jira インストール ディレクトリの
bin
サブディレクトリにあるconfig.bat
を実行します。 - Linux/Unix: Open a console and execute
config.sh
in thebin
sub-directory of the Jira installation directory.This may fail with the error as described in our Unable to Start Jira applications Config Tool due to No X11 DISPLAY variable was set error KB article. Please refer to it for the workaround.
Please Note: You may need to set the
JAVA_HOME
environment variable to run the Jira configuration tool. See Installing Java for details. - Windows: コマンド プロンプトを開いて、Jira インストール ディレクトリの
- Once the Jira configuration tool is running, click its Advanced tab.
- Refer to Connection pool settings below for more information about the options on this tab. To specify a value for one of these options, ensure its leftmost checkbox has been selected first.
Some options above are simple checkboxes (i.e. in the centre of the JIRA configuration tool). Selecting these checkboxes sets the values of their associated options to 'true'. Conversely, clearing these checkboxes sets the values of their associated options to 'false'.
- [Save] ボタンをクリックして変更を保存すると、
dbconfig.xml
ファイルの要素として格納されます。
- Start the Jira configuration tool:
- または、Jira ホーム ディレクトリのルートにある
dbconfig.xml
ファイルを編集します。- Refer to Connection pool settings below for more information about the elements you can add to your
dbconfig.xml
file to fine tune Jira's database connection. - 編集済みの
dbconfig.xml
ファイルを保存します。
- Refer to Connection pool settings below for more information about the elements you can add to your
- Use the Jira configuration tool to tune Jira's database connections.
- Jira のインストール環境を再起動します。
接続プールの設定
Jira configuration tool 'Advanced' tab option | | 説明 | 推奨事項/注意事項 | デフォルト値* |
最大サイズ |
| 同時にオープン可能なデータベース接続の最大数。 | This value should be sufficiently large enough that Jira rarely needs to wait for a database connection to become available when Jira requires one. このパラメーターの設定方法に関連するヒントは、下の「監視」の項目をご覧ください。 | 20 |
最大アイドル状態 |
| プール内でアイドル状態のまま保持可能なデータベース接続の最大数。 | この値を負に設定すると、プール内でアイドル状態のまま存在可能なデータベース接続の最大数は無制限になります。 下で説明する Minimum Idle/Size の値が上で説明した Maximum Size の値と同一の場合 (デフォルトではこれが成立します) は、この設定は無意味になります。 | Maximum Size の値 |
最小アイドル状態/サイズ |
( | 同時にオープンしているアイドル状態のデータベース接続の最小数。 | この値を上で説明した Maximum Size と同一にすると (デフォルトではこれが成立します)、プールにおける接続数は一定でアイドル接続がクローズされることはありません。 On very large Jira installations, there may be some benefit in specifying a lower value for this setting than that of Maximum Size, to conserve resources. | Maximum Size の値 |
初期サイズ |
| プール内でオープンされるデータベース接続の初期値。 | This setting is not usually configured (other than the default value of 0), since a number of database connections are quickly created when Jira starts up. | 0 |
最大待機時間 |
| The length of time (in milliseconds) that Jira is allowed to wait for a database connection to become available (while there are no free ones available in the pool), before returning an error. | '-1' を指定すると Tomcat の待ち時間は無期限となります。 この値は、競合が発生してもそれに対応できる程度に十分長い時間としなければならないと同時に、無応答やブラウザータイムアウトとなる前にユーザーに対して適切なエラー情報を提供できる程度に短い時間でなければなりません。 | 30000 |
高度な設定通常は以下の設定を変更する必要はありません。必要ならば、Apache DBCP ドキュメントをご覧ください。 | ||||
プールステートメント |
| データベース接続プールにおいてプリペアドステートメントのプーリングを有効にします。 | Do not amend the default value of false, as it will cause exceptions. For more information see
| false |
最大オープンステートメント |
| ステートメントプールから同時に割り当て可能な空きステートメントの最大数。 | 例外の原因となるため、デフォルト値を修正しないでください。 | 0 |
バリデーションクエリ |
| 接続プールから取り出された接続の検証を行う SQL クエリです。指定する場合、クエリは少なくとも1つの行を返す SQL SELECT 文でなければなりません。 | 詳細については、 コネクション切断の問題を乗り越える方法 を参照してください。 | select 1 (または、 |
バリデーションクエリのタイムアウト |
| 検証クエリがデータベース接続の破損を検出するまでのシステム待ち時間 (単位は秒)。 | 検証クエリは処理量の小さいものを使用するためこの時間は非常に短い時間で構いません。 上で Validation Query を指定した場合は Validation Query Timeout の値も指定しなければなりません。指定しない場合は '-1' が設定され、データベースの破損が起こっていない場合でも、システムは破損を無期限に待ち続けます。
| 3 (または、 |
借りるときにテスト |
| Tests if the database connection is valid when it is borrowed from the database connection pool by Jira. そのデータベース接続が破損している場合はプールから削除されます。 | This value should always be 'false' as Jira borrows a connection for each database operation.
| True ( |
返却時にテスト |
| Tests if the database connection is valid when it is returned to the database connection pool by Jira. そのデータベース接続が破損している場合はプールから削除されます。 | This value should always be 'false' as Jira returns borrowed connections for each database operation. | false |
アイドル状態にテスト |
| データベース接続がアイドル状態のときに正しく機能しているか否かを定期的にテストします。 そのデータベース接続が破損している場合はプールから削除されます。 | MySQL の場合はこれを 'true' にします。 By default, MySQL database servers close database connections if they are not used for an extended period of time. This causes problems with Jira installations (which use MySQL databases) that are largely inactive for long periods, e.g. overnight. Setting this to 'true' will work around this behavior. なお、Test While Idle の指定が必要となるのは、上で説明した Validation Query を指定したときのみです。 | true false |
追い出し実行間の時間 |
| アイドルオブジェクトのエビクションスレッド実行間隔 (単位はミリ秒)。ゼロまたは負の値を指定するとアイドルオブジェクトのエビクションスレッドは実行されません。 エビクションスレッドは、アイドル状態にあるデータベース接続数が上で説明した Minimum Idle/Size を超えたときにアイドル状態にあるデータベース接続を削除します。 | MySQL の場合、接続のエビクションとテストを正常に行うためにはこのパラメーターを大きめの正の値に設定します。一般的に妥当な値は300000 (5 分) です。
| 300000 5000 (または、 |
追い出し可能な最小限のアイドル時間 |
| アイドルオブジェクトのエビクションを実行する場合に、データベース接続プール内のオブジェクトがアイドルオブジェクトエビクションの対象となるまでのアイドル状態最小時間。 | 60000 4000 (または、 | |
クローズ漏れの削除 |
| データベース接続のクローズ漏れ状態が次の Removed Abandoned Timeout で指定した時間を超えたときにそれを削除するか否かのフラグ。 If an internal failure occurs, it is possible that Jira may borrow a connection and never return it. If this happens too often, then the pool may run short of database connections, causing Jira's performance to degrade or Jira to fail altogether. | この値は 'true' にします。 これによってクローズ漏れ状態の接続を整理してプール内の接続数を回復し、システムパフォーマンスの低下を防止します。 | true |
クローズ漏れの削除のタイムアウト |
| データベース接続がクローズ漏れと判定されるまでのアイドル状態継続時間 (単位は秒)。 | 300 |
* Please note:
- Jira writes elements with their default values (in the right-hand column of the table above) to the
dbconfig.xml
file after:- Jira セットアップ ウィザード を最後まで実行したとき。
- You use the Advanced tab of the Jira configuration tool to configure/tune your database connection — even when the leftmost checkboxes of options associated with these elements have not been selected.
- ただし、値の下に '(
dbconfig.xml
で指定されていない場合)' と表示されている要素は例外です。これらの要素は次のようになります。- Jira セットアップ ウィザードを最後まで実行したあとは、
dbconfig.xml
には書き込まれません。 - 次の場合にのみ
dbconfig.xml
ファイルへの書き込みが行われます:- このファイルを手作業で書き換えたとき
- Using the Advanced tab of the Jira configuration tool, selecting the leftmost checkboxes of the options associated with these elements and specifying values for these options.
- Jira セットアップ ウィザードを最後まで実行したあとは、
- 上述の表の一番右の列で、既定値の下に "(
dbconfig.xml
で指定されていない場合)" と表示されている要素では、dbconfig.xml
ファイルに要素が存在しない場合でも既定値が適用されます。
接続プールの監視
Jira provides a view of its database connection usage via the 'Database Monitoring' page. See Monitoring database connection usage for more information.