Traditionally, Java stacks were built for monolithic applications with long startup times and large memory requirements. Applications were run without being stopped for a long time. Cloud, containers, and Kubernetes did not exist to the same extent at that time, but now there are new requirements for Java frameworks. They must evolve to meet the needs of this new world. That’s where Quarkus comes in. Quarkus is an open source project licensed under the Apache License version 2.0.
This article will show you how to get hands-on experience with the Quarkus framework. You can run a workshop entirely out of a browser. You will also learn about other techniques and tools integrating with it.
Introduction to Quarkus
Quarkus, has a catchphrase, “supersonic, subatomic Java.” It is a Kubernetes-native Java stack tailored for OpenJDK Hotspot and GraalVM. It’s crafted from the best of breed Java libraries and standards. Quarkus was created to enable Java developers to create applications for a modern, cloud-native world.
The goal was to make Java the leading platform in Kubernetes and serverless environments while offering developers a framework to address a wider range of distributed application architectures. It’s built to provide high performance, low latency, and a small footprint to tackle the many new requirements of today’s business. Quarkus is also provides simple configuration, native executable generation, continuous testing, live reloading, dev services, and more. Quarkus achieves a better performance and smaller footprint than other traditional Java frameworks.
Normally when you manage your application, you start with packaging it, perhaps using Maven or Gradle. Then, many activities are done during runtime. Usually, Java frameworks do their bootstrapping during run time before actually starting the application’s business-oriented layer. During bootstrap, frameworks dynamically collect metadata by scanning the class path to find configurations, entity definitions, dependency injection binding, etc. to instantiate proper objects through reflection.
The main drawback of this is a delay in readiness of the application, though it also results in a peak of resource consumption at bootstrap as depicted in Figure 1.
Quarkus’ philosophy is to prevent, as much as possible, the slow and memory-intensive dynamic code execution by shifting these actions left and doing them during build time. Doing this costly work only once instead of at every startup results in faster, smaller, and more resource-efficient applications.
In addition to moving activities to build time, there are also other optimizations, such as minimizing runtime dependencies and maximizing dead code elimination. As a result, you get a longer build time but faster run time. You also have the choice of running it as native with GraalVM or on Java Virtual Machine (JVM), using the Red Hat build of OpenJDK.
Read more on Quarkus on the Quarkus.io page.
The Developer Sandbox basics
In this workshop, you will be able to get hands-on with Quarkus and try various components. You’ll also get to try out deploying and managing Quarkus applications in a Kubernetes environment. You will use Red Hat OpenShift as a target platform. You will use the Developer Sandbox and Red Hat OpenShift Dev Spaces to run workloads and work on the Quarkus applications.
The Developer Sandbox provides 30 days of no-cost access to a shared cluster on OpenShift, an enterprise-grade Kubernetes-based platform. You get instant access to your own minimal, preconfigured OpenShift environment for development and testing, hosted and managed by Red Hat. Figure 2 shows the Developer Sandbox product page.
OpenShift Dev Spaces is a cloud development environment (CDE) based on the Eclipse Che project. It gives you access to an integrated development environment (IDE) in the form of either JetBrains IntelliJ or Microsoft Visual Studio Code(VS Code open source), where you can work on applications and integrate with your environment through the terminal and console. The base for your work with the Quarkus applications is Dev Spaces and the OpenShift console. Dev Spaces provides a complete IDE and terminal for you to use. There will be no need to install anything on your workstation. Everything will be done through a browser. You can find more information in the workshop guide.
You will run the workshop in a self-paced mode, using your instance of the Developer Sandbox. You can run it when possible and pause to continue at a later time. The only restriction is the lifetime of the Developer Sandbox instance, which is 30 days. If your environment is decommissioned, you can provision a new instance and start up the workshop again from scratch(or if needed export your setup and import it to the newly provisioned instance).
To start a Developer Sandbox instance, you’ll need to create an account with Red Hat Developer (if you don’t have an account already). It is free of charge and gives you access to many useful resources, like e-books, events, and labs on the Red Hat Developer site. In this case, you will use the Developer Sandbox to run this workshop, but you can also use it to deploy other applications and try OpenShift as an application platform.
Read more about the Developer Sandbox and access your Developer Sandbox instance.
Access the workshop
This workshop guide is the starting point for this activity. You’ll follow a step-by-step flow through different tasks (Figure 3).
You can personalize the guide with the username of your Developer Sandbox instance. This enables you to run scripts and access links tuned to your Developer Sandbox instance. (Don’t worry, the guide explains how to do this.)
The guide also provides more information on how to start and access your cloud development IDE and Developer Sandbox environment.
Follow the guide and dive into the world of Quarkus!
Summary
This article introduced a hands-on workshop for Quarkus. The workshop can help you get familiar with Quarkus and its ecosystem as well as introduce you to deploying and managing applications on Kubernetes. The workshop can also be used, with some changes, on premise on your own OpenShift cluster.
This can be a starting point for learning and trying Quarkus. There are more resources, documentation, and guides available on the Quarkus.io site and on Red Hat Developer.
There is also a generator page attached to Quarkus.io where you can generate and download a skeleton configuration and files for Quarkus projects with necessary extensions.
Good luck with the workshop, and have fun!
Big thanks to Daniel Oh, James Falkner, Eric Deandrea and the Runtimes BU in general for all their work in creating the assets for this workshop.