0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

(調査中)Tomcat同時接続の制御や Keep-Alive の設定

Last updated at Posted at 2024-09-22

Tomcat には、同時接続の制御や Keep-Alive の設定を行うことができます。これらの設定は、通常 server.xml ファイルで定義されています。以下、具体的な設定方法を説明します。

同時接続制御

Tomcat の同時接続数は、server.xml 内の Connector 要素で設定できます。maxThreads パラメータを使用して、同時に処理できるリクエストの最大数を指定します。

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443"
           maxThreads="200" />

maxThreads: ここで指定した数が、同時に処理できるスレッド(リクエスト)の最大数となります。たとえば、maxThreads="200" と設定することで、最大200の同時接続を処理できます。

Keep-Alive の設定

Keep-Alive に関連する設定も、同じく Connector 要素内で指定できます。

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           keepAliveTimeout="60000"
           maxKeepAliveRequests="100" />

keepAliveTimeout: クライアントが次のリクエストを送信するまでの最大待機時間(ミリ秒)を指定します。たとえば、keepAliveTimeout="60000" とすると、Tomcat は 60 秒間接続を維持します。

maxKeepAliveRequests: 1つの接続で処理するリクエストの最大数を指定します。たとえば、maxKeepAliveRequests="100" と設定すると、1つのKeep-Alive接続で最大100のリクエストを処理します。-1 に設定すると、無制限となります。

その他のパフォーマンスに影響する設定

acceptCount: 同時接続数を超えた場合に待機できるリクエストのキューの最大数を設定します。

<Connector port="8080" protocol="HTTP/1.1"
           maxThreads="200"
           acceptCount="100" />

これにより、200のスレッドが稼働中であっても、さらに100のリクエストが待機できるようになります。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?