I'm trying to make sure my understanding is correc...
# ktor
j
I'm trying to make sure my understanding is correct and I haven't directly seen the answer in docs. Does ktor server handle each request as a separate coroutine with its own separate coroutine context?
Sorry if this has been answered, feel free to send back rtfm with the doc it's in
a
For every request, Ktor fires multiple coroutines that share a coroutine context.
j
Excellent, those coroutines and the context are not shared with other ingressing requests, correct?
We have been seeing some strange behavior with the call logging library and MDC entries that gave us concern that the context was not separated per request. But it may be related to something else
a
The issue you experience is most likely unrelated to the questions you ask. There were several problems with the CallLogging plugin and MDC, so it might be another one.
Can you file an issue with a reproducer?
j
Gotcha! I'll keep investigating those issues from our end and file a ticket (though it may be difficult to reproduce since it is likely thread related)
But for our purposes, I'm looking at adding some extra info to the coroutine context for ingressing requests to help us tie and forward information on child requests - so as long as the context is not shared between multiple ingressing requests, I'm good on my end for my question.
a
Yes, every server call has a unique coroutine context. Also, there are shared server and engine contexts.
j
Excellent, thank you!