

Using the OpenJ9 JVM for Quarkus Applications
source link: http://heidloff.net/article/openj9-jvm-for-quarkus-applications/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Using the OpenJ9 JVM for Quarkus Applications
As defined on the home page, Quarkus is “a Kubernetes Native Java stack tailored for OpenJDK HotSpot and GraalVM”. Since I’m a big fan of OpenJ9, I’ve quickly measured memory usage of my reactive sample application where I run a microservice once with OpenJ9 and once with HotSpot.
OpenJ9 is a Java JVM that was open sourced from IBM 2-3 years ago. It’s basically the same JVM that IBM uses in hundreds of products and offerings. The nice thing is that compared to Hotspot it not only provides a 42% faster startup time, but also a 66% smaller memory footprint. Check out the documentation.
I’ve used OpenJ9 from AdoptOpenJDK where you can choose between HotSpot and OpenJ9. Read my previous blog to understand what other advantages AdoptOpenJDK provides.
Memory Usage Results
Here are the results of my little test. The diagram is from the Quarkus website. Everything that is in orange is what I’ve added for OpenJ9.

I’ve run the same service which accesses a database with OpenJ9 and HotSpot. I’ve deployed the two versions of the service from scratch and warmed them up by invoking their REST APIs. After this I invoked “docker stats | grep articles-reactive”. Hotspot showed 149.8MiB and OpenJ9 59.77MiB.
How to run the Tests
I’ve used my sample application which is part of the cloud-native-starter project. The microservice provides REST APIs which perform CRUD operations on a PostgreSQL database.
To run the microservice with OpenJ9 in Minikube, invoke the following commands.
$ git clone https://github.com/IBM/cloud-native-starter.git
$ cd cloud-native-starter/reactive
$ sh scripts/start-minikube.sh
$ sh scripts/deploy-kafka.sh
$ sh scripts/deploy-postgres.sh
$ sh scripts/deploy-articles-reactive-postgres.sh
$ curl ... [invoke command to trigger APIs returned by previous command]
$ docker stats | grep articles-reactive
I’ve used the following Dockerfile:
FROM adoptopenjdk/maven-openjdk11 as BUILD
COPY src /usr/src/app/src
COPY pom.xml /usr/src/app
WORKDIR /usr/src/app
RUN mvn package
FROM adoptopenjdk/openjdk11-openj9:ubi-minimal
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV AB_ENABLED=jmx_exporter
RUN mkdir /opt/shareclasses
RUN chmod a+rwx -R /opt/shareclasses
RUN mkdir /opt/app
COPY --from=BUILD /usr/src/app/target/lib/* /opt/app/lib/
COPY --from=BUILD /usr/src/app/target/*-runner.jar /opt/app/app.jar
CMD ["java", "-Xmx128m", "-XX:+IdleTuningGcOnIdle", "-Xtune:virtualized", "-Xscmx128m", "-Xscmaxaot100m", "-Xshareclasses:cacheDir=/opt/shareclasses", "-jar", "/opt/app/app.jar"]
In order to use Hotspot replace the Dockerfile with the content from Dockerfile.Hotspot and run the same commands.
FROM adoptopenjdk/maven-openjdk11 as BUILD
COPY src /usr/src/app/src
COPY pom.xml /usr/src/app
WORKDIR /usr/src/app
RUN mvn package
FROM fabric8/java-alpine-openjdk11-jre
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV AB_ENABLED=jmx_exporter
COPY --from=BUILD /usr/src/app/target/lib/* /deployments/lib/
COPY --from=BUILD /usr/src/app/target/*-runner.jar /deployments/app.jar
ENTRYPOINT [ "/deployments/run-java.sh" ]
Share this:
Recommend
-
254
ResponsesThere are currently no responses for this story.Be the first to respond.It has nothing to do with Java 9 and everything to do...
-
177
Copy link Member
-
70
Built from IBM's open sourced J9 VM, see how OpenJ9 compares to HotSpot when it comes to Windows-based development and how to use it for your Java projects.
-
55
内存占用和启动时间是 Java 虚拟机 (JVM) 的重要性能指标。在云环境中,内存占用变得尤为重要,因为您需要为应用程序所占用的内存付费。在本教程中,我们将展示如何使用 Eclipse OpenJ9 中的共享类特性来减少内存占用并改进 JVM 启动时间...
-
56
前言 应用程序启动时间对各类人群都很重要,其中原因也不尽相同。例如,反复执行编码-编译-测试周期的软件开发人员非常关注启动时间,因为他们希望到达更快地运行新代码的时间点。在软硬件升级或故障导致计划中或计划外的运行...
-
47
随着微服务的普及,许多企业踏上微服务之旅。 微服务化后,应用数量可能高一个数量级。 一般企业,以前三五个应用能支撑业务,微服务化之后应用数量可能多达几十个。 每个微服务往往独立部署,...
-
14
IBM Introduces the Semeru Runtimes for OpenJ9 Oct 13, 2021 1...
-
7
OpenJ9 OpenJ9 点击这里这里可以找到 Java8 的下载链接。
-
7
Monitoring Quarkus JVM Mode With Cryostat By Andrew Azores
-
7
Issues · eclipse-openj9/openj9 · GitHub Skip to content...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK