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 <gpe@openrs2.org>
master
Graham 2 years ago
parent bf30f1e4a5
commit ddfc472c84
  1. 4
      archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt
  2. 4
      gradle/libs.versions.toml
  3. 4
      log/src/main/resources/logback.xml

@ -6,10 +6,10 @@ import io.ktor.serialization.jackson.JacksonConverter
import io.ktor.server.application.ApplicationCall import io.ktor.server.application.ApplicationCall
import io.ktor.server.application.call import io.ktor.server.application.call
import io.ktor.server.application.install import io.ktor.server.application.install
import io.ktor.server.cio.CIO
import io.ktor.server.engine.embeddedServer import io.ktor.server.engine.embeddedServer
import io.ktor.server.http.content.resources import io.ktor.server.http.content.resources
import io.ktor.server.http.content.static 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.autohead.AutoHeadResponse
import io.ktor.server.plugins.cachingheaders.CachingHeaders import io.ktor.server.plugins.cachingheaders.CachingHeaders
import io.ktor.server.plugins.conditionalheaders.ConditionalHeaders import io.ktor.server.plugins.conditionalheaders.ConditionalHeaders
@ -39,7 +39,7 @@ public class WebServer @Inject constructor(
@Json private val mapper: ObjectMapper @Json private val mapper: ObjectMapper
) { ) {
public fun start(address: String, port: Int) { public fun start(address: String, port: Int) {
embeddedServer(CIO, host = address, port = port) { embeddedServer(Jetty, host = address, port = port) {
install(AutoHeadResponse) install(AutoHeadResponse)
install(CachingHeaders) install(CachingHeaders)
install(ConditionalHeaders) install(ConditionalHeaders)

@ -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-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-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-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-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-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-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-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-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-thymeleaf = { module = "io.ktor:ktor-server-thymeleaf", version.ref = "ktor" }
ktor-server-webjars = { module = "io.ktor:ktor-server-webjars", 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" } logback = { module = "ch.qos.logback:logback-classic", version = "1.4.6" }
@ -93,12 +93,12 @@ ktor = [
"ktor-serialization-jackson", "ktor-serialization-jackson",
"ktor-server-autoHeadResponse", "ktor-server-autoHeadResponse",
"ktor-server-cachingHeaders", "ktor-server-cachingHeaders",
"ktor-server-cio",
"ktor-server-conditionalHeaders", "ktor-server-conditionalHeaders",
"ktor-server-contentNegotiation", "ktor-server-contentNegotiation",
"ktor-server-cors", "ktor-server-cors",
"ktor-server-defaultHeaders", "ktor-server-defaultHeaders",
"ktor-server-forwardedHeader", "ktor-server-forwardedHeader",
"ktor-server-jetty",
"ktor-server-thymeleaf", "ktor-server-thymeleaf",
"ktor-server-webjars", "ktor-server-webjars",
] ]

@ -19,6 +19,10 @@
<appender-ref ref="STDERR" /> <appender-ref ref="STDERR" />
</logger> </logger>
<logger name="org.eclipse.jetty" level="INFO">
<appender-ref ref="STDERR" />
</logger>
<logger name="org.flywaydb" level="WARN"> <logger name="org.flywaydb" level="WARN">
<appender-ref ref="STDERR" /> <appender-ref ref="STDERR" />
</logger> </logger>

Loading…
Cancel
Save