Optimize your Spring app for the cloud
Improve performance and reduce overhead with open source technologies
Running your Spring app in the cloud is simple, and so it should be. But with a little effort, you can take advantage of functionality that will improve the way your application works with the cloud.
OpenLiberty offers tooling to help build your Spring Boot container in a way intended to reduce overhead, leading to space and time savings during iterative development, or at build time in your CI/CD pipeline. The key lies in Docker layers, changing the way the container is built to split the standard Spring “fat jar” into dependencies, and application code.
For more information on why this is a good thing, OpenLiberty has a blog post that summarizes the concepts involved, with an overview of why the standard “fat jar” can lead to increased overheads during development.
OpenLiberty also has a follow-up post, explaining how to use their “springBootUtlity” to address this issue using Docker multi-stage builds.
The Eclipse OpenJ9 JVM offers Spring applications significant benefits when deployed as part of a cloud native runtime. OpenJ9 comes with improvements to memory overhead and startup times, achieved through shared classes and an aggressive focus on memory footprint.
Spring’s own petclinic demo uses around 1/3 the memory when running on OpenJ9, compared to OpenJDK. With shared classes and dynamic AOT enabled, the application can start up around two seconds faster!
The great news is that the memory footprint benefits are enabled by default with OpenJ9; no configuration is required. The startup time benefits merely need a JVM option to be set, enabling the shared classes cache.
To find out more, check out “Hands-on with OpenJ9 benefits for Spring applications.”