Tech Talk: Quarkus – a new Java Technology Stack

In the latest Tech Talk our Faktor Zehn colleague Tri presented his experience with the Java framework Quarkus. This was evaluated with regard to the integration of Linkki and Vaadin for a customer project. In the following blog article you will get an insight into the Tech Talk and find a link to the GitLab repository of the Java code.

 

Quarkus: a new Java technology stack

Quarkus is a fairly young framework (release 1.0.0 was just released in November 2019) to develop modern Java applications. The developers and developers of Quarkus want to stand out from the competition – first and foremost Spring Boot – with 3 aspects:

1) Productive application development

BEST OF BREED LIBRARIES AND STANDARDS

„Quarkus provides a cohesive, fun to use, full-stack framework by leveraging a growing list of hundreds of best-of-breed libraries that you love and use.”

 

(Image-/quote source: https://quarkus.io)

 

 

As the quote states, Quarkus builds on or integrates very many other well-known Java frameworks and libraries to enable productive and rapid application development. To give a few examples:

  • For REST, Quarkus uses
    • JAX-RS as specification standard for interface description
    • RESTEasy as implementation
    • A separate Quarkus sub-project QSON for JSON serialization (other libraries like Jackson were not taken for performance reasons)
  • For Object-Relational-Mapping (ORM):
    • JPA as specification standard
    • Hibernate as implementation
  • For Dependency Injection:
    • Java CDI as standard
    • ArC as Quarkus own implementation

Many other frameworks/libraries are available for Quarkus. Generally such integrable technologies are designated as Quarkus Extensions. Even the competitor Spring is available as an extension, e.g. to use Spring annotations in Quarkus.

 

2) Kubernetes/Docker Container

Quarkus is designed with a Kubernetes/Container-first approach. On the one hand, it means that the Quarkus team itself provides extensions for

  • building Docker images
  • creating Kubernetes manifest files
  • enabling liveness/readiness endpoints
  • … and many other topics around Kubernetes

On the other hand, the Maven/Gradle build process of Quarkus is designed by default not to create a big uber-JAR (like Spring Boot) but to deliver the built application in an “exploded” folder structure. Maven example:

The JARs of 3rd party libraries are placed in separate folders to the JAR containing the application classes. When building the Docker image, this allows the different folders to be added as Docker Layers, where

  • lower layers should contain files that rarely change from build to build (typically 3rd party libraries included via dependency)
  • Higher layers contain files that change more often (the application classes being developed on).

Properly optimized Docker image layering will result in

  • Docker builds run faster because unchanged layers are reused from the cache
  • Docker pulls (e.g., when deploying to Kubernetes) run faster when cached layers are used

3) Native compilation through GraalVM.

One aspect of Quarkus that Spring does not currently offer is the ability to package Java applications as native executables. This is made possible by the GraalVM and appropriate C++ compilation tools for the desired target platform (usually Linux or Windows operating system). The packaged native executable contains the Java application, including libraries and a reduced virtual machine.

The question arises, for what a Java application should serve as Native Executable, if the past philosophy of Java was that built Java binaries can be run by the JVM on many platforms? The goal of Quarkus in this case is to have the Native Executable combined with a “distroless” image to enable very small, fast and efficient Docker Containers. “Distroless” are those Linux images that do not include unnecessary features (i.e. package manager, bash tools, JDK/JRE) to race the application.

Provided you are running Docker, the Quarkus team has even made native compilation very easy, without the need to install GraalVM or C++ tools yourself. The following Maven command runs as a Docker multi-stage build to automatically

  • Populate a Linux image with GraalVM and C++ Tools and build the application in it.
  • combine the built native executable with a distroless image

 

Vaadin & linkki integration to Quarkus

If you are interested, you can follow the individual commits in the following GitLab repository at the develop branch, how Vaadin 8 and linkki were integrated step by step into Quarkus. Interesting code passages have been explained in more detail with comments:

https://gitlab.faktorzehn.at/hpham/linkki-vaadin-quarkus/-/commits/develop

 

Your Faktor Zehn-Team

Leave a Comment

Your email address will not be published.

Solve : *
20 × 9 =