Warming Up Payara Micro Container Images in 5.201

Uncategorized

Payara Micro 5.201 adds two command line options that make preparation of container images easier, as well as enable class data sharing on HotSpot Java Virtual Machine.

We recently looked at utilizing class data sharing (CDS) with OpenJ9. Java virtual machines may store their internal representation of class data in a CDS archive, sparing time spent on finding and parsing class files. Since the Payara Micro Runtime consists of tens of thousands of classes, this brings tangible improvements to startup time.

Before the Payara Micro release 5.201, there were two drawbacks to utilizing CDS:

  1. The startup gains are only visible on second startup, which doesn’t play well with immutable containers; it was hard to do prepare the container during its build phase.
  2. While OpenJDK has application class data sharing feature, it only works with System classloader, which was not where most of Payara Micro classes resided.

We are happy to announce that these limitations don’t exist anymore with Payara Micro 5.201!

{{cta(‘0c1037e0-adaf-4401-b888-05088602db6a’)}}

In this article we’ll explain the new features that enable it and show how to prepare pre-warmed Docker image that utilizes Class Data Sharing with OpenJDK 11.

Runtime Root Directory Launcher

When you start Payara Micro you are usually greeted with this first log message:

Payara Micro Runtime directory is located at .../payaramicro-rt....tmp

The bootstrap process extracts all of the configuration files as well as runtime libraries into this directory and then passes control to actual server implementation. It is possible to specify persistent location for this runtime directory by specifying command line argument --rootdir, however this dynamic nature of bootstrap doesn’t change in this case.

Payara Micro 5.201 adds new execution mode with flat classpath launcher bound to specific runtime directory. To create such launcher, execute:

java -jar payara-micro.jar --rootdir micro-root --outputlauncher

This will extract runtime directory into directory micro-root and add two extra files in there: launch-micro.jar and .env. To launch Payara Micro you can now use

java -jar micro-root/launch-micro.jar

The jar file has all of the runtime libraries directly on its classpath and therefore all runtime classes are eligible for CDS optimization on OpenJDK. The extraction step of runtime libraries is also skipped in this case, so neither special option noTimestampChecks is needed when running on OpenJ9. Resulting root directory is self sufficient, and you will not need payara-micro.jar for running the instance.

You can pass any arguments to launch-micro.jar just as you would to payara-micro.jar, with two exceptions:

  • --rootdir argument is ignored. The launcher assumes it resides in a root directory and will use its location as one.
  • Argument --addlibs to extend runtime classpath is not supported. You can however pass it to --outputlauncher and the libraries will be added to classpath of the launcher statically.

In case you cannot use -jar to run the launcher, file .env contains classpath, main class as well as additional arguments to use to launch micro with other command line options to java.

Warmup Mode

The second ingredient to preparing your runtime image is an ability to configure your runtime directory in a script. To enable that we added a very simple command line switch --warmup. It will cause the instance to shutdown as soon as it finishes its startup, which includes executing pre-boot and post-boot scripts, deployment of all applications and executing post-deploy scripts.

This can be used for variety of use cases, like

  • Preparing resources like database connection pools separately from deployment, simplifying number of command line arguments necessary for productive run
  • Preparing Docker image with applications already deployed into runtime directory
  • Collecting class loading information for preparing class data sharing archive

Preparing warmed-up Docker image

So let’s combine these two features to get our optimized Docker image. Let’s assume you’ve got payara-micro.jar handy (with Payara version >= 5.201), and your application is app.war. This is the what the Docker file would look like:

 

CDS Speeds Up Deployment About 40%

In our measurements, CDS speeds up deployment by approximately 40%. Its only drawback is that the CDS archive is quite big, 160 to 180 megabytes. We believe that it is a reasonable price to pay for startup improvement.

Also, when you run multiple containers based on the same image or on same layer with CDS archive, only a single copy of that archive resides in the memory and is shared across all of the containers, sparing memory usage of your host.

{{cta(‘0c1037e0-adaf-4401-b888-05088602db6a’)}}

Take a look at “What’s New in Payara Platform 201” for more info about the latest release.

Comments (2)

Post a comment

Your email address will not be published. Required fields are marked *

Payara needs the contact information you provide to us to contact you about our products and services. You may unsubscribe from these communications at any time. For information on how to unsubscribe, as well as our privacy practices and commitment to protecting your privacy, please review our Legal & Privacy Policy.

  1. Martin Bauer

    Hi,
    the first link (utilizing class data sharing (CDS) with OpenJ9) does not work.

    What is the correct Docker build file with openj9?

    Thanks

  2. Patrik Duditš

    Hello Martin,

    The link was fixed.

    We don’t provide a specific image based on openj9. Since utilizing class data sharing pays off only when image is warmed up with specific application, the easiest approach would be to adapt the Dockerfile provided in the article with different FROM clause, using -Xshareclasses:name=payara-micro in step 3, and removing step 4.

Related Posts

4 minutes
Uncategorized

Leading the Way: Payara Platform Community 7 Beta Now Fully Jakarta EE 11 Certified

We’re excited to announce that Payara Platform Community 7 Beta application server is now fully certified as Jakarta EE 11 […]

New Releases 5 minutes
News

What’s New In The Payara Platform September 2025 Release?

The September 2025 release marks a significant milestone with Payara 7.2025.1.Beta1 advancing Jakarta EE 11 readiness, alongside focused improvements […]

Blue background with coral and fish. Left text: 'MONTHLY CATCH'. Right: laptop screen with tech tabs and Payara Community logo. 4 minutes
Community

The Payara Monthly Catch – August 2025

Welcome aboard the August 2025 issue of The Payara Monthly Catch! With summer in full swing, things may have felt […]