So, if you are tasked with writing a mixed app whe...
# server
e
So, if you are tasked with writing a mixed app where there is some access to a classic DB and some micro-services to use, then you have hard time sizing threads and pools. What I'd do with kotlin coroutines in a such a case is to have a DB thread pool with a size equal to the number of DB connections and a separate "work pool" (~= # of CPU). I would dispatch all my coroutines to work pool and make sure they suspend while waiting for my microserices (use async APIs!) and use
run(dbContext) { ... }
for my DB queries and let them block my DB pool, but have them free my work pool for other stuff needing execution.
👍 1