Going Native with Eclipse MicroProfile and Quarkus

A primary value of Eclipse MicroProfile is the ability to write portable microservices that can run on multiple MicroProfile implementations. This offers developers a superb selection of runtimes to choose from and decide on one (or more) based on technical or business requirements. In case you haven't heard, there is a new MicroProfile implementation in town called Quarkus!

Quarkus is a MicroProfile implementation that focuses on efficiently running Java applications in containers in general and Kubernetes in particular. These environments are highly dynamic in nature. Microservice containers come and go to respond to changes in traffic and to address continuous deployment demands. Quickly starting microservices improve operational agility and efficient memory utilization matters when running microservices on Kubernetes nodes in order to minimize cost. Quarkus excels at both.

To put it in perspective, a traditional Java microservice starts in many seconds and utilizes 100's of megabytes of memory. A MicroProfile application compiled to a native binary with Quarkus starts in 10's of milliseconds and consumes only 10's of megabytes of memory. For example, a simple Java JAX-RS "hello world" application can start and respond to the first request in 14 milliseconds while consuming only 13MB of memory. Not just 13MB of Java heap, that's the *entire* application footprint resident in memory (RSS)! Quarkus opens up MicroProfile application development to a whole new set of use cases that were previously unattainable. When MicroProfile launched in 2016, who thought it could be used in serverless applications? It's Java, after all, right? With Quarkus, it can!

MicroProfile applications do not have to be compiled to native code to run more efficiently. Quarkus uses ahead-of-time (AOT) compilation to optimize the uber jar so that it starts very quickly and with less RAM than a traditional microservice running on the JVM. The following chart compares a microservice built with Quarkus running on the OpenJDK, running natively, and even compares it to a traditional Java microservice.

Getting started with Quarkus is easy with the Getting Started Guide, or choose from a large and growing selection of hands-on guides to learn how to use the broad set of Quarkus capabilities.

A handy cheat sheet is available that maps MicroProfile specifications to hands-on guides and maven dependencies. Gradle is supported too. Quarkus supports MicroProfile 2.2, the Reactive Streams Operators specification and even the draft Reactive Messaging specification. Keep in mind that Quarkus is still beta so there may still be some compatibility issues.

This super-quick 5-minute Introduction to Quarkus video is worth a watch. It shows application generation, the zero-config Live Reload feature, and culminates in running 100 JAX-RS microservice instances running on Kubernetes (OpenShift) on a laptop!

In conclusion, MicroProfile offers a lot of implementation options for developers to choose from. For those looking to deploy MicroProfile applications using containers or Kubernetes, then Quarkus is worth a look. Here's a hat tip to the GraalVM team which makes native compilation possible!

Resources:

About the Author

Andy McCright

John Clingan
Red Hat