6.29.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. This can be configured through micronaut.netty.event-loops.default
.
The event loop configuration under micronaut.server.netty.worker is only used if the event-loop-group is set to a name which doesn’t correspond to any micronaut.netty.event-loops configuration. This behavior is deprecated and will be removed in a future version. Use micronaut.netty.event-loops.* for any event loop group configuration beyond setting the name through event-loop-group . This does not apply to the parent event loop configuration (micronaut.server.netty.parent ). |
Property | Type | Description |
---|---|---|
| Sets the worker event loop configuration. | |
| 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 |
| java.time.Duration | Set the shutdown quiet period |
| java.time.Duration | Set the shutdown timeout (must be >= shutdownQuietPeriod) |
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 | |
| java.time.Duration | |
| java.time.Duration |
Blocking Operations
When dealing with blocking operations, Micronaut shifts 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 creates a fixed thread pool with 75 threads.