@@ -22,7 +22,7 @@ <h2 id="container-worker-threads">Container worker threads</h2>
2222 Most components including request handlers use the container's < em > default thread pool</ em > ,
2323 which is controlled by a shared executor instance.
2424 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.
2626 These thread pools are injected through special wiring in the config model and
2727 are not easily accessible from other components.
2828</ p >
@@ -38,46 +38,45 @@ <h2 id="container-worker-threads">Container worker threads</h2>
3838< p >
3939 The container will pre-start the minimum number of worker threads,
4040 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 .
4242 Note that tuning the capacity upwards increases the risk of high GC pressure
4343 as concurrency becomes higher with more in-flight requests.
4444 The GC pressure is a function of number of in-flight requests, the time it takes to complete the request
4545 and the amount of garbage produced per request.
4646 Increasing the queue size will allow the application to handle shorter traffic bursts without rejecting requests,
4747 although increasing the average latency for those requests that are queued up.
4848 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.
5050 If all threads are occupied, requests are rejected with a 503 response.
5151</ p >
5252< p >
5353 The effective thread pool configuration and utilization statistics can be observed through the
5454 < a href ="../operations/container.html#container-metrics "> Container Metrics</ a > .
5555 See < a href ="../operations/container.html#thread-pool-metrics "> Thread Pool Metrics</ a > for a list of metrics exported.
5656</ 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 >
5869< pre > {% highlight xml %}
5970< container id ="container " version ="1.0 ">
6071
6172 < search >
6273 <!-- Search handler thread pool -->
6374 < 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 >
6777 </ threadpool >
6878 </ search >
6979
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-
8180 <!-- Default thread pool -->
8281 < config name ="container.handler.threadpool ">
8382 < maxthreads > 200</ maxthreads >
0 commit comments