问题
In multi-reactor framework such as Vert.X we can set the number of event-loop threads, e.g.:
final VertxOptions vertxOptions = new VertxOptions();
vertxOptions.setEventLoopPoolSize(16);
final Vertx myVertx = Vertx.vertx(vertxOptions);
How to do the equivalent in Spring Boot 2 WebFlux / WebClient?
回答1:
You have two options:
Override
ReactiveWebServerFactorybean with a customizer that applies event loop resources config:@Bean public ReactiveWebServerFactory reactiveWebServerFactory() { NettyReactiveWebServerFactory factory = new NettyReactiveWebServerFactory(); factory.addServerCustomizers(builder -> builder.loopResources(LoopResources.create("my-http", 16, true))); return factory; }Or use
-Dreactor.ipc.netty.workerCount=16environment variable. By default it's value is set toMath.max(availableProcessors(), 4). Example:java -jar your-app.jar -Dreactor.ipc.netty.workerCount=16
来源:https://stackoverflow.com/questions/48607114/how-to-set-event-loop-pool-size-in-spring-webflux-webclient