3 months ago
I have a small java 21 spring application.
I wrap it up in a docker container and deploy it here on railway.
In Dockerfile:
ENTRYPOINT ["java", "-XX:MaxRAMPercentage=75", "-XX:MinRAMPercentage=70", "-XX:InitialRAMPercentage=50","-jar","/app.jar"]
I set max ram as a percentage, and rather than allocating 75% of 4GB (current limit of my container) it allocates 75 of 320GB (what I assume is the host's available memory)
I also tried: -XX:+UseContainerSupport to no avail
Locally, if I run a container, it correctly stays within the bounds I set up for it.
I tried different images (temurin, zulu, correto) , but none seem to work once I deploy them in railway. It always sees 320GB available memory.
My last choice is to set hardcoded limits, but I'd rather avoid that. Any ideea how I can make the JVM aware of the container limits?
1 Replies
3 months ago
Hello,
Since Railway currently uses a container based system, your application will need to be cgroup aware in order to observe the set container limits.
If the Java JVM doesn't read limits from the cgroup then it will be observing the host resources instead.
You may need to set hard limits if that is the case.
Best,
Brody
Status changed to Awaiting User Response Railway • 3 months ago
a month ago
This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!
Status changed to Solved Railway • 28 days ago