I have just started using reactivecouchbase asynchronous database driver but are running into some basic design issues. In a traditional approch I would limit the pressure I put on the database by limiting the number of connections to it. However with an asynchronous driver I can just swamp the database with new queries?
Where this has become significant is in an example as follows.
Lets say I have two different ways of calling the database.
My function calls to DB:
asyncCallDB: Future[DBResponse]
blockingCallDB: DBResponse
Now I want to map the db calls over a stream where I can use two different functions:
Flow.map()
Flow.mapAsync(numberOfConcurrentCalls)()
Now my questions is how would you select to call the database:
Flow.map(blockingCallDB) //One call at a time with back preassure
Flow.map(asyncCallDB) //Unlimited calls floods db no back pressure?
Flow.mapAsync(numberOfConcurrentCalls)(blockingCallDB) //Up to numberOfConcurrentCalls at the same time with back pressure
Flow.mapAsync(numberOfConcurrentCalls)(asyncCallDB) //Unlimited calls floods db no back pressure?
I feel that my understading is lacking here and would like to understad this type of decission.