'What controls back-pressure in the Reactive Mongodb driver?

I have hard time understanding how the back-pressure mechanism in the Reactive Mongodb driver actually works. Say for example that I have a reactive flow with a Flux with many items that looks up stuff in the database, something along the lines of:

            .map { doSomeMapping(it) }
            .flatMap { repository.findById(it) }

What mechanism is used to avoid that the database isn't overloaded with requests when the flatMap executes, especially if there are a lot of similar calls in a long-running flow? The Reactor thread pool puts some limit of the number of concurrent requests as far as I understand, but does the driver take into account e.g. some connection pool value to limit the number of operations? In our particular case we have issues with too many cursors being open but it's far from easy to see how this can be limited, other than using e.g. a concatMap() to run operations sequentially instead.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source