@@ -22,7 +22,7 @@ <h2 id="container-worker-threads">Container worker threads</h2>
22
22
Most components including request handlers use the container's < em > default thread pool</ em > ,
23
23
which is controlled by a shared executor instance.
24
24
Any component can utilize the default pool by injecting an < code > java.util.concurrent.Executor</ code > instance.
25
- Some built-in components have dedicated thread pools - such as the Jetty server, the search handler and the feed handler.
25
+ Some built-in components have dedicated thread pools - such as the Jetty server and the search handler.
26
26
These thread pools are injected through special wiring in the config model and
27
27
are not easily accessible from other components.
28
28
</ p >
@@ -38,46 +38,45 @@ <h2 id="container-worker-threads">Container worker threads</h2>
38
38
< p >
39
39
The container will pre-start the minimum number of worker threads,
40
40
so even an idle container may report running several hundred threads.
41
- For thread pools with fixed size ( < em > min == max </ em > ), all threads are pre-started .
41
+ The thread pool is pre-started with the number of thread specified in the < code > threads </ code > parameter .
42
42
Note that tuning the capacity upwards increases the risk of high GC pressure
43
43
as concurrency becomes higher with more in-flight requests.
44
44
The GC pressure is a function of number of in-flight requests, the time it takes to complete the request
45
45
and the amount of garbage produced per request.
46
46
Increasing the queue size will allow the application to handle shorter traffic bursts without rejecting requests,
47
47
although increasing the average latency for those requests that are queued up.
48
48
Large queues will also increase heap consumption in overload situations.
49
- Extra threads will be created once the queue is full (if < em > max > min </ em > ), and are destroyed after an idle timeout.
49
+ Extra threads will be created once the queue is full (when < code > boost </ code > is specified ), and are destroyed after an idle timeout.
50
50
If all threads are occupied, requests are rejected with a 503 response.
51
51
</ p >
52
52
< p >
53
53
The effective thread pool configuration and utilization statistics can be observed through the
54
54
< a href ="../operations/container.html#container-metrics "> Container Metrics</ a > .
55
55
See < a href ="../operations/container.html#thread-pool-metrics "> Thread Pool Metrics</ a > for a list of metrics exported.
56
56
</ p >
57
- < p > Example configuration override:</ p >
57
+ {% include note.html content=' If the queue size is set to 0 the metric measuring the queue size -
58
+ < code > jdisc.thread_pool.work_queue.size</ code > - will instead switch to measure how many threads are active.'%}
59
+
60
+ < h3 id ="container-worker-threads-min "> Lower limit</ h3 >
61
+ The container will override any configuration if the effective value is below a fixed minimum. This is to
62
+ reduce the risk of certain deadlock scenarios and improve concurrency for low-resource environments.
63
+ < ul >
64
+ < li > Minimum 8 threads.</ li >
65
+ < li > Minimum 650 queue capacity (if queue is not disabled).</ li >
66
+ </ ul >
67
+
68
+ < h3 id ="container-worker-threads-example "> Example</ h3 >
58
69
< pre > {% highlight xml %}
59
70
< container id ="container " version ="1.0 ">
60
71
61
72
< search >
62
73
<!-- Search handler thread pool -->
63
74
< threadpool >
64
- < max-threads > 500</ max-threads >
65
- < min-threads > 500</ min-threads >
66
- < queue-size > 0</ queue-size >
75
+ < threads boost ="12 "> 4</ threads >
76
+ < queue > 100</ queue >
67
77
</ threadpool >
68
78
</ search >
69
79
70
- < document-api >
71
- <!-- Feed handler thread pool -->
72
- < http-client-api >
73
- < threadpool >
74
- < max-threads > 50</ max-threads >
75
- < min-threads > 10</ min-threads >
76
- < queue-size > 1000</ queue-size >
77
- </ threadpool >
78
- </ http-client-api >
79
- </ document-api >
80
-
81
80
<!-- Default thread pool -->
82
81
< config name ="container.handler.threadpool ">
83
82
< maxthreads > 200</ maxthreads >
0 commit comments