https://kotlinlang.org logo
Title
g

gotoOla

04/15/2020, 8:55 PM
Does anybody here know what resources (Java threads) coroutines are running on if you run ktor with netty? Especially how the http thread pool vs worker pool works? E.g. If I get a request in a route and then start to call a service layer without changing the dispatcher myself
o

octylFractal

04/15/2020, 9:01 PM
according to https://github.com/ktorio/ktor/blob/master/ktor-server/ktor-server-netty/jvm/src/io/ktor/server/netty/NettyApplicationEngine.kt#L71-L90 there are 2-3 work pools, one for connection accepting, one for being netty's worker pool, and either one more for processing public Ktor code (i.e. this is where your call comes in) OR this is shared with the netty worker pool (configuration option)
g

gotoOla

04/15/2020, 9:14 PM
Ok. So when I get the call in code I've written netty has already then their magic with the http pool? And at that point I'm working with ktors pool by default?
o

octylFractal

04/15/2020, 9:15 PM
it depends on the configuration option you set
g

gotoOla

04/15/2020, 9:21 PM
Ok, I'll check tomorrow when I'm by my laptop and not phone. Thanks!