How to Set Up Resource Requests and Limits for a Java Application?

0
15
Asked By TechieTurtle42 On

I'm looking for input on how to configure resource requests and limits for a Java application that behaves a bit unusually during startup. Specifically, this app can utilize up to 2 CPU cores when it starts, but then it generally runs at around 5% of a core. It does ramp up to about 15% of a core when it runs a nightly job. The memory settings are 3GB for the minimum and 4GB for the maximum. We have 16 cores and 128GB of memory available on the worker nodes. I'd love to hear how different roles, like platform engineers and application owners, would approach setting these parameters. Personally, I would go with a CPU request of about 100m and if necessary, set the limit around 3. For memory, I'd request 3GB and limit it to 5GB. What are your thoughts?

6 Answers

Answered By AppArchitect55 On

If the startup can handle some throttling, I’d recommend a 150m CPU request. If not, you might need to go up to a 2 CPU request which could be wasteful. For memory, around 4.5-5GB should work, paired with a similar limit to avoid unexpected OOM situations. Always check for overhead too!

K8sNinja -

We generally set limits just to avoid any runaway scenarios on our shared clusters. It's a smart safety net, though I'm not always a fan of it.

Answered By FollowTheTechTrail On

Just here to see how this plays out! Would love to hear how others are tackling this issue.

CuriousCoder12 -

What about you? How would you set those resource limits?

Answered By RobustRack42 On

If you’re using AKS, you might want to look into the new JAZ feature, which allows you not to set requests and limits for Java apps. I haven’t tested it yet, but it sounds promising for automating these settings!

Answered By JavaJunkie99 On

What are the two CPU cores doing at startup? Maybe consider splitting that up into an init container with its own requests. But if that's not feasible, then brace for the spike during startup—it's frustrating dealing with Java container orchestration sometimes!

ResourceManagerPro -

That’s an interesting idea, but note that the scheduling considers the init container requests too. So, it won't make a huge difference.

Answered By CloudyCoder88 On

I would actually skip the Xms and Xmx settings altogether and rely on MaxRAMPercentage for memory allocation. Start with something like 75% and 4GB to avoid OOM kills. Plus, consider the Java version because older versions can mismanage CPU resources. I typically set CPU requests at 100m without a limit unless there are noisy neighbor issues. Given those nightly jobs, you might need to up the request to 150m at times.

InsightSeeker01 -

Absolutely, and don’t forget to track performance metrics! If the app underperforms while you’re tuning these settings, you may not gain any benefits. It's all about finding the right balance.

CodeCraftersForum -

Good point! We ran into major issues when our Java version mismanaged memory during a K8s upgrade. It's essential to keep an eye on the compatibility with cgroups.

Answered By DataDynamo47 On

For CPU, I’d recommend a request of 150m and no limit since your application needs guaranteed resources. Set both request and limit for memory at 4GB to ensure it works smoothly during regular operation. This should be fine given the node's capabilities.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.