Replies: 2 comments 6 replies
-
For the record, the position of the @paketo-buildpacks/java-maintainers is that the memory calculator provides a vital role in producing stable and safe containers. The JVM is getting better about running in containers, but even in 2024 it does not make any attempts to restrict its memory usage to keep within the memory limits put on your container. What this means is that the JVM will happily keep trying to allocate memory right until the OOM killer steps in and kills it. The memory calculator preallocates memory in a way that will produce a safe configuration, i.e. it will not go above the container limit, and that ensures your app will continue to run so long as you've provisioned your container memory limits correctly. There is a risk for the Java buildpack to allow users to disable this feature because it makes it very easy for users to create a configuration that will break. There was a time when the memory calculator didn't exist, way long ago and a period where it was not as thorough as it is now. I was involved in many long and arduous troubleshooting sessions during that time trying to help folks figure out why their apps were crashing. It was not fun. The memory calculator in its present state would have prevented much of that effort. If we make it easy for users to disable the memory calculator, we believe that we'll see an increase in similar problems because rather than work out a sustainable memory configuration, users will just disable the memory calculator (it's the easy short-term fix). Given this, I would be -1 on any sort of environment variable or quick configuration to disable the memory calculator. If we find that there is a default configuration that has not aged well or a way that the memory calculator's algorithm works which is counter-productive, then we can certainly do some investigations and with supporting evidence make changes to the memory calculator defaults. We can also look at adding different memory profiles/algorithms to the memory calculator. There is an RFC that's yet to be implemented to add a low-memory profile/algorithm to the calculator. This RFC is to enable the calculator to produce more useful memory configurations when the container memory limit is under 1G of RAM. We could enable other profiles/algorithms that key off of different things in your application, for example, if certain libraries are present then we'd increase the default direct memory. I'd also be OK with allowing folks to repackage their JVM vendor buildpack of choice without the memory calculator or perhaps in a mode that enables it to be disabled. We would not do this for the standard Paketo buildpack, but I'm not opposed to making it easier for folks to create their own variant of the buildpack that does enable this. Repackaging is extra work, but it is feasible for an advanced user like yourself to do this and disable the memory calculator. I'm not sure exactly how this would work and we don't have anything quite like that at present, but I'm confident that we could sort something out if this is a path that folks would like us to go down. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the thoughtful response and for all your help throughout my buildpacks adoption journey. At present our primary use-case for opting out of some or all java memory calculator settings is the removal of the I have considered repackaging the jvm vendor buildpack, but would prefer to avoid that because it creates the need to fork and maintain a code base and comes with its own set of responsibilities and challenges. It will eventually lead to drift as the paketo jvm buildpacks evolve and there are old forks out there. Have you considered de-coupling the memory calculator entirely into a separate buildpack and having it be part of the java build group order in the builder? At the end of the day, we want to use paketo buildpacks without duplicating the burden of maintaining code bases, cutting releases, patching vulnerabilities, etc. If users go down the path of repackaging paketo buildpacks, they will have less incentive to contribute back to upstream because they would be using a custom version that only they are benefiting from. Repackaging is not really a solution in my opinion (2 cents). Again, I appreciate the input and hope to find some common ground that can benefit me and potentially others in the future. The memory calculator is there to help the user, but I do think there should be a way for the user to customize things if needed. |
Beta Was this translation helpful? Give feedback.
-
One of the challenges of porting java apps built with Dockerfiles to buildpacks is that some developers expect or rely on the java defaults for some memory settings. At present the memory calculator will always be used if the java runtime is provided by any of the paketo buildpacks (bellsoft-liberica, azul-zulu). It is simple enough to override any of the settings through
JAVA_TOOL_OPTIONS
; however, it is not trivial to remove options altogether. While the memory calculator settings are indeed helpful in providing some guard rails when running apps, I have encountered a few situations where setting any value for a specific option,-XX:MaxDirectMemorySize
for example, would cause the app to crash.As an end user the only way for me to opt out of any of the java memory calculator defaults is to specify a custom container entrypoint that does not use the launcher to start the java app. This means I also have to set
PATH
andJAVA_HOME
, along with any other environment variables. Another way to potentially get around the issue is to have another custom exec.d script/executable that runs after the memory calculator and updatesJAVA_TOOL_OPTIONS
. Both of these solutions require in-depth knowledge of how buildpacks work and an understanding of the spec.None of the workarounds are ideal and I think it would be helpful to have some way for users to opt out of the memory calculator either in part or entirely when needed. I think having a disclaimer in a README or documentation will make it clear that a user assumes all responsibility and they should know what they are doing if they choose to go down this road.
Beta Was this translation helpful? Give feedback.
All reactions