GraalVM.org


Why GraalVM native image?

In short, using GraalVM native image to compile Java applications into native executables has the potential to save CPU and Memory resources and this can translate into saving $Money in cloud hosting costs.

GraalVM native image achieves this by ahead-of-time compiling the Java application into a native executable. This results in faster startup times and lower memory consumption compared to traditional JVM-based applications.

GraalVM vs JVM

The chart above compares the cpu and memory usage of a Java application that has been built using GraalVM native image versus running on a traditional JVM. As you can see, the GraalVM native image uses significantly less CPU and memory resources. This can lead to cost savings, especially when running applications in cloud environments where resource usage directly translates to costs.

The application above uses Helidon 4, Avaje libraries including avaje-nima, Postgres JDBC and Ebean ORM.

How do Avaje Libraries help?

Avaje libraries avoid using Reflection, Dynamic proxies and Classpath scanning so they are well suited to be used in GraalVM native image applications.

Avaje libraries also provide specific support for GraalVM native image where needed. For example, avaje-config specifies resource loading for application.properties and application.yaml etc.

avaje-config

avaje-config is a configuration library that supports GraalVM native image. It supports loading configuration from properties and yaml files as well as environment variables, system properties and plugins (like AWS AppConfig).

avaje-simple-logger

avaje-simple-logger is a simple structured JSON logger that is well suited to GraalVM native image applications.

avaje-http

avaje-http generates adapter code for @Controller and also HTTP clients. This code generation avoids the need for reflection and dynamic proxies, making it perfect for use with GraalVM native image.

avaje-jsonb

avaje-jsonb is a JSON binding library that uses code generation to create serializers and deserializers for Java objects. This approach avoids the need for reflection, making it ideal for GraalVM native image.

GraalVM Considerations

While GraalVM native image offers significant benefits, there are some considerations to keep in mind: