Spring Boot ReactiveWeb

Netty Configuration

  • reactor.netty.ioWorkerCount

    Math.max(availableProcessors(), 4)

  • reactor.netty.ioSelectCount

  • reactor.netty.pool.maxConnections

  1. How to change them?

System.setProperty(“reactor.netty.ioWorkerCount”, “100”);


Q&A

Why concatMap is better than flatMap?

In its essence, flatMap is designed to merge elements from the multiple substreams that is executing at a time. It means that flatMap should have asynchronous streams underneath so, they could potentially process data on the multiple threads or that could be a several network calls. Subsequently, such expectations impact implementation a lot so flatMap should be able to handle data from the multiple streams (Threads) (means usage of concurrent data structures), enqueue elements if there is a draining from another stream (means additional memory allocation for Queues for each substream) and do not violate Reactive Streams specification rules (means really complex implementation). Counting all these facts and the fact that we replace a plain map operation (which is synchronous) onto the more convenient way of throwing an exception using Flux/Mono.error (which does not change synchronicity of execution) leads to the fact that we do not need such a complex operator and we can use much simpler concatMap which is designed for asynchronous handling of a single stream at a time and has a couple of optimization in order to handle scalar, cold stream.


Reference

https://projectreactor.io/
https://www.callicoder.com/spring-5-reactive-webclient-webtestclient-examples/