r/programming • • Mar 11 '21

Announcing Spring Native Beta!

https://spring.io/blog/2021/03/11/announcing-spring-native-beta
48 Upvotes

9 comments sorted by

5

u/LicensedProfessional Mar 12 '21

Very excited to see where this goes—boring middleware developers, rejoice!

3

u/CartmansEvilTwin Mar 12 '21

I really ambivalent about this.

It sound pretty cool at first, but then you think about it and suddenly it's not as clear cut as it seems.

Native images are smaller, don't need a JVM, start faster and use less memory, that's cool. But you also lose a lot of flexibility, surprisingly native images are slower and building them takes forever.

So, who is this really relevant for? Regular, big iron application servers are booted once and then keep on running until the next release, so they don't care about startup time. Even regular microservices can absolutely tolerate a few seconds startup time.

The only real use case are serverless apps.

1

u/LicensedProfessional Mar 13 '21

Hmm, I really didn't expect them to be slower! TIL.

2

u/CartmansEvilTwin Mar 13 '21

The JIT can produce highly optimized code, because it knows, what's happening. The AOT compiler doesn't know that. So its code is slower.

I also expect the JVM overhead would be larger than its optimization benefits, but apparently that's not the case.

Small caveat: I tested using a simple server application, so a relatively small amount of code being executed thousands of time. This may or may not be applicable to whatever you're building.

1

u/Indie_Dev Mar 13 '21

Exactly, this is great for serverless. I plan to create a few microservices for personal use that will only have one user - me. Regular spring with a startup time of 5-10 seconds and ram usage of 300-500 mb will require me to purchase a VPS, which is overkill for something that's going to be used by a single user. With spring native I would be able to run them on AWS lambda for practically free.

1

u/LicensedProfessional Mar 13 '21

I'm curious—are your Java lambdas REST endpoints? I've written a couple of lambdas for work that weren't API endpoints and I just used vanilla Java for them—no framework startup times, just the normal lambda cold start penalty

1

u/Indie_Dev Mar 13 '21

are your Java lambdas REST endpoints?

I haven't completed them yet but plan to in the coming days, but yes, they are REST endpoints.

no framework startup times, just the normal lambda cold start penalty

Do you use spring or any other framework or just vanilla Java? Because frameworks like spring add a lot to the startup time.

1

u/LicensedProfessional Mar 13 '21

For my case the lambda just writes records to a data sink. I really try to avoid frameworks wherever possible

1

u/Indie_Dev Mar 14 '21

Yes, and I think that's why your startup time is not that bad.