kubele
08/15/2023, 8:09 AMSchedulers.fromExecutor(Executors.newFixedThreadPool(75))
My problem is that when I rewrote this:
@GetMapping("/get-stuff")
fun getStuff(
@RequestParam param: String
): Mono<ResponseObject> = Mono.fromCallable {
service.getStuff(param = param)
}.subscribeOn(blockingScheduler)
to use coroutines:
@GetMapping("/get-stuff")
suspend fun getStuff(
@RequestParam param: String
): ResponseObject = withContext(blockingScheduler.asCoroutineDispatcher()) {
service.getStuff(param = param)
}
the memory usage has increased almost 2-3 times.
Do you have any idea why the performance might so much worse? That's something I definitely did not expect.
Edit: I forgot to mention - the behaviour was the same when we tried to use <http://Dispatchers.IO|Dispatchers.IO>
instead of the scheduler
Slack Conversationxoangon
08/15/2023, 8:25 AMkubele
08/15/2023, 8:28 AMgetStuff()
is now suspend, otherwise it stays the same.
Yea, I didn't expect it either 😞