The OpenJ9 JVM for applications Quarkus

In this article, please see How to Use OpenJ9 JVM for Quarkus application, and check memory usage results. Unraveling the elaborate architecture of those things - [lesson] You Rui

According to the definition on the home page, Quarkus is "to OpenJDK HotSpot and GraalVM tailored Kubernetes native Java stack." Since I was a loyal supporter of OpenJ9, so I quickly measure the memory usage of my reactive sample application in which I use OpenJ9 and run a micro HotSpot service.

OpenJ9 is Java JVM, it is 2--3 years ago from IBM open source. It JVM IBM and used in hundreds of products and product is basically the same. Happily, compared with Hotspot, which not only shortens start-up time by 42%, and memory footprint reduced by 66%. View the document.

I used AdoptOpenJDK in OpenJ9, you can choose between HotSpot and OpenJ9. Read my previous blog to learn about other advantages AdoptOpenJDK provided.

 

Memory usage results

This is my little test results. The figure from Quarkus website. All contents orange are my content OpenJ9 added.

 

 

 

I run the same service, the service uses OpenJ9 and HotSpot access the database. I scratch deployed two versions of the service, and their REST API by calling them a warm-up. After that, I called "docker stats | grep article effective." Hot displayed 149.8MiB, OpenJ9 displayed 59.77MiB.

How to test

I used the example application, which is part of the cloud-native-starter project. Micro service providers REST API, the API to perform CRUD operations on PostgreSQL database.

To use the service in Minikube micro OpenJ9 run in, please call the following command.

1

$ 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 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 with the contents Dockerfile.Hotspot Dockerfile and run in the same command.

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" ]

Thanks for reading!

Guess you like

Origin www.cnblogs.com/youruike-/p/12509746.html
JVM
JVM