6.27.1 Configuring Server Thread Pools
The HTTP server is built on Netty which is designed as a non-blocking I/O toolkit in an event loop model.
The Netty worker event loop uses the “default” named event loop group. That event loop can be configured through micronaut.server.netty.worker
, or micronaut.netty.event-loops.default
, with the latter having precedence.
Property | Type | Description |
---|---|---|
| java.lang.String | Sets the name to use. |
| int | Sets the number of threads for the event loop group. |
| java.lang.Integer | Sets the I/O ratio. |
| java.lang.String | Sets the name of the executor. |
| boolean | Set whether to prefer the native transport if available |
The parent event loop can be configured with micronaut.server.netty.parent with the same configuration options. |
The server can also be configured to use a different named worker event loop:
Using a different event loop for the server
micronaut:
server:
netty:
worker:
event-loop-group: other
netty:
event-loops:
other:
num-threads: 10
The default value for the number of threads is the value of the system property io.netty.eventLoopThreads , or if not specified, the available processors x 2. |
See the following table for configuring event loops:
Property | Type | Description |
---|---|---|
| int | |
| java.lang.Integer | |
| boolean | |
| java.lang.String |
Blocking Operations
When dealing with blocking operations, Micronaut will shift the blocking operations to an unbound, caching I/O thread pool by default. You can configure the I/O thread pool using the ExecutorConfiguration named io
. For example:
Configuring the Server I/O Thread Pool
micronaut:
executors:
io:
type: fixed
nThreads: 75
The above configuration will create a fixed thread pool with 75 threads.