Tech Corner - 13. May 2020

Have you met Quarkus?


Are you tired and annoyed of jokes about ‘How slow Java is”? Good news, I would like to introduce you to Quarkus. After more than 20 years of existence of monolithic Java application, the change was necessary. The modern world points to having everything in the Cloud, as microservices in containers and raising productivity with being as efficient as you can. The new ‘Supersonic subatomic Java’, as they used this main headline, comes in like a wrecking ball framework tailored mainly for GraalVM and Hotspot. But can be used in OpenJDK and run it like a common jar as well.

This ‘Container first’ approach has plenty of advantages. We can start with extremely fast boot time and once the startup time is measurable in milliseconds, it brings possibilities of up and down scaling of microservices in orchestration platforms like Kubernetes. Did I just mention Kubernetes? That’s because this framework was made to measure Kubernetes native Java stack. 

OK, that was a bit of theory around. And what about some tests? I am going to create a simple Java application based on Maven with dependency for REST and JPA.

Quarkus declares some measurements of memory usage and boot time of similar stack on the official web page.

Let’s have a look at our own example. Note: Unfortunately we cannot use in-memory databases to test our simple CRUD example. The reason is that for working with database drivers you need to add agroal extension to your application. Thanks to this extension you can configure an in-memory database in embedded-mode. But at the time of writing this blog there was no support for compilation of embedded databases into native images. We want to show you some measurements of native images as well, so we will use MySQL in this example.

After running our application with the following stack of REST & CRUD, but in JVM (Java(TM) SE Runtime Environment (build 13.0.1+9)) we got results like this.


You can clearly see the startup time of 2.132 seconds. Pretty impressive. Now let’s do the same but switch to GraalVM and build native image. 


So the same application run as native executable image has startup time only 0.072 seconds. The result is even better.

Now let’s have a look at memory consumption (RSS). As first we are going to check Quarkus application in JVM.


Memory load of this setup takes 298MB, so let’s switch back to GraalVM and native image.


Now it takes only 25MB. The difference between those 2 approaches is remarkable. Another win for native image.

Do you want to know how it is possible? What the heck is doing the Quarkus and GraalVM under the hood? Keep following our blog! 🙂

Our example was built with Maven, but Quarkus supports Gradle as well. The official web page gives you an opportunity to bootstrap your application with many extensions of different categories like REST, Security, Messaging, Database etc. 

So let's sum it up. Quarkus provides a new modern approach of developing Java applications. It puts effectiveness and productivity on the next level with container first approach and cloud native Java applications. It is somehow getting rid of Java runtime, because basically we don’t really need it once we have our application in a container as an image. It looks really fast compared to traditional stack and with a fraction of used memory. Also development of Quarkus applications is faster, once it brings super fast hot-reloads and we as developers can enjoy our code modifications in milliseconds. The only thing where we can spend more time as we are used to is waiting to build a native executable image using GraalVM. This can take a few minutes and it depends on your hardware. ;)

Getting ready for more details already? Stay tuned for the next blog!