Skip to content

Commit 3b5b79e

Browse files
authored
Merge pull request #58 from oktadev/jchampions-2024
Upgrade frameworks for jChampions Conference presentation
2 parents 4d9c317 + 269db34 commit 3b5b79e

File tree

25 files changed

+106
-139
lines changed

25 files changed

+106
-139
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ rm -rf {micronaut,quarkus,spring-boot}/build
77
rm -rf helidon/target
88

99
source ~/.sdkman/bin/sdkman-init.sh
10-
sdk use java 21-graalce
10+
sdk use java 21.0.1-graalce
1111

1212
echo "Building Micronaut..."
1313
cd micronaut && ./gradlew nativeCompile

demo.adoc

Lines changed: 29 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ toc::[]
2121

2222
Use SDKMAN to install Java 21 with GraalVM
2323

24-
sdk install java 21-graalce
24+
sdk install java 21.0.1-graalce
2525

2626
== Generate an OAuth 2.0 Access Token
2727

@@ -32,7 +32,7 @@ Use SDKMAN to install Java 21 with GraalVM
3232
+
3333
[source,shell]
3434
----
35-
auth0 test token -a https://<your-auth0-domain>/api/v2/
35+
auth0 test token -a https://<your-auth0-domain>/api/v2/ -s openid
3636
----
3737

3838
. Set the access token as a `TOKEN` environment variable in a terminal window.
@@ -222,9 +222,11 @@ public class HelloResourceTest {
222222
[source,shell]
223223
----
224224
sdk install springboot
225-
spring init -d=web,oauth2-resource-server,native \
225+
spring init -d=web,oauth2-resource-server,native -b=3.2.0 \
226226
--group-id=com.okta.rest --package-name=com.okta.rest spring-boot
227227
----
228+
+
229+
CAUTION: Spring Boot 3.2.1 https://github.com/oktadev/auth0-java-rest-api-examples/pull/58#issuecomment-1877844650[does not work with GraalVM].
228230

229231
. Add a `HelloController` class that returns the user's information: [`sb-hello`]
230232
+
@@ -383,7 +385,8 @@ mp.jwt.verify.publickey.location=${mp.jwt.verify.issuer}.well-known/jwks.json
383385
----
384386
Args=--initialize-at-build-time=com.okta.rest \
385387
--initialize-at-run-time=io.helidon.openapi.ExpandedTypeDescription \
386-
--report-unsupported-elements-at-runtime
388+
--report-unsupported-elements-at-runtime \
389+
-H:+AddAllCharsets
387390
----
388391

389392
. Compile your Helidon app into a native executable using the `native-image` profile:
@@ -401,72 +404,32 @@ Args=--initialize-at-build-time=com.okta.rest \
401404
== Startup Time Comparison
402405

403406
. Run each image three times before recording the numbers, then each command five times.
407+
+
408+
TIP: Use the link:start.sh[`start.sh`] script to get the real time, not what each framework prints to the console.
404409

405410
. Write each time down, add them up, and divide by five for the average. For example:
406411
+
407412
----
408-
Micronaut: (19 + 18 + 17 + 12 + 19) / 5 = 17
409-
Micronaut (optimized): (18 + 15 + 19 + 20 + 17) / 5 = 17.8
410-
Quarkus: (29 + 26 + 27 + 29 + 25) / 5 = 27.2
411-
Spring Boot: (42 + 43 + 37 + 44 + 36) / 5 = 40.4
412-
Helidon*: (50 + 52 + 42 + 53 + 55) / 5 = 50.4
413-
Helidon (optimized): (33 + 34 + 38 + 37 + 36) / 5 = 35.6
413+
Micronaut: (51 + 50 + 51 + 47 + 47) / 5 = 49.2
414+
Micronaut (optimized): (49 + 50 + 48 + 52 + 57) / 5 = 51.2
415+
Quarkus: (48 + 44 + 46 + 49 + 54) / 5 = 48.2
416+
Spring Boot: (70 + 70 + 75 + 73 + 69) / 5 = 71.4
417+
Helidon: (66 + 68 + 62 + 64 + 73) / 5 = 66.6
418+
Helidon (optimized): (42 + 44 +68 + 49 + 66) / 5 = 53.8
414419
----
415-
+
416-
NOTE: Helidon https://github.com/helidon-io/helidon/issues/7784[requires Java 20].
417420

418421
.Native Java startup times in milliseconds
419422
|===
420423
|Framework | Command executed | Milliseconds to start
421424

422-
|Micronaut | `./micronaut/build/native/nativeCompile/app` | 17
423-
|Micronaut (optimized) | `./micronaut/build/native/nativeOptimizedCompile/app` | 17.8
424-
|Quarkus | `./quarkus/build/quarkus-1.0.0-SNAPSHOT-runner` | 27.2
425-
|Spring Boot | `./spring-boot/build/native/nativeCompile/spring-boot` | 40.4
426-
|Helidon | `./helidon/target/helidon` | 50.4
427-
|Helidon (optimized) | https://github.com/oktadev/auth0-java-rest-api-examples/pull/2[auth0-java-rest-api-examples/pull/2] | 35.6
425+
|Micronaut | `./micronaut/build/native/nativeCompile/app` | 49.2
426+
|Micronaut (optimized) | `./micronaut/build/native/nativeOptimizedCompile/app` | 51.2
427+
|Quarkus | `./quarkus/build/quarkus-1.0.0-SNAPSHOT-runner` | 48.2
428+
|Spring Boot | `./spring-boot/build/native/nativeCompile/spring-boot` | 71.4
429+
|Helidon | `./helidon/target/helidon` | 66.6
430+
|Helidon (optimized) | https://github.com/oktadev/auth0-java-rest-api-examples/pull/2[auth0-java-rest-api-examples/pull/2] | 53.8
428431
|===
429432

430-
////
431-
October 19, 2023:
432-
- Micronaut: 17
433-
- Micronaut (optimized): 17.8
434-
- Quarkus: 27.2
435-
- Spring Boot: 40.4
436-
- Helidon: 50.4
437-
- Helidon (optimized): 35.6
438-
439-
October 17, 2023:
440-
- Micronaut: 16.2
441-
- Micronaut (optimized): 16
442-
- Quarkus: 27.8
443-
- Spring Boot: 38.4
444-
- Helidon: 49.2
445-
- Helidon (optimized): 23.8
446-
447-
August 2023:
448-
- Micronaut: 15.6
449-
- Micronaut (optimized): 14
450-
- Quarkus: 36.8
451-
- Spring Boot: 38.2
452-
- Helidon: 48.4
453-
- Helidon (optimized): 30.8
454-
455-
June 2023:
456-
- Micronaut: 33.4
457-
- Micronaut (optimized): 23.8
458-
- Quarkus: 25.8
459-
- Spring Boot: 39.8
460-
- Helidon: 47.6
461-
- Helidon (optimized): 33.2
462-
463-
October 2022:
464-
- Micronaut was 18
465-
- Quarkus was 20.6
466-
- Spring Boot was 39
467-
- Helidon was 43.2
468-
////
469-
470433
== Memory Usage Comparison
471434

472435
Test the memory usage in MB of each app using the command below. Make sure to send an HTTP request to each one before measuring.
@@ -480,14 +443,14 @@ Substitute `<executable>` as follows:
480443

481444
.Native Java memory used in megabytes
482445
|===
483-
|Framework | Executable | Megabytes after startup | Megabytes after 1 request| Megabytes after 5 requests
484-
485-
|Micronaut | `app` | 53 | 63 | 64
486-
|Micronaut (optimized) | `app` | 45 | 65 | 67
487-
|Quarkus | `quarkus` | 41 | 51 | 53
488-
|Spring Boot | `spring-boot` | 74 | 84 | 84
489-
|Helidon | `helidon` | 83 | 99 | 117
490-
|Helidon (optimized) | `helidon` | 72 | 89 | 123
446+
|Framework | Executable | Megabytes after startup | Megabytes after 1 request| Megabytes after 10 requests
447+
448+
|Micronaut | `app` | 53 | 62 | 66
449+
|Micronaut (optimized) | `app` | 53 | 63 | 67
450+
|Quarkus | `quarkus` | 37 | 48 | 52
451+
|Spring Boot | `spring-boot` | 76 | 86 | 87
452+
|Helidon | `helidon` | 82 | 92 | 93
453+
|Helidon (optimized) | `helidon` | 62 | 72 | 73
491454
|===
492455

493456
IMPORTANT: If you disagree with these numbers and think X framework should be faster, I encourage you to clone https://github.com/oktadev/auth0-java-rest-api-examples[this repo] and run these tests yourself.

helidon/.helidon

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

helidon/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
<parent>
77
<groupId>io.helidon.applications</groupId>
88
<artifactId>helidon-mp</artifactId>
9-
<version>4.0.1</version>
9+
<version>4.0.2</version>
1010
<relativePath/>
1111
</parent>
1212
<groupId>com.okta.rest</groupId>
1313
<artifactId>helidon</artifactId>
1414
<version>1.0-SNAPSHOT</version>
1515

16-
1716
<dependencies>
1817
<dependency>
1918
<groupId>io.helidon.microprofile.bundles</groupId>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
Args=--initialize-at-build-time=com.okta.rest \
22
--initialize-at-run-time=io.helidon.openapi.ExpandedTypeDescription \
3-
--report-unsupported-elements-at-runtime
3+
--report-unsupported-elements-at-runtime \
4+
-H:+AddAllCharsets

memory.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ memory() {
4545
kill_cmd="fuser -k -n tcp 8080"
4646

4747
if [[ "$OSTYPE" == "darwin"* ]]; then
48-
kill_cmd="kill -9 $(lsof -i:8080 -t)"
48+
fkill --version || echo "fkill is missing. Install it using 'npm i -g fkill-cli'."
49+
kill_cmd="fkill :8080"
4950
fi
5051

5152
# Start the app in the background
@@ -66,13 +67,13 @@ while true; do
6667
echo -e "\n---- Memory usage after the first request:"
6768
memory $executable
6869

69-
# Make four more curl requests with an access token
70-
for ((i=1; i<=4; i++)); do
70+
# Make 9 more curl requests with an access token
71+
for ((i=1; i<=9; i++)); do
7172
curl -s -o /dev/null localhost:8080/hello -i --header "Authorization: Bearer $access_token"
7273
done
7374

74-
# Print out memory usage after five requests
75-
echo -e "\n---- Memory usage after five requests:"
75+
# Print out memory usage after 10 requests
76+
echo -e "\n---- Memory usage after 10 requests:"
7677
memory $executable
7778

7879
# Kill the app

micronaut/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
## Micronaut 4.1.4 Documentation
1+
## Micronaut 4.2.3 Documentation
22

3-
- [User Guide](https://docs.micronaut.io/4.1.4/guide/index.html)
4-
- [API Reference](https://docs.micronaut.io/4.1.4/api/index.html)
5-
- [Configuration Reference](https://docs.micronaut.io/4.1.4/guide/configurationreference.html)
3+
- [User Guide](https://docs.micronaut.io/4.2.3/guide/index.html)
4+
- [API Reference](https://docs.micronaut.io/4.2.3/api/index.html)
5+
- [Configuration Reference](https://docs.micronaut.io/4.2.3/guide/configurationreference.html)
66
- [Micronaut Guides](https://guides.micronaut.io/index.html)
77
---
88

99
- [Shadow Gradle Plugin](https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow)
1010
- [Micronaut Gradle Plugin documentation](https://micronaut-projects.github.io/micronaut-gradle-plugin/latest/)
1111
- [GraalVM Gradle Plugin documentation](https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html)
12+
## Feature security-jwt documentation
13+
14+
- [Micronaut Security JWT documentation](https://micronaut-projects.github.io/micronaut-security/latest/guide/index.html)
15+
16+
1217
## Feature serialization-jackson documentation
1318

1419
- [Micronaut Serialization Jackson Core documentation](https://micronaut-projects.github.io/micronaut-serialization/latest/guide/)
@@ -19,8 +24,3 @@
1924
- [Micronaut AOT documentation](https://micronaut-projects.github.io/micronaut-aot/latest/guide/)
2025

2126

22-
## Feature security-jwt documentation
23-
24-
- [Micronaut Security JWT documentation](https://micronaut-projects.github.io/micronaut-security/latest/guide/index.html)
25-
26-
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
id("com.github.johnrengelman.shadow") version "8.1.1"
3-
id("io.micronaut.application") version "4.1.2"
4-
id("io.micronaut.aot") version "4.1.2"
3+
id("io.micronaut.application") version "4.2.1"
4+
id("io.micronaut.aot") version "4.2.1"
55
}
66

77
version = "0.1"
@@ -20,10 +20,11 @@ dependencies {
2020
compileOnly("io.micronaut:micronaut-http-client")
2121
runtimeOnly("ch.qos.logback:logback-classic")
2222
testImplementation("io.micronaut:micronaut-http-client")
23-
aotPlugins platform("io.micronaut.platform:micronaut-platform:4.1.6")
23+
aotPlugins(platform("io.micronaut.platform:micronaut-platform:4.2.3"))
2424
aotPlugins("io.micronaut.security:micronaut-security-aot")
2525
}
2626

27+
2728
application {
2829
mainClass.set("com.okta.rest.Application")
2930
}
@@ -32,7 +33,8 @@ java {
3233
targetCompatibility = JavaVersion.toVersion("17")
3334
}
3435

35-
graalvmNative.toolchainDetection = false
36+
37+
graalvmNative.toolchainDetection.set(false)
3638
micronaut {
3739
runtime("netty")
3840
testRuntime("junit5")
@@ -43,13 +45,13 @@ micronaut {
4345
aot {
4446
// Please review carefully the optimizations enabled below
4547
// Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details
46-
optimizeServiceLoading = false
47-
convertYamlToJava = false
48-
precomputeOperations = true
49-
cacheEnvironment = true
50-
optimizeClassLoading = true
51-
deduceEnvironment = true
52-
optimizeNetty = true
48+
optimizeServiceLoading.set(false)
49+
convertYamlToJava.set(false)
50+
precomputeOperations.set(true)
51+
cacheEnvironment.set(true)
52+
optimizeClassLoading.set(true)
53+
deduceEnvironment.set(true)
54+
optimizeNetty.set(true)
5355
configurationProperties.put("micronaut.security.jwks.enabled","false")
5456
}
5557
}

micronaut/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
micronautVersion=4.1.4
1+
micronautVersion=4.2.3
346 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)