4 ms·
I've always had some questions about graalvm so I'd like to hijack this thread, forgive the out of topic comment please! I've got a number is spring web applic
by spapas82 4y ago
I've always had some questions about graalvm so I'd like to hijack this thread, forgive the out of topic comment please!
I've got a number is spring web applications from which I create an uberjar (jar file with all dependencies) and run them in a Centos server using something like java -jar server.jar (it's a little more complex than this but you get the idea).
Would I be able to use graalvm to create native binaries from these jars? Is there some kind of tutorial describing the procedure?
Is this possible without a license/paying big money?
Finally, is this worth it? Will the apps become any faster?
- fesc 4y agoI think right now this Isn’t possible with “normal” Spring because Spring and various other libraries you’ll normally use make heavy use of reflection. Frameworks like Quarkus and Micronaut have been written with native in mind and I think Spring is also working on it (Spring Native).
- spapas82 4y agoThank you for the suggestions I'll take a peek at them!
- kaba0 4y agoYou would likely not be able to turn them to native binaries without a ton of work — spring uses reflection very heavily, so you would have to list every class that would get reflectively checked (including spring internals). There is spring native that will solve it for the most part, but I’m not sure how hard it is to change an existing spring web app to that. GraalVM has a community edition, which is free, I’m not sure about the license. And it is likely not worth it, performance will likely be worth, but memory usage and startup speed will decrease. It can be worth it for command line apps or some tiny microservice that is mostly idle.
- spapas82 4y agoThank you for the information! Doing some research myself I found some things about the license and integration with spring here: https://www.graalvm.org/faq/ https://www.graalvm.org/faq/ ; it seems that no license is needed for graalvm! I'll also take a peek on spring native it seems to be available in beta: https://github.com/spring-projects-experimental/spring-native https://github.com/spring-projects-experimental/spring-nativ...
- nomercy400 4y agoSpring Boot 3 is expected to support native/graal. There is a milestone release I think. There is a Graal Community Edition, which is free. Search for graal and spring pet clinic demo, you will likely find an article reducing startup time 100x (starting pet clinic in 15ms), and reducing memory 2-3x. I don't know about 'faster', but in my experience most spring applications are RAM bound, not CPU bound. So the native binaries can result in scaling back to smaller and cheaper cloud instances, or smaller VMs. Imagine halving your monthly cloud instance bill, if you are looking for 'worth it'. If you want to play with a framework where the native part works pretty okay, and still be able to use your dependent injection and dependencies, have a look at Quarkus. They even have some spring 'polyfills'.
- spapas82 4y agoStartup time is the major problem I have with spring, it can be ~ 1 minute in some apps. I'll definitely check Quarkus thank ypu!