From ddfc472c84413e2c658925cb7bb14e9de67766ec Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 24 Mar 2023 23:41:10 +0000 Subject: [PATCH] Switch to Ktor's Jetty backend We've now found both the CIO and Netty backends to be problematic in certain cases (CIO with lots of concurrent requests, Netty with backpressure). Hopefully Jetty is a bit more battle-tested! Signed-off-by: Graham --- archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt | 4 ++-- gradle/libs.versions.toml | 4 ++-- log/src/main/resources/logback.xml | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt b/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt index 4aa64ac0e3..4688841388 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt @@ -6,10 +6,10 @@ import io.ktor.serialization.jackson.JacksonConverter import io.ktor.server.application.ApplicationCall import io.ktor.server.application.call import io.ktor.server.application.install -import io.ktor.server.cio.CIO import io.ktor.server.engine.embeddedServer import io.ktor.server.http.content.resources import io.ktor.server.http.content.static +import io.ktor.server.jetty.Jetty import io.ktor.server.plugins.autohead.AutoHeadResponse import io.ktor.server.plugins.cachingheaders.CachingHeaders import io.ktor.server.plugins.conditionalheaders.ConditionalHeaders @@ -39,7 +39,7 @@ public class WebServer @Inject constructor( @Json private val mapper: ObjectMapper ) { public fun start(address: String, port: Int) { - embeddedServer(CIO, host = address, port = port) { + embeddedServer(Jetty, host = address, port = port) { install(AutoHeadResponse) install(CachingHeaders) install(ConditionalHeaders) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6539f00cda..69b016331b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -60,12 +60,12 @@ kotlinPoet = { module = "com.squareup:kotlinpoet", version = "1.12.0" } ktor-serialization-jackson = { module = "io.ktor:ktor-serialization-jackson", version.ref = "ktor" } ktor-server-autoHeadResponse = { module = "io.ktor:ktor-server-auto-head-response", version.ref = "ktor" } ktor-server-cachingHeaders = { module = "io.ktor:ktor-server-caching-headers", version.ref = "ktor" } -ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor" } ktor-server-conditionalHeaders = { module = "io.ktor:ktor-server-conditional-headers", version.ref = "ktor" } ktor-server-contentNegotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "ktor" } ktor-server-cors = { module = "io.ktor:ktor-server-cors", version.ref = "ktor" } ktor-server-defaultHeaders = { module = "io.ktor:ktor-server-default-headers", version.ref = "ktor" } ktor-server-forwardedHeader = { module = "io.ktor:ktor-server-forwarded-header", version.ref = "ktor" } +ktor-server-jetty = { module = "io.ktor:ktor-server-jetty", version.ref = "ktor" } ktor-server-thymeleaf = { module = "io.ktor:ktor-server-thymeleaf", version.ref = "ktor" } ktor-server-webjars = { module = "io.ktor:ktor-server-webjars", version.ref = "ktor" } logback = { module = "ch.qos.logback:logback-classic", version = "1.4.6" } @@ -93,12 +93,12 @@ ktor = [ "ktor-serialization-jackson", "ktor-server-autoHeadResponse", "ktor-server-cachingHeaders", - "ktor-server-cio", "ktor-server-conditionalHeaders", "ktor-server-contentNegotiation", "ktor-server-cors", "ktor-server-defaultHeaders", "ktor-server-forwardedHeader", + "ktor-server-jetty", "ktor-server-thymeleaf", "ktor-server-webjars", ] diff --git a/log/src/main/resources/logback.xml b/log/src/main/resources/logback.xml index 6a41c66c32..45c49018be 100644 --- a/log/src/main/resources/logback.xml +++ b/log/src/main/resources/logback.xml @@ -19,6 +19,10 @@ + + + +