5 Tips for Optimizing Java Performance on Kubernetes

Transcript

Do your instances devour cloud resources or CPU time? Do containers restart frequently for unknown reasons? Are response times suboptimal? Is it challenging to meet service level agreement?

If the answer is yes to any of these questions, these five tips may help you boost the performance of your Java apps in the cloud!

Tip 1. Set CPU and RAM limits properly

Set CPU and RAM limits based on the results of load testing, stress testing, Native Memory tracking data, and other relevant metrics such as memory usage inside the pod. In addition, you should take Kubernetes overhead into account. For instance, AWS Fargate adds 256 MB to each Pod's memory reservation for the required Kubernetes components. 

Tip 2. Configure Kubernetes probes correctly

Probes are essential for monitoring the health of your pod. But improper prob configuration may lead to unnecessary container restarts, unrequired vertical scaling, or other issues. 

Tip 3. Choose a small base image

Choose a small base image to reduce container image size. For instance, Liberica Runtime Container can help you reduce RAM consumption by up to 30%.

Tip 4. Select the right Garbage collector

Select a Garbage Collector tailored to your needs. HotSpot JVM offers a selection of garbage collectors for various purposes, such as ParallelGC for high throughput or ZGC for low latency. 

Tip 5. Reduce application startup and warmup time

Reduce startup and warmup time of your applications. Java services may take dozens of minutes to reach stable peak performance. During that period, they process way fewer requests. You can alleviate the situation by using AppCDS, GraalVM Native Image, or Coordinated Restore at Checkpoint.

Summary

If your Java apps in the cloud struggle with high resource consumption, frequent container restarts, or slow response times, these five tips can help enhance their performance. First, set CPU and RAM limits properly based on load testing and account for Kubernetes overhead. Additionally, configure Kubernetes probes accurately, use a small base image to optimize container size, choose a suitable garbage collector, and reduce application startup and warmup time to ensure faster performance.

About Catherine

Java developer passionate about Spring Boot. Writer. Developer Advocate at BellSoft

Social Media

Videos
card image
Apr 1, 2025
SBOMs & Java Security: Stay Compliant, Stay Protected!

A software bill of materials or SBOM is crucial for the modern development environment full of regulations, vulnerabilities, and hidden threats. In this video, we discuss what SBOMs are and how they help dealing with compliance audits and application security. We will explore the best open-source tools for generating SBOMs and provide a tutorial on creating an SBOM for your project and analyzing it for vulnerabilities.

Videos
Apr 1, 2025
SBOMs & Java Security: Stay Compliant, Stay Protected!

A software bill of materials or SBOM is crucial for the modern development environment full of regulations, vulnerabilities, and hidden threats. In this video, we discuss what SBOMs are and how they help dealing with compliance audits and application security. We will explore the best open-source tools for generating SBOMs and provide a tutorial on creating an SBOM for your project and analyzing it for vulnerabilities.

Further watching

Videos
card image
Jun 23, 2025
How to install Liberica Native Image Kit on Windows PC

Liberica Native Image Kit is a multilingual GraalVM-based set of utilities for creating native images. This guide will help you to install it on Windows PC.

Videos
card image
Apr 25, 2025
Java in 2025: Busting the Biggest Myths

Think Java is slow, outdated, or only for old-school enterprise apps? Think again. In this episode of Java Myth Busters, we debunk six common myths about Java, including performance issues, security concerns, and the myth that Java is dead. Discover how the JVM, Spring Boot, GraalVM, and modern JDK updates make Java one of the most powerful, scalable, and relevant languages in 2025.

Videos
card image
Apr 16, 2025
Spring Boot Buildpacks: Optimize, Secure, and Shrink Your Containers!

Buildpacks let you containerize Spring Boot apps without writing Dockerfiles, but the default settings aren’t always optimal. In this video, I’ll show you how to fine-tune buildpacks for faster startup, smaller images, and better security—so you get the best performance with minimal effort.