Skip to content

Commit b059139

Browse files
Merge pull request #4262 from vespa-engine/johsol/default-threadpool-documentation
Container Default Threadpool Documentation
2 parents fe6a945 + 09f0159 commit b059139

File tree

3 files changed

+58
-12
lines changed

3 files changed

+58
-12
lines changed

en/performance/container-tuning.html

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
<h2 id="container-worker-threads">Container worker threads</h2>
1818
<p>
1919
The container uses multiple thread pools for its operations.
20-
Most components including request handlers use the container's <em>default thread pool</em>,
20+
Most components including request handlers use the container's
21+
<a href="../reference/services-container.html#threadpool">default thread pool</a>,
2122
which is controlled by a shared executor instance.
2223
Any component can utilize the default pool by injecting an <code>java.util.concurrent.Executor</code> instance.
2324
Some built-in components have dedicated thread pools - such as the Jetty server, the
@@ -31,7 +32,8 @@ <h2 id="container-worker-threads">Container worker threads</h2>
3132
(<code>Runtime.getRuntime().availableProcessors()</code>).
3233
It's paramount that the <code>-XX:ActiveProcessorCount</code>/<code>jvm_availableProcessors</code>
3334
configuration is correct for the container to work optimally.
34-
The default thread pool configuration can be overridden through services.xml.
35+
The <a href="../reference/services-container.html#threadpool">default thread pool</a> configuration can be
36+
overridden through services.xml.
3537
We recommend you keep the default configuration as it's tuned to work across a variety of workloads.
3638
Note that the default configuration and pool usage may change between minor versions.
3739
</p>
@@ -83,6 +85,17 @@ <h3 id="container-worker-threads-example">Example</h3>
8385
<pre>{% highlight xml %}
8486
<container id="container" version="1.0">
8587

88+
<!-- The containers default thread pool -->
89+
<threadpool>
90+
<!-- Note: relative values -->
91+
92+
<!-- 5 threads per vcpu => 40 threads on 8 vcpu -->
93+
<threads max="5">5</threads>
94+
95+
<!-- 25 queue slots per thread => 1000 entries on 8 vcpu -->
96+
<queue>25</queue>
97+
</threadpool>
98+
8699
<search>
87100
<!-- Search handler thread pool -->
88101
<threadpool>
@@ -104,14 +117,6 @@ <h3 id="container-worker-threads-example">Example</h3>
104117
</threadpool>
105118
</document-processing>
106119

107-
<!-- Default thread pool -->
108-
<config name="container.handler.threadpool">
109-
<!-- Set corePoolSize==maxthreads for fixed size pool (recommended) -->
110-
<!-- Note: absolute pool size -->
111-
<corePoolSize>1000</corePoolSize>
112-
<maxthreads>1000</maxthreads>
113-
</config>
114-
115120
</container>
116121
{% endhighlight %}</pre>
117122

en/reference/services-container.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<a href="#secret-store">secret-store [type]</a>
6969
<a href="#group">group [name, environment]</a>
7070
<a href="#zookeeper">zookeeper</a>
71+
<a href="#threadpool">threadpool</a>
7172
</pre>
7273

7374
<p><a href="config-files.html#generic-configuration-in-services-xml">config</a> elements are also allowed most places.</p>
@@ -813,3 +814,43 @@ <h2 id="zookeeper">zookeeper</h2>
813814
and configure the necessary components.
814815
This element has no attributes or children.
815816
</p>
817+
818+
819+
<h2 id="threadpool">threadpool</h2>
820+
<p>
821+
Available since {% include version.html version="8.611.13" %}.
822+
</p>
823+
<p>
824+
Specifies configuration for the default thread pool in the container.
825+
All parameters are relative to the number of CPU cores—see the
826+
<a href="../performance/container-tuning.html#container-worker-threads-example">container tuning example</a>.
827+
This thread pool also supports the optional <code>max</code> attribute, which lets the pool grow up to
828+
<code>max * vCPU</code> threads under load before shrinking back after 5 seconds of idleness. Requests are rejected once the allowed
829+
number of threads is reached, all are busy, and the queue is full.
830+
</p>
831+
832+
<h3 id="threadpool-threads">threads</h3>
833+
<p>
834+
The number of permanent threads relative to number of vCPU cores. Default value is <code>2</code>.
835+
</p>
836+
<table class="table">
837+
<thead>
838+
<tr><th>Attribute</th><th>Required</th><th>Value</th><th>Default</th><th>Description</th></tr>
839+
</thead><tbody>
840+
<tr><th>max</th>
841+
<td>optional</td>
842+
<td>number</td>
843+
<td>100</td>
844+
<td>
845+
<p id="threads.max">
846+
The maximum number of threads relative to vCPU cores. Value must be greater than or equal to <code>&lt;threads&gt;</code>.
847+
</p>
848+
</td></tr>
849+
</tbody>
850+
</table>
851+
852+
<h3 id="threadpool-queue">queue</h3>
853+
<p>
854+
The size of the request queue relative to effective number of threads.
855+
Specify <code>0</code> to disable queuing. Queueing is disabled by default.
856+
</p>

en/reference/services-search.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,11 @@ <h3 id="threadpool-threads">threads</h3>
545545
<tr><th>max</th>
546546
<td>optional</td>
547547
<td>number</td>
548-
<td></td>
548+
<td>equal to <code>&lt;threads&gt;</code></td>
549549
<td>
550550
<span id="threads.boost"></span>
551551
<p id="threads.max">
552-
The maximum number of threads relative to vCPU cores. Defaults to <code>&lt;threads&gt;</code> (no dynamic scaling), and must be greater than or equal to <code>&lt;threads&gt;</code>.
552+
The maximum number of threads relative to vCPU cores. Value must be greater than or equal to <code>&lt;threads&gt;</code>.
553553
</p>
554554
</td></tr>
555555
</tbody>

0 commit comments

Comments
 (0)