How to set the size of the event-event pool in Spring Webflux / WebClient?

In an infrastructure with multiple reactors , such as Vert.X, we can set the number of event loop threads, for example:

final VertxOptions vertxOptions = new VertxOptions();
vertxOptions.setEventLoopPoolSize(16);
final Vertx myVertx = Vertx.vertx(vertxOptions);

How to make equivalent in Spring Boot 2 WebFlux / WebClient?

+4
source share
1 answer

You have two options:

  • Override the ReactiveWebServerFactorybean using a customizer that applies the event loop resource configuration:

    @Bean
    public ReactiveWebServerFactory reactiveWebServerFactory() {
        NettyReactiveWebServerFactory factory = new NettyReactiveWebServerFactory();
        factory.addServerCustomizers(builder -> builder.loopResources(LoopResources.create("my-http", 16, true)));
    
        return factory;
    }
    
  • Or use an environment variable -Dreactor.ipc.netty.workerCount=16. By default, this value is set to Math.max(availableProcessors(), 4).

+4
source

Source: https://habr.com/ru/post/1693150/


All Articles