Coroutines and use of blocking resources (e.g. JDBC calls inside actors)


I’m looking at using actors for various types of event processing however, I’m unsure what to do in situations where N actors may need to share a pool of M resources where M < N. For example lets say I have 20 actors needing to connect to a database with a pool of 10 connections. What is the impact if at any given time ~half of the actors end up blocking while they wait for a database connection to become available from the pool? Is there some pattern or abstraction I’m missing here or am I simply perhaps abusing actors in general?


So doing a bit of reading, is it sufficient to wrap my JDBC calls (including the allocation of the connection via a DataSource) in some combination of suspend, etc?


Create a thread pool of 10 and execute query using it as context.
Use the new context only for JDBC calls.