Quarkus: Application Modernization Using Helloworld from JBoss EAP Quickstart (continued)

Hello everyone - this is the fifth post from our series about Quarkus! (By the way, watch our webinar "This is Quarkus - Kubernetes native Java framework". We will show you how to start from scratch or transfer ready-made solutions)

Quarkus: Application Modernization Using Helloworld from JBoss EAP Quickstart (continued)

Π’ previous post we looked at modernizing Java applications using technologies supported by Quarkus (CDI and Servlet 3) using the example of the helloworld program from the repository Red Hat JBoss Enterprise Application Platform (JBoss EAP) Quickstart. Today we will continue the topic of modernization and discuss the issue of memory consumption.

Performance measurement is the foundation of almost any upgrade, and memory usage reporting is an important part of the performance analysis process. Today, we'll look at relevant measurement tools that can be used to quantify the improvements resulting from modernizing Java applications.

For details on measuring memory usage, see the Quarkus guide titled Measuring Performanceβ€”How do we measure memory usage?

And below, we'll just show you how to compare memory usage data for three different types of applications (JBoss EAP, JAR package, and executable) by collecting this data on Linux using the pmap and ps utilities.

JBoss EAP

Launch an instance of the JBoss EAP application (see Deploying helloworld in previous post) and then look at its process PID (in our example it is 7268) with the following command:

$ pgrep -lf jboss
7268 java

Note. The -a option allows you to extract the full command line (ie: $ pgrep -af jboss).

Now we use PID 7268 in the ps and pmap commands.

Like this:

$ ps -o pid,rss,command -p 7268
PID RSS COMMAND 
7268 665348 java -D[Standalone] -server -verbose:gc -Xloggc:/home/mrizzi/Tools/jboss-eap-7.2.0/jboss-eap-7.2/standalone/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferI

And so:

$ pmap -x 7268
7268:   java -D[Standalone] -server -verbose:gc -Xloggc:/home/mrizzi/Tools/jboss-eap-7.2.0/jboss-eap-7.2/standalone/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=/home/mrizzi/Tools/jboss-eap-7.2.0/jboss-eap-7.2/standa
Address           Kbytes     RSS   Dirty Mode  Mapping
00000000ae800000 1348608  435704  435704 rw---   [ anon ]
0000000100d00000 1035264       0       0 -----   [ anon ]
000055e4d2c2f000       4       4       0 r---- java
000055e4d2c30000       4       4       0 r-x-- java
000055e4d2c31000       4       0       0 r---- java
000055e4d2c32000       4       4       4 r---- java
000055e4d2c33000       4       4       4 rw--- java
[...]
ffffffffff600000       4       0       0 r-x--   [ anon ]
---------------- ------- ------- -------
total kB         3263224  672772  643024

We look at the RSS value and see that JBoss EAP consumes approximately 650 MB of memory.

JAR package

Run the JAR application (see "Running helloworld packaged in a JAR" in previous post):

$ java -jar ./target/helloworld-<version>-runner.jar

Again we look at the PID using the pgrep command (this time we use the -a option described above):

$ pgrep -af helloworld
6408 java -jar ./target/helloworld-<version>-runner.jar

Run ps and pmap to measure memory usage, but now for process 6408.

Like this:

$ ps -o pid,rss,command -p 6408
  PID   RSS COMMAND
 6408 125732 java -jar ./target/helloworld-quarkus-runner.jar

And so:

$ pmap -x 6408
6408:   java -jar ./target/helloworld-quarkus-runner.jar
Address           Kbytes     RSS   Dirty Mode  Mapping
00000005d3200000  337408       0       0 rw---   [ anon ]
00000005e7b80000 5046272       0       0 -----   [ anon ]
000000071bb80000  168448   57576   57576 rw---   [ anon ]
0000000726000000 2523136       0       0 -----   [ anon ]
00000007c0000000    2176    2088    2088 rw---   [ anon ]
00000007c0220000 1046400       0       0 -----   [ anon ]
00005645b85d6000       4       4       0 r---- java
00005645b85d7000       4       4       0 r-x-- java
00005645b85d8000       4       0       0 r---- java
00005645b85d9000       4       4       4 r---- java
00005645b85da000       4       4       4 rw--- java
[...]
ffffffffff600000       4       0       0 r-x--   [ anon ]
---------------- ------- ------- -------
total kB         12421844  133784  115692

We look at the RSS again and see that the JAR package consumes approximately 130 MB.

Executable

Run the native (see the "Run the helloworld native executable" section in previous post):

$ ./target/helloworld-<version>-runner

Again we look at its PID:

$ pgrep -af helloworld
6948 ./target/helloworld-<version>-runner

And then we use the resulting process ID (6948) in the ps and pmap commands.

Like this:

$ ps -o pid,rss,command -p 6948
  PID   RSS COMMAND
 6948 19084 ./target/helloworld-quarkus-runner
И Π²ΠΎΡ‚ Ρ‚Π°ΠΊ:
$ pmap -x 6948
6948:   ./target/helloworld-quarkus-runner
Address           Kbytes     RSS   Dirty Mode  Mapping
0000000000400000      12      12       0 r---- helloworld-quarkus-runner
0000000000403000   10736    8368       0 r-x-- helloworld-quarkus-runner
0000000000e7f000    7812    6144       0 r---- helloworld-quarkus-runner
0000000001620000    2024    1448     308 rw--- helloworld-quarkus-runner
000000000181a000       4       4       4 r---- helloworld-quarkus-runner
000000000181b000      16      16      12 rw--- helloworld-quarkus-runner
0000000001e10000    1740     156     156 rw---   [ anon ]
[...]
ffffffffff600000       4       0       0 r-x--   [ anon ]
---------------- ------- ------- -------
total kB         1456800   20592    2684

We watch RSS and see that the executable file takes up about 20 MB of memory.

Compare memory consumption

So, we got the following figures for memory usage:

  • JBoss EAP - 650 MB.
  • JAR package - 130 MB.
  • Executable file - 20 MB.

Obviously, the executable takes up much less memory.

Summing up 4 and 5 posts

In this post and the previous one, we've covered how to modernize Java applications using Quarkus-supported technologies (CDI and Servlet 3), as well as various ways to develop, build, and run such applications. We've shown you how to collect memory usage data to evaluate the improvements resulting from this upgrade. These articles help you understand how Quarkus works and what it's good for, whether it's the simplest helloworld program in our examples or the much more complex real-life applications.

We'll be back in two weeks with a final Quarkus post - see you soon!

In our final post, we'll show you how to combine AMQ Online and Quarkus to build a modern messaging system based on OpenShift using two new messaging technologies. Read on link.

Source: habr.com

Add a comment