I am new to Project reactor and I am trying to understanding difference between boundedElastic() vs parallel() scheduler. Documennt (https://projectreactor.io/docs/core/release/api/) says that boundedElastic() is used for blocking tasks and parallel() for non-blocking tasks. Why do Project reactor need to address blocking scenario as they are non-blocking in nature. Can someone please help me out with some realtime use case for boundedElastic() vs parallel() scheduler ?
7
votes
1 Answers
1
votes
The parallel flavor is backed by N workers (according to the N cpus) each based on a ScheduledExecutorService. If you submit N long lived tasks to it, no more work can be executed, hence the affinity for short-lived tasks.
The elastic flavor is also backed by workers based on ScheduledExecutorService, except it creates these workers on demand and pools them. BoundedElastic is same as elastic, difference is that you can limit the total no. of threads.
https://spring.io/blog/2019/12/13/flight-of-the-flux-3-hopping-threads-and-schedulers