6.4.1 Overview of controlling the number of request processing threads
After the request processing threads are created when the in-process HTTP server starts, the status of the request processing threads and the number of threads are monitored periodically. When requests are concentrated in the in-process HTTP server, the request processing threads are added and the adequate number of spare threads is pooled in advance. When there are few requests, the extra pooled spare threads will be deleted.
The controlling of the number of request processing threads is executed as follows:
-
When the J2EE server starts, the specified number of request processing threads is created.
-
While the J2EE server is running, the number of request processing threads is monitored.
-
During monitoring, if the number of spare threads is smaller than the specified minimum value, the request processing threads are added and pooled as the spare threads. Also, if the number of spare threads is greater than the specified maximum value, the extra spare threads are deleted.
Note that you can also maintain the number of threads created when the J2EE server starts. When maintaining the number of threads created at startup, if the total number of request processing threads and spare threads is less than the number of threads created when the Web server starts, even if the number of spare threads exceeds the maximum value, the spare threads are not deleted. For example, if the number of threads created when the Web server starts is 8 and the maximum number of spare threads is 5, the spare threads are not deleted in the case when the number of request processing threads is 2 and the number of spare threads is 6.
The transition of the number of request processing threads is explained with the following examples:
-
Transition example 1
Assume the following settings:
-
Maximum number of connections from the Web client: 15
-
Number of registrations in the Listen queue: 100
-
Number of request processing threads created when the J2EE server starts: 8
-
Minimum number of spare threads: 5
-
Maximum number of spare threads: 10
-
Maintenance of the number of threads created when the J2EE server starts: Disabled
The following figure shows the transition example for the number of request processing threads:
Figure 6‒2: Transition example for the number of request processing threads Stages 1. to 7. of the figure are explained below:
-
When the J2EE server starts, the specified number (8 threads) of request processing threads is created.
-
When 4 requests are received, the number of spare threads becomes 4 and since this number is less than the minimum value, 1 thread is added.
-
When the processing of the 4 requests ends, the number of spare threads becomes 9. Since this number is less than the maximum value and more than the minimum value, the current state is maintained.
-
When 14 requests are received, the number of spare threads is less than the minimum value, but the maximum number of connections from the Web client is reached, therefore, the spare threads add only 1 thread.
-
When the processing of 13 requests ends, the number of spare threads exceeds the maximum value, so 4 threads are deleted.
-
When 7 requests are received, the number of spare threads is less than the minimum value, so 2 threads are added.
-
When the processing of 8 requests ends, the number of spare threads exceeds the maximum value, so 3 threads are deleted.
-
-
Transition example 2
By setting the maximum number of spare threads equal to the maximum number of connections from the Web client, you can continue to use the request processing threads created once without deleting them.
The transition example for the number of request processing threads when the maximum number of spare threads is equal to the maximum number of connections from the Web client is as follows:
Assume the following settings:
-
Maximum number of connections from the Web client: 15
-
Maximum number of registrations in the Listen queue: 100
-
Number of request processing threads created when the J2EE server starts: 8
-
Minimum number of spare threads: 5
-
Maximum number of spare threads: 15
-
Maintenance of the number of threads created when the J2EE server starts: Disabled
The following figure shows the transition example for the number of request processing threads, when the maximum number of spare threads is equal to the maximum number of connections from the Web client:
Figure 6‒3: Transition example for the number of request processing threads when the maximum number of spare threads is equal to the maximum number of connections from the Web client Stages 1. to 7. of the figure are explained below:
-
When the J2EE server starts, the specified number (8 threads) of request processing threads is created.
-
When 4 requests are received, the number of spare threads becomes 4 and since this number is less than the minimum value, 1 thread is added.
-
When the processing of the 4 requests ends, the number of spare threads becomes 9. Since this number is less than the maximum value and more than the minimum value, the current state is maintained.
-
When 14 requests are received, the number of spare threads is less than the minimum value, but so that the total number of request processing threads does not exceed the maximum number of connections from the Web client, spare threads add only 1 thread.
-
When the processing of 13 requests ends, the number of spare threads becomes 14, but this number is less than the maximum value and more than the minimum value, so the current state is maintained.
-
When 7 requests are received, the number of spare threads becomes 7, but this number is less than the maximum value and more than the minimum value, so the current state is maintained.
-
When the processing of 8 requests ends, the number of spare threads becomes 15, but this number is less than the maximum value and more than the minimum value, so the current state is maintained.
-
-
Setup example 3
The following is a transition example for the number of request processing threads when the number of threads created at server startup is maintained:
Assume the following settings:
-
Maximum number of connections from the Web client: 15
-
Maximum number of registrations in the Listen queue: 100
-
Number of request processing threads created when the J2EE server starts: 8
-
Minimum number of spare threads: 3
-
Maximum number of spare threads: 5
-
Maintenance of the number of threads created when the J2EE server starts: Enabled
The following figure shows the transition example for the number of request processing threads when the number of threads created at server startup is maintained:
Figure 6‒4: Transition example for the number of request processing threads when the number of threads created at J2EE server startup is maintained Stages 1. to 8. of the figure are explained below:
-
When the J2EE server starts, the specified number (8 threads) of request processing threads is created.
-
When 6 requests are received, the number of spare threads becomes 2. Since this number is less than the minimum value, 1 thread is added.
-
When the processing of the 6 requests ends, the number of spare threads becomes 9 and the maximum value is exceeded, but in order to maintain the number of threads created at server startup, only 1 thread is deleted.
-
When 14 requests are received, the number of spare threads is less than the minimum value, but so that the total number of request processing threads does not exceed the maximum number of connections from the Web client, spare threads add only 1 thread.
-
When the processing of 7 requests ends, the number of spare threads becomes 8 and exceeds the maximum value, so 3 threads are deleted.
-
When 3 requests are received, the number of spare threads becomes 2 and is less than the minimum value, so 1 thread is added.
-
When the processing of 1 request ends, the number of spare threads becomes 4, but this number is less than the maximum value and more than the minimum value, so the current status is maintained.
-
When the processing of 9 requests ends, the number of spare threads becomes 13. This number is more than the maximum value, but in order to maintain the number of threads at J2EE server startup, only 5 threads are deleted.
-