micronaut-projects / micronaut-core

Micronaut Application Framework
http://micronaut.io
Apache License 2.0
6.09k stars 1.07k forks source link

Support Cloud Native Buildpacks via Paketo #6169

Open alvarosanchez opened 3 years ago

alvarosanchez commented 3 years ago

https://paketo.io/ https://buildpacks.io/

graemerocher commented 3 years ago

Thread on the topic https://twitter.com/andreasmanner/status/1438245716330225666?s=21

graemerocher commented 3 years ago

One for your queue @melix

nhandev552 commented 1 year ago

Hi @graemerocher, how about this enhancement? I cannot see this in micronaut-projects/micronaut-maven-plugin

alvarosanchez commented 1 year ago

It's obviously not done, this issue is still open.

It seems there hasn't been a huge interest from the community in having this

jjathman commented 1 year ago

I would be very interested in this and would be happy to help contribute this feature.

For background I recently discovered that after migrating from Spring Boot to Micronaut, our containerized applications were using a fraction of the container’s memory because of Paketo’s memory calculation was more intelligent about setting up sensible defaults for a cloud native application.

alvarosanchez commented 1 year ago

@jjathman what Java version are you using? Since JDK 10 (and JDK 8u191) the JVM will auto-detect the memory limits of the container. See https://bugs.openjdk.org/browse/JDK-8146115

jjathman commented 1 year ago

@alvarosanchez the JVM does detect the memory size correctly as you noted, it’s just very conservative about max heap size because there’s no way for it to know if you have anything else running in the container. But practically speaking the only thing running is the single app, so it should use basically all of the memory it gets from its container.

What I’d like to see is this behavior that we get from our Spring Boot applications: https://paketo.io/docs/reference/java-reference/#memory-calculator

alvarosanchez commented 1 year ago

I think this is a reasonable ask that perhaps could be implemented regardless of the Buildpack support.

jjathman commented 1 year ago

Agreed, definitely not necessary to use build packs to get a more reasonable set of memory defaults for a single application container scenario. The way I "solved" this for myself was by adding:

args.set(['-XX:MaxRAMPercentage=75', '-XX:InitialRAMPercentage=75'])

I think there could be even higher settings that are reasonable, but this was pretty good.