Ktor, how to deal with jdbc blocking calls

Usually you just invoke blocking operation and it works fine. The problem arises then you have multiple blocking calls running simultaneously. They can exhaust CommonPool and block completely. I see three possibility here:

  1. If operations are fast and you are sure that they won’t block forever, you can call them inside coroutines.
  2. If operations are long, but you have only few of them, you can use custom CoroutineContext with increased number of parallel threads.
  3. If you have a large number of those blocking operations, you should just good old executor. If you want to evaluate the result, you can create a Channel and send results to it.