1
0
Fork 1
mirror of https://gitlab.com/mangadex-pub/mangadex_at_home.git synced 2024-01-19 02:48:37 +00:00

Made more changes to the numbers used for threading

This commit is contained in:
Amos Ng 2020-06-12 02:47:43 +08:00
parent c87a0c0041
commit ac682e98c3
No known key found for this signature in database
GPG key ID: 89086414F634D123
2 changed files with 8 additions and 5 deletions

View file

@ -45,7 +45,7 @@ fun getServer(cache: DiskLruCache, serverSettings: ServerSettings, clientSetting
val executor = Executors.newCachedThreadPool() val executor = Executors.newCachedThreadPool()
if (LOGGER.isInfoEnabled) { if (LOGGER.isInfoEnabled) {
LOGGER.info("Starting ApacheClient with {} threads", THREADS_TO_ALLOCATE) LOGGER.info("Starting image retriever")
} }
val client = ApacheClient(responseBodyMode = BodyMode.Stream, client = HttpClients.custom() val client = ApacheClient(responseBodyMode = BodyMode.Stream, client = HttpClients.custom()
@ -144,7 +144,6 @@ fun getServer(cache: DiskLruCache, serverSettings: ServerSettings, clientSetting
if (LOGGER.isTraceEnabled) { if (LOGGER.isTraceEnabled) {
LOGGER.trace("Upstream query for $sanitizedUri errored with status {}", mdResponse.status) LOGGER.trace("Upstream query for $sanitizedUri errored with status {}", mdResponse.status)
} }
mdResponse.close()
Response(mdResponse.status) Response(mdResponse.status)
} else { } else {
if (LOGGER.isTraceEnabled) { if (LOGGER.isTraceEnabled) {
@ -195,7 +194,6 @@ fun getServer(cache: DiskLruCache, serverSettings: ServerSettings, clientSetting
} }
respondWithImage(mdResponse.body.stream, contentLength, contentType, lastModified) respondWithImage(mdResponse.body.stream, contentLength, contentType, lastModified)
} }
mdResponse.close()
} }
} }
} }

View file

@ -35,11 +35,12 @@ import java.util.concurrent.atomic.AtomicReference
import javax.net.ssl.SSLException import javax.net.ssl.SSLException
private val LOGGER = LoggerFactory.getLogger("Application") private val LOGGER = LoggerFactory.getLogger("Application")
private val THREADS_TO_ALLOCATE = Runtime.getRuntime().availableProcessors() * 32 / 2
class Netty(private val tls: ServerSettings.TlsCert, private val clientSettings: ClientSettings, private val stats: AtomicReference<Statistics>) : ServerConfig { class Netty(private val tls: ServerSettings.TlsCert, private val clientSettings: ClientSettings, private val stats: AtomicReference<Statistics>) : ServerConfig {
override fun toServer(httpHandler: HttpHandler): Http4kServer = object : Http4kServer { override fun toServer(httpHandler: HttpHandler): Http4kServer = object : Http4kServer {
private val masterGroup = NioEventLoopGroup(Runtime.getRuntime().availableProcessors() * 30 / 2) private val masterGroup = NioEventLoopGroup(THREADS_TO_ALLOCATE)
private val workerGroup = NioEventLoopGroup(Runtime.getRuntime().availableProcessors() * 30 / 2) private val workerGroup = NioEventLoopGroup(THREADS_TO_ALLOCATE)
private lateinit var closeFuture: ChannelFuture private lateinit var closeFuture: ChannelFuture
private lateinit var address: InetSocketAddress private lateinit var address: InetSocketAddress
@ -52,6 +53,10 @@ class Netty(private val tls: ServerSettings.TlsCert, private val clientSettings:
} }
override fun start(): Http4kServer = apply { override fun start(): Http4kServer = apply {
if (LOGGER.isInfoEnabled) {
LOGGER.info("Starting webserver with {} threads", THREADS_TO_ALLOCATE)
}
val (mainCert, chainCert) = getX509Certs(tls.certificate) val (mainCert, chainCert) = getX509Certs(tls.certificate)
val sslContext = SslContextBuilder val sslContext = SslContextBuilder
.forServer(getPrivateKey(tls.privateKey), mainCert, chainCert) .forServer(getPrivateKey(tls.privateKey), mainCert, chainCert)