Kirillov Mikhail
05/26/2022, 8:27 AMfun ApplicationCall.receiveFlow(): Flow<ByteBuffer> = flow<ByteBuffer> {
val channel = receiveChannel()
try {
while (true) {
val buffer = ByteBuffer.allocate(4096)
if (channel.readAvailable(buffer) == -1) {
break
}
buffer.flip()
emit(buffer)
}
} catch (e: Exception) {
log.error("URL: '${request.uri}' error reading body", e)
throw e
}
}
If server slowly process http request - we see increase direct byte buffers (non-heap), this buffers create netty for buffering request (buffers grows to 2 gb)
I expected back pressure in ktor, but buffers are growing...
I communicated with netty users - they recommend disable autoread at channel and use read() manually
Does ktor support back pressure? If so, how enable it?Kirillov Mikhail
05/26/2022, 12:01 PMKirillov Mikhail
05/26/2022, 12:07 PMKirillov Mikhail
05/26/2022, 1:14 PMKirillov Mikhail
05/30/2022, 6:13 AMbitkid
06/02/2022, 12:19 PM