Currently we are switching to Kotlin on Smartfox, as I understood that with Java is blocking and it block the extension thread during processing time. But with Kotlin my code when processing the request is like this:
Code: Select all
override fun handleClientRequest(user: User, requestData: ISFSObject) {
ServerScope.launch {
try {
handleClientRequestInternal(user, requestData)
} catch (e: ServerErrorException) {
log.error("Error handling admin, sending error to admin: {}", user.name, e)
sendException(user, EMPTY_COMMAND_ID, e.errorCode.code, "Error handling admin, sending error to admin:${user.name}")
} catch (e: Exception) {
log.error("Error handling client request: {}", user.name, e)
sendException(user,
EMPTY_COMMAND_ID,
ServerErrorCode.SERVER_ERROR_EXCEPTION.code,
"Error handling admin request, sending error to admin:${user.name}")
}
}
}
With ServerScope.launch {...} We actually sending the whole process to Kotlin Coroutine and the extension thread will be release quickly.
Currently my server serving for about 12K users and with this Kotlin we are facing with I/O call request timeout fequently. From what I observe the request got 2 cases, some stuck and not be sent out until get timeout. Another case is some request have been already sent out and result have been responsed from the called server but some how that result is not be processed by SFS server and the request getting timeout.
When using Java we also getting that issue but very little. Mostly because of the blocking, server use up all the extension threads, the client request need to be wait until its turn so this request timeout rarely happen.
Please also have a look at my config thead pool on server side, my server using Linux and it have 32 cores and 64Gb Ram.
https://prnt.sc/1v4nznh
I wonder is there anything else I need to config more on Linux config or I need to increase the thr ead pool on SFS server.