Browse Source

upgrade to http4k to take advantage of tweaks to Apache and Netty, reduce pool size (#3959)

David Denton 7 years ago
parent
commit
b8666e08ed

+ 2 - 28
frameworks/Kotlin/http4k/apache/src/main/kotlin/Http4kApacheServer.kt

@@ -1,32 +1,6 @@
-import org.apache.http.config.SocketConfig
-import org.apache.http.impl.bootstrap.ServerBootstrap
-import org.http4k.core.HttpHandler
-import org.http4k.server.Http4kRequestHandler
-import org.http4k.server.Http4kServer
-import org.http4k.server.ServerConfig
-import java.util.concurrent.TimeUnit
 
 
-private const val PORT = 9000
+import org.http4k.server.ApacheServer
 
 
 fun main(args: Array<String>) {
 fun main(args: Array<String>) {
-    Http4kBenchmarkServer().start(object : ServerConfig {
-        override fun toServer(httpHandler: HttpHandler): Http4kServer = object : Http4kServer {
-            override fun port() = PORT
-
-            private val server = ServerBootstrap.bootstrap()
-                    .setListenerPort(PORT)
-                    .setSocketConfig(SocketConfig.custom()
-                            .setTcpNoDelay(true)
-                            .setSoKeepAlive(true)
-                            .setSoReuseAddress(true)
-                            .setBacklogSize(512)
-                            .build())
-                    .registerHandler("*", Http4kRequestHandler(httpHandler))
-                    .create()
-
-            override fun start() = apply { server.start() }
-
-            override fun stop() = server.shutdown(15, TimeUnit.SECONDS)
-        }
-    })
+    Http4kBenchmarkServer().start(ApacheServer(9000))
 }
 }

+ 1 - 1
frameworks/Kotlin/http4k/build.gradle

@@ -1,6 +1,6 @@
 buildscript {
 buildscript {
     ext.kotlin_version = "1.2.50"
     ext.kotlin_version = "1.2.50"
-    ext.http4k_version = "3.33.1"
+    ext.http4k_version = "3.34.0"
 
 
     repositories {
     repositories {
         mavenCentral()
         mavenCentral()

+ 1 - 1
frameworks/Kotlin/http4k/core/src/main/kotlin/Database.kt

@@ -28,7 +28,7 @@ open class Database(private val dataSource: DataSource) {
 
 
             val config = HikariConfig()
             val config = HikariConfig()
             config.jdbcUrl = postgresqlUrl
             config.jdbcUrl = postgresqlUrl
-            config.maximumPoolSize = 256
+            config.maximumPoolSize = 100
             config.username = "benchmarkdbuser"
             config.username = "benchmarkdbuser"
             config.password = "benchmarkdbpass"
             config.password = "benchmarkdbpass"
             return Database(HikariDataSource(config))
             return Database(HikariDataSource(config))