Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Kotlin] Added r2dbc to Ktor suite #9487

Merged
merged 9 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions frameworks/Kotlin/ktor/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@
"notes": "http://ktor.io/",
"versus": "netty"
},
"r2dbc": {
"plaintext_url": "/plaintext",
"json_url": "/json",
"db_url": "/db",
"query_url": "/queries?queries=",
"update_url": "/updates?queries=",
"fortune_url": "/fortunes",

"port": 9090,
"approach": "Realistic",
"classification": "Micro",
"database": "Postgres",
"framework": "ktor",
"language": "Kotlin",
"orm": "Raw",
"platform": "Netty",
"webserver": "None",
"os": "Linux",
"database_os": "Linux",
"display_name": "ktor-netty-r2dbc",
"notes": "http://ktor.io/",
"versus": "netty"
},
"jetty": {
"plaintext_url": "/plaintext",
"json_url": "/json",
Expand Down
15 changes: 10 additions & 5 deletions frameworks/Kotlin/ktor/ktor-asyncdb/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
application
kotlin("jvm") version "1.9.22"
kotlin("jvm") version "2.0.21"
kotlin("plugin.serialization") version "2.0.0"
id("com.github.johnrengelman.shadow") version "8.1.0"
}
Expand All @@ -17,20 +17,25 @@ application {
}

val ktor_version = "2.3.12"
val kotlinx_serialization_version = "1.6.3"
val vertx_pg_client = "4.5.8"
val kotlinx_serialization_version = "1.7.3"

dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinx_serialization_version")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
implementation("io.ktor:ktor-server-netty:$ktor_version")
implementation("io.ktor:ktor-server-default-headers:$ktor_version")
implementation("io.ktor:ktor-server-html-builder:$ktor_version")
implementation("com.github.jasync-sql:jasync-postgresql:2.2.0")
implementation("com.github.jasync-sql:jasync-postgresql:2.2.4")
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

tasks.shadowJar {
archiveBaseName.set("bench")
archiveBaseName.set("ktor-asyncdb")
archiveClassifier.set("")
archiveVersion.set("")
}
2 changes: 1 addition & 1 deletion frameworks/Kotlin/ktor/ktor-asyncdb/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kotlin.code.style=official

kotlin_version=1.9.22
kotlin_version=2.0.21
ktor_version=2.3.12
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Dec 07 21:01:17 MST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
14 changes: 0 additions & 14 deletions frameworks/Kotlin/ktor/ktor-asyncdb/settings.gradle

This file was deleted.

1 change: 1 addition & 0 deletions frameworks/Kotlin/ktor/ktor-asyncdb/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "tech-empower-framework-benchmark"
6 changes: 3 additions & 3 deletions frameworks/Kotlin/ktor/ktor-cio.dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM maven:3.9.7-amazoncorretto-17-debian as maven
FROM maven:3.9.9-amazoncorretto-21-debian-bookworm as maven
WORKDIR /ktor
COPY ktor/pom.xml pom.xml
COPY ktor/src src
RUN mvn clean package -q

FROM amazoncorretto:17.0.11-al2023-headless
FROM amazoncorretto:21-al2023-headless
WORKDIR /ktor
COPY --from=maven /ktor/target/tech-empower-framework-benchmark-1.0-SNAPSHOT-cio-bundle.jar app.jar

EXPOSE 9090

CMD ["java", "-jar", "app.jar"]
CMD ["java", "-server","-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AlwaysPreTouch", "-jar", "app.jar"]
2 changes: 1 addition & 1 deletion frameworks/Kotlin/ktor/ktor-exposed/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {
mavenCentral()
}

val ktorVersion = "3.0.1"
val ktorVersion = "3.0.3"
val kotlinxSerializationVersion = "1.7.3"
val exposedVersion = "0.56.0"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
10 changes: 6 additions & 4 deletions frameworks/Kotlin/ktor/ktor-jasync.dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM maven:3.9.7-amazoncorretto-17-debian
FROM gradle:jdk21 as build
WORKDIR /app
COPY ktor-asyncdb/gradle gradle
COPY ktor-asyncdb/build.gradle.kts build.gradle.kts
COPY ktor-asyncdb/gradle.properties gradle.properties
COPY ktor-asyncdb/gradlew gradlew
COPY ktor-asyncdb/settings.gradle settings.gradle
COPY ktor-asyncdb/src src
RUN /app/gradlew --no-daemon shadowJar

FROM amazoncorretto:21-al2023-headless
WORKDIR /app
COPY --from=build /app/build/libs/ktor-asyncdb.jar ktor-asyncdb.jar

EXPOSE 9090

CMD ["java", "-server", "-XX:+UseParallelGC", "-Xms2G","-Xmx2G", "-jar", "/app/build/libs/bench.jar", "jasync-sql"]
CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AlwaysPreTouch", "-jar", "ktor-asyncdb.jar", "jasync-sql"]
6 changes: 3 additions & 3 deletions frameworks/Kotlin/ktor/ktor-jetty.dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM maven:3.9.7-amazoncorretto-17-debian as maven
FROM maven:3.9.9-amazoncorretto-21-debian-bookworm as maven
WORKDIR /ktor
COPY ktor/pom.xml pom.xml
COPY ktor/src src
RUN mvn clean package -q

FROM amazoncorretto:17.0.11-al2023-headless
FROM amazoncorretto:21-al2023-headless
WORKDIR /ktor
COPY --from=maven /ktor/target/tech-empower-framework-benchmark-1.0-SNAPSHOT-jetty-bundle.jar app.jar

EXPOSE 9090

CMD ["java", "-jar", "app.jar"]
CMD ["java", "-server","-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AlwaysPreTouch", "-jar", "app.jar"]
6 changes: 3 additions & 3 deletions frameworks/Kotlin/ktor/ktor-pgclient.dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM maven:3.9.7-amazoncorretto-17-debian as build
FROM gradle:jdk21 as build
WORKDIR /app
COPY ktor-pgclient/gradle gradle
COPY ktor-pgclient/build.gradle.kts build.gradle.kts
COPY ktor-pgclient/gradlew gradlew
COPY ktor-pgclient/src src
RUN /app/gradlew --no-daemon shadowJar

FROM amazoncorretto:17.0.11-al2023-headless
FROM amazoncorretto:21-al2023-headless
WORKDIR /app
COPY --from=build /app/build/libs/ktor-pgclient.jar ktor-pgclient.jar

EXPOSE 8080

CMD ["java", "-server", "-XX:MaxRAMFraction=1", "-XX:-UseBiasedLocking", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AlwaysPreTouch", "-jar", "ktor-pgclient.jar"]
CMD ["java", "-server","-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AlwaysPreTouch", "-jar", "ktor-pgclient.jar"]
17 changes: 10 additions & 7 deletions frameworks/Kotlin/ktor/ktor-pgclient/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
application
kotlin("jvm") version "1.9.22"
kotlin("jvm") version "2.0.21"
kotlin("plugin.serialization") version "2.0.0"
id("com.github.johnrengelman.shadow") version "8.1.0"
}
Expand All @@ -17,19 +17,22 @@ application {
}

val ktor_version = "2.3.12"
val vertx_version = "4.5.11"

dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
implementation("io.ktor:ktor-server-netty:$ktor_version")
implementation("io.ktor:ktor-server-html-builder-jvm:$ktor_version")
implementation("io.ktor:ktor-server-default-headers-jvm:$ktor_version")
implementation("io.vertx:vertx-pg-client:4.5.8")
implementation("io.vertx:vertx-lang-kotlin:4.5.8")
implementation("io.vertx:vertx-lang-kotlin-coroutines:4.5.8")
implementation("io.vertx:vertx-pg-client:$vertx_version")
implementation("io.vertx:vertx-lang-kotlin:$vertx_version")
implementation("io.vertx:vertx-lang-kotlin-coroutines:$vertx_version")
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "17"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

tasks.shadowJar {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
13 changes: 13 additions & 0 deletions frameworks/Kotlin/ktor/ktor-r2dbc.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM maven:3.9.9-amazoncorretto-21-debian-bookworm as maven
WORKDIR /ktor-r2dbc
COPY ktor-r2dbc/pom.xml pom.xml
COPY ktor-r2dbc/src src
RUN mvn clean package -q

FROM amazoncorretto:21-al2023-headless
WORKDIR /ktor-r2dbc
COPY --from=maven /ktor-r2dbc/target/tech-empower-framework-benchmark-1.0-SNAPSHOT-netty-bundle.jar app.jar

EXPOSE 9090

CMD ["java", "-server","-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AlwaysPreTouch", "-jar", "app.jar"]
50 changes: 50 additions & 0 deletions frameworks/Kotlin/ktor/ktor-r2dbc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Ktor

Ktor is a framework for building servers and clients in connected systems using Kotlin programming language.
More information is available at [ktor.io](http://ktor.io).

# Setup

* Java 21
* Postgres server

# Requirements

* Maven 3
* JDK 21
* Kotlin
* ktor
* netty
* R2DBC

Maven is downloaded automatically via Maven Wrapper script (`mvnw`), add dependencies are specified in `pom.xml` so will be downloaded automatically from maven central and jcenter repositories.

# Deployment

Run maven to build a bundle

```bash
./mvnw package
```

Once bundle build complete and mysql server is running you can launch the application

```bash
java -jar target/tech-empower-framework-benchmark-1.0-SNAPSHOT.jar
```

Please note that the server holds tty so you may need nohup. See `setup.sh` for details.

# Contact

[Leonid Stashevsky](https://github.com/e5l)

[Sergey Mashkov](https://github.com/cy6erGn0m)

[Ilya Ryzhenkov](https://github.com/orangy)

[Ilya Nemtsev](https://github.com/inemtsev)

Slack ktor channel https://kotlinlang.slack.com/messages/ktor (you need an [invite](http://slack.kotlinlang.org/) to join)


Loading
Loading