But I could just offload the CPU bound work to a b...
# ktor
m
But I could just offload the CPU bound work to a background thread and prevent the OTHER coroutines from being blocked, couldn't I?
e
Other coroutines will not be blocked. They (usually) run on a thread pool
m
I don't know for sure about ktor though. Isn't that internal to ktor? If it uses a thread pool, does it use it's own one? What's the thread limit?
e
It is configurable. # of CPU cores by default, so it is designed for CPU-bound tasks.
m
So if I have 4 cores and just 4 requests are CPU bound and take a while, no further requests can be handled even if they are very lightweight?
e
You are not supposed to block those threads. If all your code is async, you can handle tens of thousands of concurrent requests
If you have code that blocks thread, then you should consider moving that particular code to a dedicated thread-pool using
withContext(myPool) { ... }