Hi all. In the last post on GraalVm we saw how polyglot functionality works when we are working with GraalVm. We saw how multiple languages can be tied together in a single application. Moreover, we saw how to pass variables and state from one programming language to another. You can visit the post here: https://blog.knoldus.com/going-polyglot-with-graalvm/. In this blog we will cover the other aspect of using GraalVm: lower Memory footprints and faster startup times. GraalVm uses the concept of native images to suppport a lower memory footprint and very fast startup time for an application. As a result, our focus here is to run a spring-boot application as a normal jar on the Jvm and as a native image on grall. We will capture and the metrics like boost in startup time and etc. so let’s begin.

Prerequisites

So here are some basics you should be aware of before we move ahead:

  • Basic knowledge of a spring boot web application, like how to create and run one.
  • Some basic understanding of GraalVm.
  • Setup of GraalVm done on your local, for that you can follow instructions here: https://blog.knoldus.com/going-polyglot-with-graalvm/
  • Familiarity with maven and Java programming language.

That’s all. Now, let’s analyze what are native images.

Native Image

I believe most of the developers have gone through the pain of longer waiting for their applications to start. Depending upon the size and complexity of your application the startup time can vary. As a result, sometimes applications take more than 30-40 seconds to start and running. Now think how much time it would take if you have to repeat the same process n number of times?  Yeah, I think you are now getting there. The pain is real. Sitting idle, watching your application load classes and jars everytime during startup is not something anyone would like. Can we reduce this startup time? Can we reduce the memory footprint of our application? Is there a way we can load necessary classes once and run app directly without reloading them on every fresh run?

#java #scala #tech blogs #flatjar #graalvm #native image

Running Spring boot application as Native Image
1.30 GEEK