Apache OpenWhisk Java actions on Eclipse OpenJ9 Runtime

Apache OpenWhisk is a serverless platform which supports different programming languages to write the application in terms of smaller functions/actions. Since the actions are expected to be executed on demand, the platform needs to bring up the corresponding language runtime fast enough that the action can be scheduled faster and gets executed.

Java is one of the supported programming languages to write actions in OpenWhisk. It is important that the Java runtime starts up faster and uses the resources like CPU, memory optimally to improve the performance of the platform.

So, it is important to understand the effect of the Java runtime’s performance and resource utilisation on the platform. Currently OpenJDK+Hotspot is the Java runtime available on OpenWhisk. In addition, I picked up the newly open-sourced Eclipse OpenJ9 JVM for performance comparison.


Java action — very simple Java action(QR generator)which generates QR code by making use of the ZXing library. 
Docker image — update the existing Dockerfile such that it uses the AdoptOpenJDK — Eclipse OpenJ9 with Class Sharing enabled docker image:

FROM adoptopenjdk/openjdk8-openj9:x86_64-ubuntu-jdk8u152-b16
RUN java -Xshareclasses:cacheDir=/javaSharedCache -version
ADD proxy /javaAction
RUN cd /javaAction; ./gradlew oneJar
RUN rm -rf /javaAction/src
CMD [“java”, “-Xshareclasses:cacheDir=/javaSharedCache,readonly”, “-jar”, “/javaAction/build/libs/javaAction-all.jar”]

Commands — starts the Java action’s HTTP server using Eclipse OpenJ9 or Hotspot and then listens for the incoming requests

  1. docker run -d -p 18080:8080 — name HotspotJavaRuntime whisk/java8action
  2. docker run -d -p 8080:8080 — name Openj9JavaRuntime whisk/java8action:openj9xsharexquick

Startup time

As per the OpenWhisk platform, the actions are cold started everytime if the actions are not exercised often. The action’s cold start involves

  1. Java runtime startup,
  2. the HTTP server startup and
  3. then execution of action

Measured the time taken for the first 2 stages of the cold start by capturing the time before launching Java Runtime and after HTTP server startup. As captured in the following graph, the server is able to come up faster everytime with Eclipse OpenJ9 with the approximation of ~25% of improvement in startup.


Memory usage of the container is observed at various stages of the execution through the docker stats command. As noted in the graph below, the memory usage of the container in both the cases is same just after the startup. But the memory usage of the Hotspot runtime starts to increase over the period. At the end of QR action completion, the Eclipse OpenJ9 memory usage is far lesser than the Hotspot at about 1/3.


From this current set of experiments, Eclipse OpenJ9 with Shared Class Cache is definitely helps the platform to bring up the actions faster with less memory.

  1. OpenWhisk actions over Eclipse OpenJ9 is~25% faster than actions over Hotspot runtime.
  2. Eclipse OpenJ9 runtime based actions use 3x smaller memory footprint compared to Hotpot runtime.

With further understanding of the platform, there might be more opportunities to improve the performance of the Java actions through JVM tunings(like Java Heap tuning, GC policy & etc).


Apache OpenWhisk — http://openwhisk.incubator.apache.org

Eclipse OpenJ9 — https://www.eclipse.org/openj9/

AdoptOpenJDK Docker Images — https://hub.docker.com/r/adoptopenjdk/openjdk8-openj9/