While you are reading these lines, there are a few hundreds of Spring Boot applications struggling to load a JVM and start.
Yet others are up and running but consuming a huge amount of memory since a JVM needs to be underlying - supporting the application on top.
And adding this latency and resource consumption to a more Cloud Native world is just something that... It's NOT a match!
Some developers just abandoned the idea of using Spring Boot in a world conquered by containers. And they moved far to those battles with Golang. Others stayed with Java, but in another flavour, like Quarkus or Micronaut (i.e. GraalVM powered).
But in March 2021, something happened in the community of Spring Boot users, and that was the release of the beta program of Spring Native.
What it was slow and resource consuming π:
Why? Spring Boot applications can be now be compiled using GraalVM. I.e., it can be compiled to native code.
- Image size for an example project can go from ~170MB to ~60MB
- RAM memory consumption can go from ~172MB to ~30MB
- Start-up times can go from 2 seconds to 70 milliseconds
Seems awesome.
I've written a small example that you can take a look and comment on that π
π Bookend: Spring Native Starter app
- Example Spring Boot REST application using Spring Native
- Spring Boot, Java 11, Lombok
Provided a comparison between JVM image build and GraalVM image build.
Using Spring Native β³ 0.067 seconds
Using the JVM β³ 2.112 seconds
Get started
Create the image locally
./mvnw clean spring-boot:build-image
Running the just created local image
docker run --rm -p 8080:8080 bookend-native:0.0.1-SNAPSHOT
or just
docker-compose up
And if you are Spanish, I've explained all this in a more multimedia format:
Thanks for reading. I appreciate your comments β€οΈ.
Top comments (0)