Resource Topic: Java

  • The State of Java on Kubernetes 2026: Why Defaults are Killing Your Performance

    The State of Java on Kubernetes 2026: Why Defaults are Killing Your Performance

    Java is the backbone of enterprise software, and Kubernetes is the standard for deployment. You would assume that by 2026 these two technologies would work perfectly together out of the box. They do not. Most Java workloads on Kubernetes run with default JVM settings that quietly waste memory, throttle CPU, and slow requests.

    The data confirms Java’s dominance. According to the Azul State of Java Survey 2025, 68% of enterprises report that the majority of their applications run on the JVM. New Relic’s 2024 State of the Java Ecosystem found that adoption of container-friendly Java versions like Java 17 and 21 has surged by nearly 300%, proving that Java is being aggressively modernized for the cloud.

    Unfortunately, while adoption is high, performance and efficiency are low.

    In our recent webinar, Stefano Doni (CTO at Akamas) and Bruno Borges (Principal Program Manager at Microsoft and Java Champion) analyzed the state of the industry. After reviewing data from thousands of JVMs running in production environments globally, the verdict was clear: the majority of Java workloads on Kubernetes are running with “default” settings that are actively hurting performance and wasting money.

    Here is a look at what the data says, why “safe” defaults are dangerous in the cloud, and how you can fix it.

    How Are We Configuring JVMs?

    The premise of modern DevOps is automation and efficiency. However, the reality is that most organizations are “lifting and shifting” their Java applications into containers without adjusting the Java Virtual Machine (JVM) configuration.

    This isn’t a new problem, but it is getting worse. During the session, Bruno Borges referenced historical data from New Relic, highlighting that for years, over 65% of workloads lacked explicit Garbage Collection (GC) tuning.

    But that was about 5 years ago. How is the situation now? Stefano Doni then presented Akamas’s 2025 research, analyzing thousands of Java workloads being optimized in our platform. The data confirms that despite the maturity of Kubernetes and Java, these bad habits persist today.

    Chart: 60% of Java workloads on Kubernetes run with an unset garbage collector (Akamas 2025 data)

    According to our data:

    • 60% of JVMs have an unset Garbage Collector. The JVM then picks a default algorithm that may not match your container size or latency requirements.
    • The majority of Heap configurations are unset. Most developers rely on the JVM’s automatic memory management.
    • Most containers are too small. Many JVMs run with less than 1 CPU or less than 1 GiB of RAM. That is a major bottleneck for Java’s multi-threaded architecture.
    Chart: CPU core allocation distribution for Java pods on Kubernetes, many under one core
    Chart: JVM maximum heap size distribution on Kubernetes, most heaps left at conservative defaults

    Why is this happening? As Bruno Borges highlighted, many developers assume “the JVM will tune itself”. The JVM ergonomics are smart, but they were originally designed for large, shared physical servers, not for the constrained resources of isolated Kubernetes pods.

    Ergonomics is the process by which the Java Virtual Machine (JVM) and garbage collection tuning, such as behavior-based tuning, improve application performance. The JVM provides platform-dependent default selections for the garbage collector, heap size, and runtime compiler. These selections match the needs of different types of applications while requiring less command-line tuning. In addition, behavior-based tuning dynamically tunes the sizes of the heap to meet a specified behavior of the application.

    Oracle Java Documentation

    The reality is that default JVM heuristics are far from optimal. Their impact on your workloads is invisible but significant.

    Wasting Cloud Resources

    The most common mistake is leaving the Heap Size unset (no -Xmx or -XX:MaxRAMPercentage).

    Modern JVMs (Java 10+) are “container-aware”, meaning they attempt to self-configure based on the resources assigned to the container. However, this default behavior is incredibly conservative. For typical production containers (those allocated above 512MB of memory), the JVM uses only 25% of the container memory limit for the heap.

    Note: For very small containers (<256MB), the JVM acts differently, taking up to 50%, but most enterprise workloads fall into the larger category where the 25% rule applies.

    This default creates a paradox around resource efficiency. Imagine you configure a pod with 2GB of memory requests and limits. You are reserving 2GB of cluster capacity for that container. Because you relied on defaults, the JVM sees that limit but allocates only 512MB to your application’s heap. The remaining 1.5GB is technically available for non-heap memory, yet a typical microservice rarely needs 1.5GB of overhead. You are effectively leaving almost 75% of your memory on the table, paying for capacity your application is forbidden from touching.

    Beyond the waste, this configuration undermines performance and stability. Because the heap is restricted to a small fraction of available memory, your application fills it up much faster than necessary. That triggers frequent, aggressive Garbage Collection cycles to reclaim space, leading to CPU spikes and latency, even though the container has plenty of free memory.

    What happens when you leave your GC Unset?

    The Garbage Collector (GC) is the single most impactful factor on application latency and throughput. The research data shows that nearly 60% of Java workloads leave the Garbage Collector type unset. This forces the JVM to rely on its ergonomics to choose an algorithm for you.

    By default, modern Java versions prefer the G1GC collector, designed for high throughput and low latency. However, the JVM only enables G1GC if it detects at least 2 CPUs and 1791MB of RAM.

    Diagram: JVM ergonomics selects G1GC or SerialGC on Kubernetes based on CPU and memory thresholds

    If you deploy a microservice with a standard “cost-saving” configuration of 1 CPU or less, the JVM silently downgrades the Garbage Collector to SerialGC. Unlike G1GC, which runs concurrently, SerialGC performs memory cleanup using a single thread, freezing your application entirely for the duration of the collection.

    There is a second trap just above that threshold. When a container is just large enough to select G1GC (say, exactly two CPUs), you hit a technical paradox. G1GC spins up worker threads to clean memory in parallel. In such a constrained environment those threads crowd the very few cores available. Instead of streamlining the work, the CPU wastes cycles on constant context switching between your application logic and the swarm of background GC threads.

    This convenience of “automatic” selection is a double-edged sword. It often chooses a GC that is not optimal for your performance or footprint goals, and it does so silently. Because the JVM shifts its entire memory management strategy based on an apparently unrelated setting like the CPU limit, it can introduce performance penalties that are hard to diagnose. Relying on these defaults means ignoring the delicate balance between threads and cores. You are left at risk of a single-threaded bottleneck on one side and multi-threaded overhead on a small node on the other.

    The High Cost of “Micro-Containers”

    One of the most pervasive trends is the deployment of JVMs with less than 1 CPU. This looks efficient on a spreadsheet, and it is often chosen to reduce the “blast radius” by spreading instances. For Java it creates a fundamental architectural conflict, forcing a trade-off between cost and application stability.

    A Kubernetes CPU limit is not a “speed limit” that slows down the processor. It is a “time quota” enforced by the Linux kernel’s Completely Fair Scheduler (CFS). Typically the kernel divides time into 100ms windows. If you assign a container a limit of 500m (0.5 CPU), you are granting it 50ms of runtime every 100ms. Your JVM can still see all the CPUs of your Kubernetes node. Once that quota is exhausted, the kernel throttles the container: it freezes all threads until the next window begins.

    This mechanism is disastrous for Java because of its multi-threaded nature. The JVM is not just running your code. It constantly runs background threads for the Just-In-Time (JIT) compiler and the Garbage Collector.

    When your application starts or hits a new “hot” code path, the JIT compiler kicks in to transform bytecode into optimized machine code. This process is CPU-intensive. In a micro-container, a JIT burst can consume the entire 50ms quota in an instant. The Linux kernel then forcibly pauses your application for the remaining 50ms of the window. To your users this looks like latency, but it is actually an OS-enforced sleep where no code is executing.

    The sheer density of threads inside the JVM makes this worse. Even a simple application spawns dozens of threads: Garbage Collection threads, compiler threads, and your application threads. When you constrain a Java pod to less than 1 CPU, all these threads fight for those microscopic time slices. The background maintenance tasks, which are supposed to be invisible helpers, become active obstructors of your business logic.

    This contention damages performance regardless of which Garbage Collector you use. Modern concurrent collectors (like G1GC, ZGC, and Shenandoah) clean memory in the background using worker threads named ParallelGCThreads and ConcGCThreads. Tight CPU limits force the Kubernetes scheduler to throttle these threads, slowing user requests so the GC can proceed. When the inevitable “Stop-The-World” pause occurs, a phase required by all collectors, the lack of available CPU cycles means the cleanup takes significantly longer.

    This explains the findings from the benchmarks discussed by Bruno Borges. When comparing six small replicas (1 CPU each) against two larger replicas (3 CPUs each), the results revealed a clear performance gap. With the exact same total CPU capacity, the two larger replicas delivered significantly better throughput and lower tail latency. Giving the JVM “breathing room” reduces the probability of hitting these throttling walls. It also ensures background threads run on separate cores without freezing the request-processing threads.

    Benchmark chart: two larger Java replicas beat six small replicas on throughput and tail latency at equal CPU

    The Ecosystem Is Reacting

    The industry is aware of these challenges, and during the webinar Bruno Borges shared several initiatives aimed at mitigating them.

    Tools like the Azure Command Launcher for Java (“jaz”) automate the configuration of JVM flags based on the environment, effectively tuning the startup command for you. Projects within the OpenJDK ecosystem, such as Project Leyden and CRaC (Coordinated Restore at Checkpoint), are making strides to reduce startup times and memory footprint through static images and snapshotting.

    These advancements help developers start on the right foot. They do not eliminate the fundamental need to manage the performance and efficiency trade-offs of running Java in Kubernetes. Even with a perfectly tuned startup command or a faster boot time, once your application is running under load the tension between memory, CPU, and latency remains.

    Stop Guessing, Start Measuring

    The days of manual tuning are over. Even well-intentioned attempts to “fix” these issues by hand often backfire.

    Real efficiency requires balancing Throughput, Latency, and Footprint. Improving one often comes at the expense of the others.

    • Maximize Throughput? You may need a larger heap, increasing your Footprint.
    • Minimize Footprint? You risk squeezing the JVM and destroying your Latency.

    To solve this puzzle you cannot look at the JVM in isolation. You must align JVM configuration with Kubernetes container resources and HPA scaling policies at the same time. It is a trade-off between wasting money on over-provisioning and risking reliability with under-provisioning. It has to be done for every Java workload, continuously, as traffic changes and new releases reach production.

    You don’t need to solve this multi-variable equation manually. You can use Akamas Insights to run a comprehensive health check of your Java applications on your Kubernetes clusters. By connecting to your existing observability tool (like Prometheus, Datadog, and Dynatrace), Akamas Insights analyzes the full picture: JVM metrics, container limits, and actual usage. It tells you exactly where you are sacrificing reliability for cost, or the reverse.

    Stop flying blind: Get your free Application Health Score with Akamas Insights now.

    FAQs

    Which garbage collector does the JVM use by default on Kubernetes?

    It depends on the resources the JVM detects. With at least 2 CPUs and 1791MB of RAM, the JVM selects G1GC. Below that threshold it silently falls back to the single-threaded SerialGC.

    How much heap does the JVM allocate by default in a container?

    For containers above 512MB, a container-aware JVM (Java 10+) uses only 25% of the memory limit for the heap by default. Set -XX:MaxRAMPercentage or -Xmx to reclaim the rest.

    Why do Java pods with less than 1 CPU perform poorly?

    A Kubernetes CPU limit is a time quota enforced by the Linux CFS scheduler, not a speed limit. A 500m limit grants 50ms of runtime per 100ms window. JIT and GC threads exhaust that quota quickly, so the kernel throttles the pod and requests stall.

    What is CPU throttling in Kubernetes?

    Throttling is the kernel pausing a container once it spends its CFS time quota for the current window. The container waits, idle, until the next window. For Java this freezes application, JIT, and GC threads together.

    Are fewer large replicas better than many small ones for Java?

    Often yes. At equal total CPU, benchmarks showed two 3-CPU replicas beat six 1-CPU replicas on throughput and tail latency, because larger CPU limits reduce throttling and give background threads room to run.

  • Top 10 Kubernetes Performance Pitfalls (and how to avoid them)

    Top 10 Kubernetes Performance Pitfalls (and how to avoid them)

    If you are a cloud native company, you already know that Kubernetes is a solid choice for deploying and managing modern applications at scale. It’s flexible, powerful, and capable of handling complex workloads. However, there is also the potential for serious performance headaches.

    Many people think performance optimization is just about cutting costs or squeezing efficiency out of resources. That’s part of it, but not all of it. It’s also about delivering reliable services without over-provisioning. There is a fine line between balancing performance, reliability, and costs. Nobody wants a cheap Kubernetes environment if it’s always down (or slow). That only frustrates users. Nobody wants a robust Kubernetes environment that costs so much to run that it defeats the purpose.

    Kubernetes optimization is more than tuning the cluster (sorry, platform engineers). It’s a holistic effort that involves many layers, including the cluster, the workloads and application runtimes like the JVM running on it. Focusing on just one piece leaves significant optimization opportunities on the table. It’s a layered stack: the infrastructure (nodes, networking, storage), the control plane (scheduling, autoscaling), and the applications themselves. Each layer needs attention.

    In this article, we’re going to look at the top performance pitfalls that we see on a regular basis from customers in their Kubernetes journey. We’ll show you how to avoid these antipatterns and share practical tips to keep your deployments smooth.

    1. Settings CPU Limits Based on Theory Rather Than Experience

    By far, pod resource requests and limits are the biggest challenge K8s teams face. If you’re not familiar, we described how requests and limits work and their impact on costs and reliability in a previous post.

    One of the most debated aspects is CPU limits: is it best to set them for your workloads, or avoid them and just live with CPU requests? CPU limits can cause CPU throttling and significant application performance degradation, such as response-time slowdowns, even when CPU usage is low compared to the limit.

    But CPU limits can also be critical for cluster stability and application performance in shared or multi-tenant clusters. So, as a developer or operator of K8s apps aiming for reliability and efficiency, what should you do?

    To understand how CPU limits actually work, we ran performance tests under CPU-contention scenarios. We measured application performance when a misbehaving job, co-located on the same node, saturates the node CPUs. We tested two setups: CPU requests only (no limits), and both requests and limits set.

    The result? CPU requests alone do not protect latency-sensitive workloads from a noisy neighbor. In our tests, application p95 latency rose 3x. With CPU limits in place, the CPU-hungry job could no longer saturate the node, and the impact on application performance was contained.

    Why is that? This might sound counterintuitive, especially as many people expect CPU requests to prevent such situations. But there is nothing wrong here: that’s exactly how CPU resource management works on K8s (courtesy of Linux cgroups), and failing to understand it can have serious consequences for app performance and stability, as others have noted too. More details in an upcoming blog.

    2. Picking the Wrong Instance types for your Nodes

    Kubernetes provides built-in autoscalers at the cluster level, adding nodes when demand rises and removing them when traffic dies down. The Cluster Autoscaler (or Karpenter) watches resource requests from pending pods, spins up new nodes to accommodate them, then scales down during quiet periods to save costs.

    A common issue SREs and platform engineers face is failing to keep node-group configuration matched to workload resource requirements. Teams often configure node groups with standard cloud instance types and never revisit whether the CPU-to-memory (or GPU) ratio matches the workload shape.

    This can produce highly inefficient allocation at the cluster level, with significant CPU or memory (and cost) wasted. What often happens: the cluster autoscaler adds nodes for pending pods, but only one resource (say, memory) is exhausted while the other (say, CPU) sits idle and wasted.

    Let’s look at an example. In this cluster, the cluster autoscaler creates nodes due to a memory shortage (right chart). In doing so it provisioned roughly 5,000 CPUs that went unused, because the workloads never requested them (left chart).

    Notice that the cluster autoscaler works perfectly here. Nevertheless, a huge amount of resources and cost is wasted because of the poor instance-type configuration in the underlying node groups.

    Choosing node types and scaling your cluster is like picking the right rental car for a road trip. Too small, and everyone is cramped, with no room for luggage. Too big, and you burn far too much fuel, and every gas-station stop leaves your wallet in shock. Misjudge your node instance types, or fail to scale dynamically, and you’ll either hit bottlenecks or waste a lot of resources.

    3. JVM Misconfigurations for Java Applications

    Java applications on Kubernetes can be particularly tricky. The Java Virtual Machine (JVM) is a highly configurable engine with 500+ options that can be tuned for performance and resource efficiency. But JVM tuning requires deep expertise and is notoriously hard. Even a common task like determining the optimal heap memory size can be surprisingly complex for Java developers.

    Containers and Kubernetes add another layer of complexity: how should you configure the memory limit and heap size of your JVM? And what about CPU limits and garbage-collector type? For high-performance, reliable, efficient Java apps, JVM resource management must be aligned with Kubernetes pod resource settings. Despite the JVM’s container-aware heuristics, in practice the default configurations are wasteful, prone to reliability issues, or cause unnecessary slowdowns.

    Here’s a real example. In the chart below you can see an out-of-memory kill (OOMKill) that hit application availability. Seeing the steady rise in container memory usage, the SRE team blamed a memory leak in the application – time to fix your code, dear development team! But there was no memory leak. The real cause was a JVM misconfiguration: the pod memory limit did not account for total JVM memory demand, which includes both heap and off-heap memory.

    4. Poor application performance due to wrong JVM heap sizing

    In the previous pitfall we covered jointly optimizing pod resources and the application runtime to avoid reliability issues. But a wrong JVM configuration can hurt application performance too.

    Many developers assume the JVM performs best out of the box, especially with container-awareness features that let it size the heap automatically from pod memory limits. In reality – whether you set the heap explicitly (e.g. via -Xmx) or rely on container awareness (e.g. MaxRAMPercentage) – the resulting heap size may be well off and slow your application substantially.

    To show this, we ran benchmarks with the DaCapo Java suite, which mimics real-world Java workloads. We used the G1 garbage collector on Java 21 (eclipse-temurin) and measured Spring Boot latency across different JVM max-heap sizes. Here’s what we found:

    • If the heap is too small, performance suffers badly. A 20% latency impact is easy to hit, rising to 65% when the heap is too tight.
    • Beyond a certain size, more heap doesn’t help. Throwing gigabytes of memory at a Java app is not useful – the extra memory is basically wasted.

    As a Java developer looking to optimize your applications and microservices, don’t forget to size your JVM heap properly.

    5. Resource Management for Node.js Applications

    Node.js applications often hit performance and reliability issues on Kubernetes because of their unique (and, honestly, under-documented) runtime characteristics.

    Node.js runs on a managed runtime called V8, which resembles the JVM in many ways, including automatic memory management via garbage collection and a multi-threaded architecture (yes – the Node.js runtime is not single-threaded).

    A common problem is an out-of-memory kill (OOMKill). This mirrors pitfall #3 for the JVM: most teams misread OOMKills as a memory leak, when the real issue is how heap memory is sized relative to container memory limits.

    Less known is that Node.js performance and resource usage are also very sensitive to V8 garbage collection and heap settings. In an earlier blog we benchmarked a Node.js app across different V8 heap-pool sizes. Tuning the V8 heap memory pools cut application latency by nearly 50%, with no code changes. Similar gains showed up on CPU usage – which means savings on infrastructure footprint and cost.

    Check the blog for full details.

    6. Misconfigured HPA Autoscaling (Autoscaling Gone Wild)

    Kubernetes provides built-in application-level scaling via the Horizontal Pod Autoscaler (HPA), adding pods when demand rises and removing them when traffic dies down. HPA can be a lifesaver, but it’s not a set-and-forget solution.

    HPA needs careful tuning of scaling metrics, thresholds, and periods. Scaling behaviour is highly application- and traffic-dependent. Is your app’s startup time quick or slow? Do you need to react to sudden traffic peaks, or does traffic build slowly? Depending on your performance requirements or SLOs, HPA must be configured accordingly.

    Teams often don’t get HPA right, and we regularly see deployments that scale too slowly, too aggressively, or fail to scale down. A poorly tuned HPA will:

    • hurt end-user performance
    • cause unnecessary SLO breaches and production incidents
    • waste a lot of resources
    • push the cluster autoscaler to provision unnecessary nodes

    Look at this example. The team rightly adopted HPA for a deployment with fluctuating traffic, but set the scaling threshold far too low. As a result, HPA scaled the deployment far too much: overall HPA scaling efficiency (CPU used / CPU requested) was just 9%, wasting most of the requested CPU.

    The lesson: as with cluster-level autoscaling, simply adding HPA to your workloads may not meet the scalability and efficiency goals you’re after.

    7. VPA Missteps with Requests and Limits

    The Vertical Pod Autoscaler (VPA) is often the most recommended tool for setting pod resource requests and limits. VPA automatically sets container requests and limits based on observed usage.

    That sounds like exactly what’s needed, but the reality is different.VPA has a number of known limitations that many teams are not aware of, and can make it inapplicable in real-world production environments.

    There is one very important limitation not even mentioned in the docs. The VPA recommendation algorithm takes a purely infrastructure-only approach: it looks at resource usage and adjusts resources, with no awareness of the application running inside the pod.

    Why is that a problem? Modern apps run on a runtime that manages resources such as heap memory and CPU threads. Runtimes like the JVM or Node.js V8 adjust automatically based on pod resource limits. The VPA is unaware of how these runtimes behave, so applying its recommendations without care can create performance and reliability issues.

    Infrastructure-only approaches like the VPA can also slow your application down. In one customer test, the team applied VPA recommendations to a Java app and measured response time before and after. The change introduced significant slowdowns, making the app unresponsive to users.

    Why did that happen? Read this blog on why it’s crucial to consider the application runtimes inside containers and why infrastructure-level metrics aren’t enough. This holds for any tool or approach that looks only at container-level resource metrics – not just the VPA.

    8. Pod Sizing for Disaster Recovery (DR) and High Availability (HA)

    Poorly sized pods in disaster-recovery or high-availability scenarios can jeopardize cluster resilience. If pods aren’t configured to handle failover or spikes, you risk downtime or degraded performance during critical moments.

    This is a common challenge for SREs and development teams working out the best resource-allocation strategy. Teams typically size pods against currently observed load. For example, a pod requests 4 CPUs but uses just 1, so you downsize it to match the 1-CPU demand and save cost.

    The problem: this ignores reliability, high availability, and business-continuity requirements. Your applications may need to withstand the failure of one or more data centers and keep response times good during infrastructure disruptions.

    Properly sizing workloads for degraded scenarios means simulating the impact of 2x traffic on your workloads. And again, it’s not only about pod resources: your application runtime – like the JVM heap memory – must be considered too, to avoid unexpected bottlenecks at critical moments.

    9. Configuration Chaos and Drift

    Technical issues aren’t the only challenges teams face adopting Kubernetes. A more organizational or process issue we see, especially in mid-to-large organizations, is that developers push frequent changes to production, and these can introduce performance regressions or outright break things across the cluster.

    Part of the problem is that developers aren’t necessarily well-versed in the Kubernetes stack – and rightly so. As we showed in this blog, configuring apps and clusters for efficiency and performance is no small feat. Developers’ goal is usually to ship features quickly, not to become infrastructure experts.

    Meanwhile, SREs and platform engineers have to cope with the fallout. Poor configuration of even a single workload can impact other applications on the same node (as shown in pitfall #1 on CPU limits) or the entire cluster (for example, if a node crashes).

    Kubernetes is a great platform, but every user has to be a good citizen and use it wisely so everyone else can too. At scale, proper performance isolation and reliability practices are key – and in practice this doesn’t always happen. The only way to keep the platform stable, performant, and efficient is to adopt proper processes and tools that automate the optimization work as you scale.

    10. Organizational Knowledge Gaps and Prioritization Conflicts

    Kubernetes thrives on collaboration, but when priorities aren’t aligned between platform engineering and application teams, it creates a deadlock that affects both performance and reliability. When application teams lack Kubernetes expertise and prioritize feature speed over stability, big problems follow.

    It typically goes like this:

    • Platform engineers understand Kubernetes intricacies, but application teams may lack the training to optimize their deployments. This leads to misconfigured resources or ignored best practices.
    • Application teams focus on shipping features quickly, sidelining critical tasks like performance tuning, monitoring setup, or adopting Kubernetes-native practices.
    • Without good collaboration, platform teams may enforce overly restrictive policies while application teams deploy suboptimal workloads. The result is friction between teams and unreliable software.

    To fix this, invest in cross-team training to bridge the Kubernetes knowledge gap. Offer workshops or hands-on learning tailored to application teams. Establish clear service-level objectives (SLOs) that align platform and application priorities, balancing feature velocity with reliability goals.

    Tools to Save the Day

    Here are some tools and techniques to help you tune Kubernetes for better performance:

    • Observability: Use tools like Prometheus, OpenTelemetry, or commercial options like Dynatrace and Datadog to understand resource usage. Don’t stop at workload-level metrics – collect application-runtime metrics too, as they are critical for success, as shown throughout this post.
    • AI-powered tuning: Use tools that automate full-stack Kubernetes optimization to reduce the effort and skills required from engineering teams. Akamas autonomously optimizes the full-stack configuration of enterprise applications – from infrastructure to application layers – using reinforcement learning, live telemetry, and user-defined goals, both live in production and offline in testing.
    • Load testing: Simulate traffic with tools like Locust, JMeter, or commercial options like OpenText LoadRunner and Tricentis NeoLoad. Load testing is often the best way to find scalability bottlenecks and tune workload configurations like the JVM or HPA before you deploy to production.
    • Chaos engineering: Use tools like Chaos Toolkit, Chaos Mesh, or commercial options like Gremlin to test resilience against worst-case events. This helps confirm applications can sustain traffic in disaster-recovery scenarios.
    • Advanced Kubernetes features: Use capabilities like taints, tolerations, affinity rules, priority classes, resource quotas, and HPAs to build reliable, efficient clusters.

    Wrapping It Up

    Kubernetes is a great platform to scale your cloud applications on, and we love it – but performance and efficiency won’t come for free. You can build clusters that are fast, reliable, and cost-effective by avoiding these common pitfalls. The key is to stay proactive: monitor relentlessly, tune continuously, and build a performance-engineering culture where everyone cares about performance within their own scope.

    If you’re struggling with Kubernetes performance, we can help. Explore Akamas Insights to see how our AI-driven optimization platform tackles all of these challenges and cuts cost. We understand the problems companies face deploying Kubernetes at scale, and we can help you too.

    FAQs

    What causes poor performance in Kubernetes?

    Most Kubernetes performance problems come from small misconfigurations across three layers: infrastructure (node instance types), the control plane (HPA, VPA, cluster autoscaler), and the application runtime (JVM or Node.js/V8). Optimizing one layer while ignoring the others leaves gains on the table and can even create new bottlenecks.

    Do CPU limits help or hurt Kubernetes performance?

    Both, depending on context. CPU limits can cause throttling and slow a workload even when usage looks low. But in shared or multi-tenant clusters they protect latency-sensitive workloads from noisy neighbors. In Akamas contention tests, removing CPU limits let a misbehaving job push p95 latency 3x higher.

    Why do Java applications get OOMKilled on Kubernetes?

    Usually not because of a memory leak. The common cause is a pod memory limit that doesn’t account for total JVM memory demand, which includes both heap and off-heap memory. When off-heap usage is ignored, container memory grows past the limit and Kubernetes issues an OOMKill.

    Does the Vertical Pod Autoscaler (VPA) improve application performance?

    Not reliably. The VPA sets requests and limits from observed infrastructure usage alone, with no awareness of the runtime inside the pod. Because runtimes like the JVM and V8 react to pod limits, applying VPA recommendations blindly can slow an application down, as seen in a customer test on a Java app.

    How do you optimize Kubernetes performance across the full stack?

    Tune pods, application runtimes, and nodes together instead of in isolation. Align JVM or V8 settings with pod resource limits, size node instances to workload shape, and validate autoscaling under realistic traffic. Automating this full-stack tuning – for example with Akamas – reduces manual effort and keeps configurations optimal as workloads change.

  • Application Performance Optimization on Kubernetes: More Than Just Pods

    Application Performance Optimization on Kubernetes: More Than Just Pods

    In 2025, Kubernetes dominates the cloud container landscape. It is the “operating system of the cloud.” Yet many organizations are discovering how expensive it is to run and scale. OOM kills anyone?

    Application performance optimization on Kubernetes usually stops at pod requests and limits. That misses the layer where most waste and most reliability risk actually live: the application runtime. Tuning the JVM, Node.js V8, .NET CLR, or Go runtime alongside pod and node settings is what turns Kubernetes cost and reliability around.

    Overprovisioning to avoid an outage costs companies far more than they budgeted when they first migrated to containers. Many teams right-size pods and tune cluster resources to fix it. Most still miss the fundamental layer that holds the key to poor reliability and overspending: the language runtime of the application itself. As a result, they leave money on the table and suffer avoidable reliability incidents.

    Modern applications do not run directly on Kubernetes. They execute on language runtimes like the Java Virtual Machine, the Node.js V8 engine, the .NET CLR, or the Go runtime. None of these is “tuned” out of the gate. Each exposes an intimidating number of options for memory allocation, garbage collection, thread management, and compilation. Each setting can make a large difference in performance and resource use. This area gets ignored because the platform teams that deploy the applications focus on Kubernetes, not on the applications themselves.

    Chart showing Java 21 exposes 537 JVM configuration options for memory, GC, threads, and compilation
    Java 21 has an outstanding 537 configuration options. How many are you actually setting?

    The Hidden Costs of Pod-Only Kubernetes Optimization

    The main approach SREs and platform teams use today is tuning pod requests and limits. That instinct is right, because applications are where most of the waste comes from. The execution is misguided. It looks only at Kubernetes metrics like pod-level CPU and memory. What happens inside the application is treated as someone else’s problem.

    Tuning at that level is genuinely hard. The right configuration is specific per application and demands a granular view. Focusing on infrastructure alone produces three problems we see as a pattern at Akamas.

    Memory Misconfiguration Leads to Cascading Failures

    Consider a typical Java application in a Kubernetes pod. Infrastructure monitoring shows the pod steadily uses 2GB, so a tool recommends cutting the limit from 4GB to 2.5GB for savings. That recommendation ignores the JVM heap configuration, which may be set to use up to 3GB based on the original 4GB limit.

    The result? A slight traffic increase pushes the JVM to use all the allocated heap, and Kubernetes kills the pod. These reliability problems are invisible in infrastructure metrics until it is too late.

    Diagram of a Kubernetes pod getting OOMKilled when the JVM heap exceeds a reduced pod memory limit

    Auto-Configuration Creates Performance Cliffs

    Java’s runtime reacts to your pod resources. Reduce a pod’s allocation and the runtime adjusts its own parameters. The JVM shrinks the heap, changes garbage collection behavior, and modifies thread pool sizes.

    These automatic adjustments often create problems. A slightly smaller memory limit can shrink the JVM heap. That triggers far more frequent garbage collection, which burns CPU and raises latency. The Node.js V8 engine behaves the same way. Memory pressure there can cause dramatic swings in resource use and execution performance.

    Diagram showing a smaller pod memory limit forcing a smaller JVM heap and more frequent garbage collection

    Efficiency Gains Require Runtime Tuning

    Right-sizing infrastructure removes some waste. It does not make the application more efficient. True efficiency comes from optimizing how the runtime uses resources. Developers routinely set Java heap far higher than the application needs. Properly sizing the heap can cut the memory footprint in half, with the same performance. Different garbage collection algorithms in the JVM can vary CPU usage by 30% for identical workloads. The default V8 settings are tuned for browsers, not for the high-throughput server workloads that Node.js runs.

    Tune the runtime parameters and you often get the same performance with far fewer resources. You can also get more performance from the same allocation. Sometimes the result shows up as a welcome drop on the monthly cloud invoice. This level of optimization is impossible without understanding the application layer.

    Chart showing lower monthly cloud cost after tuning application runtime memory and garbage collection

    How Runtime Config Breaks Kubernetes Autoscaling

    Optimization gets harder once Kubernetes autoscaling enters the picture. Horizontal Pod Autoscaling acts on the metrics and thresholds you define. If the runtime is poorly configured and out of step with pod requests and limits, these systems scale wrong. You get an excessive pod count that triggers unnecessary cluster scale-out, or under-provisioning that degrades performance.

    Diagram of Kubernetes HPA and cluster autoscaler scaling incorrectly because of a misconfigured application runtime
    There’s more to Kubernetes scaling than meets the eye.

    Node selection is another challenge. Should the workload run on compute-optimized instances with a high CPU-to-memory ratio, or memory-optimized instances with more RAM per core? The answer depends on the workload’s resource shape, which is driven mainly by the runtime configuration. Kubernetes cluster autoscalers can match provisioned resources to requests. Turning one on is not enough on its own. Your node group configuration is what makes node shapes match your workloads.

    Multiply these decisions across hundreds of microservices, each with different runtime needs and resource patterns. Manual optimization is not practical at that scale. When automated tools ignore the application layer, that blind spot guarantees overspending and reliability incidents.

    Beyond Infrastructure Metrics: Application-Aware Optimization

    Application performance optimization requires analyzing application metrics alongside infrastructure utilization. That means response times, throughput, error rates, garbage collection frequency, and more. You need the application-layer context that infrastructure metrics alone cannot give you.

    This is why application-aware optimization is essential to any sound Kubernetes optimization strategy. It also enables real collaboration between platform engineering, SREs, and developers, which produces more efficient and more reliable applications.

    An optimization tool that sees both layers at once shows you what you have been missing. A pod can show low CPU at the infrastructure level while suffering high garbage collection overhead that consumes CPU cycles inefficiently. A traditional tool recommends cutting CPU. An application-aware tool fixes the garbage collection stress instead.

    The payoff is that you improve cost efficiency and application performance together. You stop choosing between saving money and holding performance. You get both.

    The Path Forward: Full-Stack Performance and Cost Gains

    Organizations that use Akamas consistently report significant improvements, sometimes dramatic ones. In Akamas customer engagements, cost reductions of 20-50% are common when application tuning is combined with infrastructure optimization. Misconfigurations that cause reliability issues get identified and fixed fast. Performance gains often exceed the cost savings, with response-time reductions of 30% that are not uncommon. Akamas often pays for itself in the early stages of tuning.

    Instead of fighting resource constraints and performance issues, teams can proactively tune their specific Kubernetes environment for their own applications. Teams that adopt application-aware optimization end up with more efficient, more reliable, and more cost-effective Kubernetes deployments.

    Ready to see how much performance and cost your Kubernetes applications are leaving on the table? Learn more about full-stack optimization for your organization.

    FAQs

    What is application performance optimization on Kubernetes?

    It is tuning the application runtime, the pod settings, and the cloud nodes together, not in isolation. Most teams tune only pods. This approach also tunes the JVM, V8, or .NET CLR the application runs on, which is where much of the waste and reliability risk lives.

    Why is pod rightsizing not enough to reduce Kubernetes cost?

    Pod rightsizing looks at pod-level CPU and memory, not at what happens inside the runtime. A pod can look efficient while the JVM wastes CPU on garbage collection. Rightsizing alone can also shrink the heap and trigger OOM kills. Runtime tuning is what removes the underlying waste.

    What happens to the JVM when you lower a pod’s memory limit?

    The JVM reacts to the resources it sees. A smaller limit shrinks the heap, which can trigger far more frequent garbage collection, higher CPU use, and increased latency. Below a threshold, the pod gets OOMKilled. This is why heap settings must be tuned together with pod limits.

    How much can runtime tuning reduce Kubernetes cost?

    In Akamas customer engagements, combining application tuning with infrastructure optimization commonly cuts cost 20-50%. Properly sizing the JVM heap alone can halve the memory footprint at equal performance, and choosing the right garbage collector can shift CPU usage by around 30% for the same workload.

    Which application runtimes can be optimized this way?

    The same approach applies to the Java Virtual Machine, the Node.js V8 engine, the .NET CLR, and the Go runtime. Each exposes many options for memory, garbage collection, threading, and compilation. Java 21 alone has 537 configuration options.

  • Beware of Kubernetes autoscaling if you want reliable, cost-efficient services

    Beware of Kubernetes autoscaling if you want reliable, cost-efficient services

    Autoscaling is sold as the button that keeps Kubernetes efficient on its own. Be careful before you trust it.

    Kubernetes autoscalers scale on resource usage alone. They do not look at application signals such as response time. So a change that looks efficient on a CPU chart can quietly break your latency SLO and, at the same time, raise your cloud bill. In one real case, a Java microservice on Azure, tuning the Kubernetes requests, limits and JVM settings together cut cloud cost by 49% while keeping response time inside its SLO. This article shows how that happens and what to do about it.

    Many teams running on the cloud pay far more than they expected. Over-provisioning is the usual culprit: it is the safe reflex when release cycles are short and there is no time for proper sizing. Moving from on-premise to cloud makes it easy to ignore, because a bigger bill looks like an acceptable price for agility. Sooner or later, though, those bills start to limit how cost-effectively you can deliver services.

    Kubernetes resource management adds to the difficulty. Tuning a single microservice by hand often takes weeks, even for experienced SREs and performance engineers. This was exactly the situation at a European leader in SaaS accounting, payroll and business-management services. Their teams were shipping frequent updates for new features and regulations, and cost efficiency had slipped down the priority list.

    We use that real case below to show the challenges of tuning Kubernetes Java microservices, especially when autoscaling policies are in place. The same effects apply to any language runtime. We then show how AI-powered optimization finds the best tradeoff between performance, resilience and cost automatically.

    Kubernetes autoscaling: a word of caution

    Sizing containers and properly setting resource requests and resource limits is very important to ensure performance and resilience (here is why). Kubernetes offers built-in autoscaling to automate this. The Vertical Pod Autoscaler (VPA), for example, recommends CPU and memory requests from measured pod usage.

    Here is the catch. Kubernetes autoscalers, VPA included, act on resource usage only. They do not consider application-level metrics such as response time. That gap can hit the performance and resilience of your workloads hard.

    Vertical Pod Autoscaler cutting CPU requests until service latency breaches its SLO
    Figure 1: Vertical Pod Autoscaling in action

    The chart above shows a microservice serving a typical diurnal traffic pattern: low load, then high load, then low again. The top-left panel plots latency against the defined SLO. The lower panels show resource requests and the matching utilization for CPU and memory.

    The service first ran under default requests. Then VPA was switched on. VPA saw CPU utilization below 50%, judged the service over-provisioned, and cut CPU requests in half. Under the new settings, latency spiked and the service breached its response-time SLO.

    The lesson is direct. You have to evaluate the effect of any recommended setting on the service itself, because a change that looks efficient can degrade performance or reliability. This is what makes tuning Kubernetes microservices hard: requests, limits, autoscaling thresholds and runtime flags all interact, and they have to balance performance, resilience and cost against real SLOs.

    A real-world case: a Java microservice on Azure

    The customer’s first target was a Java microservice on Azure that provides the B2B authorization service behind all their digital products.

    Java B2B authorization microservice running on Azure Kubernetes, the optimization target
    Figure 2: Case studied

    The baseline configuration for the pod is shown below.

    Baseline Kubernetes pod and JVM settings: CPU and memory requests, limits and max heap
    Figure 3: Pod initial configuration (baseline)

    Both CPU and memory requests were set lower than the limits: 1.5 CPUs and 3.42 GB requested, against limits of 2 CPUs and 4.39 GB. Setting requests below limits is a common way to guarantee enough resources while leaving headroom for growth. At the runtime level, the JVM max heap was set higher than the memory request, so the JVM could use more memory than the pod asked for.

    The environment used KEDA autoscaling, with policies on both CPU and memory. The triggers were 70% CPU utilization and 90% memory utilization, measured against requests, not limits. So once CPU usage reaches 1 core (70% of 1.5 cores), KEDA adds a replica.

    We ran a load test reproducing the diurnal pattern with this baseline.

    Baseline configuration under load: response time spikes from CPU throttling during JVM startup
    Figure 4: Behavior of the baseline configuration under load

    Two problems showed up. Response time spiked because of high CPU usage and CPU throttling during JVM startup. That hurts performance and reliability at exactly the wrong moment.

    The second problem is more subtle. When load dropped, the replica count did not scale back down. Container memory usage stayed above the 90% threshold, so KEDA kept the extra replicas running. The cause here was the JVM max heap sitting above the memory request. In other cases the same effect can come simply from a new release changing the application’s memory footprint.

    This is the heart of the matter. Tuning Kubernetes applications for both reliability and cost efficiency is hard, because container requests and limits, autoscaling metrics and thresholds, and runtime flags interact in non-obvious ways. Get one of them wrong and you can pay for replicas you do not need while still missing your SLO.

    AI-powered optimization to minimize cost

    The first step in the AI-powered optimization process is to state the goal. Here the goal was to minimize the total cost of the service on Azure, which in Kubernetes depends on the allocated CPU and memory. We then set constraints to rule out any configuration that violated the SLOs: throughput, response time and error rate could not degrade by more than 10% against the baseline.

    Akamas optimization goal to minimize cloud cost under response-time and error-rate SLO constraints
    Figure 5: Optimization goal and constraints

    The study tuned nine parameters at once:

    • Four Kubernetes parameters: CPU and memory requests and limits, which drive performance, reliability and cost.
    • Five JVM parameters: including heap size and garbage collector type, which govern the behaviour of containerized Java.

    Tuning all nine together keeps the JVM aligned with the chosen container sizing. That is the difference from the manual approach, which tunes each layer on its own and misses the interactions.

    Akamas found the best cost configuration after a few dozen experiments, in about 19 hours. Against the baseline, it delivered a 49% improvement on cost and behaved better under load.

    Best configuration holds response time within SLO with no autoscaling triggered, versus the baseline
    Figure 6: Behavior of best vs baseline configuration

    Two differences stand out:

    • Response time in the best configuration stays within the SLO throughout, with no peaks.
    • Autoscaling never triggers, because a fixed replica count sustains the full load.

    So the best configuration improves cost and improves performance and resilience at the same time.

    Here is the side-by-side comparison.

    Side-by-side Kubernetes and JVM parameters for the best cost configuration versus the baseline
    Figure 7: Best vs baseline configurations
    ParameterBaselineBest (lowest-cost) configuration
    CPU requests / limits1.5 / 2 CPUsHigher than baseline
    Memory requests3.42 GB5 GB
    Memory limits4.39 GBHigher than baseline
    JVM max heapAbove memory request+20%, kept within memory request
    JVM min heapBelow max heapAlmost equal to max heap
    Autoscaling under loadTriggered, no scale-backNot triggered
    Cost vs baselineReference49% lower

    Two points are worth calling out. The best configuration sets memory and CPU requests and limits higher than the baseline, which feels counterintuitive, since Kubernetes is often seen as best for small, highly scalable pods. And the max heap, though raised by 20%, now sits within the container memory request, while min heap is almost equal to max heap. Keeping min and max heap close helps avoid garbage collection cycles during JVM startup.

    The pod is larger in both CPU and memory, so autoscalers fire less often, even though the fixed cost per pod is higher. The apparent paradox resolves once container and runtime parameters are aligned: with the JVM max heap below the memory request, the application scales down cleanly.

    The high-resilience alternative

    Alongside the lowest-cost result, Akamas surfaced other configurations. After about a dozen experiments (roughly 8 hours), one stood out: it reduced cost by 16% but behaved far better on resilience.

    High-resilience configuration: lower response-time peak on scale-out and replicas scaling back after peak load
    Figure 8: Behavior of best vs baseline configuration

    The response-time peak on scale-out was less than half the baseline.

    Replicas scaled back down after the high-load phase.

    In this configuration, CPU requests are smaller than the baseline while limits are higher, and memory requests are higher than in the lowest-cost configuration. Several JVM options change too, including the garbage collector set to Parallel, which is more efficient on CPU and memory for this workload.

    This higher-resilience result appeared while searching for cost reduction. Stating resilience as the explicit goal, and relaxing other constraints, would likely find an even better one. That was not this customer’s objective, but it shows the value of exploring tradeoffs automatically instead of guessing.

    Conclusions

    Tuning Kubernetes applications with dozens of microservices by hand is no longer feasible. It means juggling hundreds of parameters across several technology layers at once, and it gets harder when utilization-based autoscaling is in the mix.

    Akamas AI takes all of these factors into account automatically. It identifies the best configuration without manual effort and without prior knowledge of the application, the Kubernetes setup or the autoscaling policies.

    With Akamas, architects, performance engineers and SREs declare a goal (minimize cloud cost, or maximize resilience) and constraints (a response-time SLO), and get configurations plus a clear view of the tradeoffs. The result is real cost savings, better performance and resilience, and less manual toil across every team involved in delivering the service.

    Want to see this on your own workloads? Explore Akamas for Kubernetes workloads and JVM-on-Kubernetes optimization.

    FAQs

    What is Kubernetes autoscaling?

    Kubernetes autoscaling adjusts resources automatically to match load. The Horizontal Pod Autoscaler changes the number of replicas. The Vertical Pod Autoscaler changes per-pod CPU and memory requests. The Cluster Autoscaler adds or removes nodes. KEDA scales on external and resource metrics.

    Why can Kubernetes autoscaling hurt reliability?

    Autoscalers act on resource usage, not on application metrics such as response time. A change that looks efficient on CPU can push latency past its SLO. Always validate a scaling decision against the service’s own performance, not just utilization.

    Does autoscaling always reduce cost?

    No. Misaligned container and runtime settings can keep replicas running when load drops. In the case above, a JVM heap set above the memory request held memory utilization high, so replicas never scaled back and cost stayed up.

    HPA vs VPA: what is the difference?

    The Horizontal Pod Autoscaler scales out by adding replicas. The Vertical Pod Autoscaler resizes a pod by changing its CPU and memory requests. They solve different problems and can conflict if used together without care.

    How do you autoscale Kubernetes without breaking SLOs?

    Tune container requests and limits, runtime settings and scaling thresholds together, against an explicit SLO constraint rather than one layer at a time. Akamas does this automatically: in the case above it cut cost 49% while holding the response-time SLO.

  • How to Choose the Right Java Garbage Collector for Maximum Performance

    How to Choose the Right Java Garbage Collector for Maximum Performance

    The Java platform keeps getting better. The OpenJDK community has been busy improving the performance of the JVM and the garbage collector (GC): new collectors are being developed, and existing ones are constantly refined to make Java applications run faster and more efficiently.

    So when you want better application performance, it is fair to ask whether you should still tune the JVM at all. Why not simply move to a newer JVM, take the improved out-of-the-box behavior, and rely on the new low-latency garbage collectors? In other words, should you just leave application performance and efficiency to the JVM?

    There is no single best Java garbage collector. The right choice depends on your goal: throughput, latency, or memory footprint. In Akamas benchmarks, switching from the default G1 collector to Parallel GC made one Java application 22% faster while using 30% less memory. GC selection and JVM tuning still deliver large gains, even on modern JVMs. If you care about performance, cost, and resiliency, it pays not to “just leave it to the JVM.”

    The rest of this post shows why, using two studies from our labs. In each one we run extensive performance testing and benchmarking to understand how JVMs actually behave, and how best to optimize them.

    Insights on G1 garbage collector heuristics

    G1 has been the default garbage collector since OpenJDK 9, and it remains the default through the current LTS releases (JDK 17 and JDK 21). It is a significantly more complex collector than Parallel: it relies on many internal heuristics that decide when to collect garbage, how much to collect, and how much memory to allocate. All of these decisions ultimately shape application performance and efficiency.

    Our first study set out to understand how G1 GC behaves, in terms of application performance and resource footprint, under varying heap sizes. For the setup we used Renaissance, a popular open-source Java benchmark.

    We ran several experiments, increasing the Java max heap from 2 GB to 5 GB, with all other JVM options left at their defaults. During each run we measured a few key metrics: application execution time, max heap memory used, and GC metrics such as GC time (the overhead), GC CPU time, and pauses from the GC log files.

    Chart showing Java G1 GC overhead rising as the heap grows from 2 GB to 5 GB
    Figure 1: GC time increases with default JVM settings (Source: Akamas benchmark, Renaissance suite)

    The results hold a few surprises. As you would expect, execution time falls as more memory is allocated. But the GC overhead percentage rises with larger heaps, which is the opposite of what most people expect. (For more on why JVM metrics can be poor predictors of real application performance, see our companion post on why lowering GC time may not lead to better performance.).

    One G1 behavior stands out. Look at the run with a 5 GB heap, highlighted in the next figure.

    Table showing G1 GC using only 3.4 GB of a 5 GB Java heap at ~20% GC overhead
    Figure 2: G1 GC behavior at a 5 GB heap (Source: Akamas benchmark, Renaissance suite)

    Here the GC overhead is close to 20%, already significant: application threads are halted 20% of the time. Yet G1 chose to use only 3.4 GB of the 5 GB available. It did not inflate the heap, even with 1.6 GB of headroom on the table. G1 also burned a lot of CPU: 172 seconds of CPU time went to garbage collection. Since the run took 223 seconds, that is almost 80% of one CPU core spent on GC work.

    So what happened? G1 traded CPU and application throughput for memory efficiency. This is a common G1 behavior we have seen many times in production Java applications. That is fine if memory is your constraint. But what if your goal was lower CPU usage, higher efficiency, and lower cloud cost? Or higher application throughput? G1 was simply optimizing for different goals than yours.

    Why does this happen? The JVM, like any runtime, OS, or database, has to make complex decisions about performance and resource management. It makes them with built-in heuristics: rules and thresholds implemented around the collector’s own design goals. Those heuristics can behave very differently from your end-to-end performance or efficiency targets. Worse, they are driven by internal JVM metrics, not by real application performance indicators.

    What is the best JVM garbage collector?

    Our second study looked at how much the choice of collector alone affects application performance and resource footprint.

    We reused the setup from the previous experiments, with one change: we held the heap at 8 GB throughout. This time we ran OpenJDK 15, so we could assess the newer low-latency collectors. We tested five garbage collectors:

    • Serial: the single-threaded collector; simple and efficient for a small memory footprint.
    • Parallel: the multi-threaded collector; ideal for throughput-oriented applications.
    • G1: the multi-threaded collector; designed to balance latency and throughput.
    • Z and Shenandoah: the low-latency collectors available from OpenJDK 15.

    We used the Akamas platform to automate the benchmarks, gather the metrics, and compute the performance deltas. Akamas also kept results repeatable and stable: it excluded warmups automatically and ran multiple trials to confirm low variability.

    Akamas benchmark comparing Serial, Parallel, G1, Z and Shenandoah Java garbage collectors
    Figure 3: How performance and efficiency vary across GC types (Source: Akamas benchmark, Renaissance suite, OpenJDK 15). All deltas are relative to the G1 baseline

    The results are striking:

    • Parallel wins for this application. It is about 22% faster than the default G1 configuration. It is also more memory efficient, using 30% less memory.
    • Serial performs surprisingly well. It runs about 10% slower, but it is very efficient on resources: 22% less CPU and nearly half the memory of the default G1. That is notable at an 8 GB heap, where a single-threaded collector might be expected to struggle.
    • Z and Shenandoah are both slower and less memory efficient here. Z in particular used 67% more memory than G1. Their OS load average was also much higher, most likely from the extra concurrent work these collectors perform.

    These results are specific to this application. But we have seen similar patterns across many customer production applications, which confirms a simple point: the default JVM configuration and collector can be far from optimal for a given application and its performance requirements. Collectors keep improving, yet the need to tune the JVM and select the right GC will remain. As Aleksey Shipilev, developer of the Shenandoah GC and a leading JVM performance expert, put it in his Devoxx Belgium 2017 talk:

    Universal GC does not exist. You have either low latency, or high throughput or low memory footprint. For your application you have to decide which GC you want to use.”

    Aleksey Shipilev – Principal Software Engineer, RedHat

    Conclusions

    We asked whether JVM tuning still has a place today, when new JVMs ship with ever-greater performance improvements.

    The answer is yes. As we showed, choosing the best collector for your application can change performance and efficiency dramatically. Despite real improvements, the JVM remains a complex system whose default behavior does not necessarily match your specific requirements. Leave performance, efficiency, and reliability entirely to the JVM, and you are likely leaving significant gains on the table.

    There is a lot of room to improve the performance, resilience, and cost of your applications by finding the JVM parameters that are optimal for each application and workload. In a world of complex architectures, each built on many technologies with dozens or hundreds of parameters (whose behavior sometimes changes from one version to the next), that is a daunting task. It cannot be done well with predefined rules and vendor best practices alone.

    Akamas gives performance engineers a way to optimize application performance by exploring thousands of configurations automatically, without relying on predefined rules or human guesswork. Its specialized AI finds the configuration that best fits your goals (for example, a performance and cost tradeoff) and your constraints (for example, SLOs), in just a few hours. To see how this applies on Kubernetes, where the JVM and the container fight over the same memory, read preventing OOMKilled with JVM-aware optimization.

    In the next posts we will keep debunking JVM performance tuning myths and making the case for a new approach to optimization. Stay tuned.

    FAQs

    What is the best Java garbage collector?

    There is no universal best Java garbage collector. The right choice depends on your priority: throughput, latency, or memory footprint. In Akamas benchmarks, Parallel GC was 22% faster than G1 for a throughput-oriented workload, while Serial GC nearly halved memory use. Test the collectors against your own goals.

    What is the default garbage collector in Java?

    G1 is the default garbage collector from OpenJDK 9 onward, including the current LTS releases (JDK 17 and JDK 21). G1 balances latency and throughput, but its defaults are tuned for general use, not for your specific application or SLOs.

    Is Parallel GC faster than G1 GC?

    It can be, depending on the workload. In one Akamas benchmark on OpenJDK 15, Parallel GC ran about 22% faster than the default G1 and used 30% less memory. Parallel favors raw throughput; G1 favors predictable pauses. The winner depends on your goal.

    Should I still tune the JVM, or just rely on a newer version?

    You should still tune it. Newer JVMs improve default behavior, but defaults are generic. Akamas benchmarks and customer results show large gains from selecting the right collector and tuning JVM parameters per application, even on modern releases.

    How does the Java garbage collector work?

    The JVM garbage collector reclaims memory used by objects your application no longer references. Each collector uses different heuristics to decide when to collect, how much to collect, and how much memory to hold. Those heuristics are driven by internal JVM metrics, which is why they can diverge from your real performance goals.

  • Java performance: improving throughput, response time, and cost together

    Java performance: improving throughput, response time, and cost together

    Developers and system owners usually take for granted that there are some intrinsic tradeoffs in the Java design. For example, it is commonly accepted that if you aim at reducing resource usage (e.g. CPU), you must accept some performance degradation. Or that, if you optimize for maximum throughput and lowest latency, then the resource footprint of your Java application (e.g. memory usage) grows.

    The general assumption is that you cannot improve throughput, latency, and footprint of a Java application at the same time. The common belief is that the best you can achieve is to improve only two of these three metrics. This rule, which we refer to as the “JVM short blanket”, is considered to be always valid.

    In practice, that assumption is wrong: with the right JVM configuration you can improve throughput, latency, and footprint at the same time. In this post we show the results of real-world JVM optimization studies we have conducted, and how the short-blanket rule breaks once you explore the full JVM configuration space.

    The JVM short blanket: throughput, response time and cost.

    To describe the “JVM short blanket”, we will use the following statement by Charlie Hunt, the world-renowned Java performance expert, taken from his presentation on “The Fundamentals of GC Performance” at the GOTO Chicago conference in 2014:

    Improving one or two of these performance attributes, (throughput, latency or footprint) results in sacrificing some performance in the other. Improving all three performance attributes usually requires a lot of non-trivial development work.” 

    Charlie Hunt, JVM Engineer at Oracle

    It is worth noting that he used a “three-legged stool” metaphor, while others have used the “performance triangle” metaphor to illustrate the same concept.

    Before further analyzing this statement, let’s review the three metrics that represent the apexes of the “JVM short blanket”:

    • Footprint: the amount of resources (memory and CPU) the JVM needs to run.
    • Throughput: the number of operations that your application can complete in a certain period of time.
    • Latency: the time a single operation takes to be processed.

    Intuitively, if you consider how Garbage Collection (GC) operates, this makes perfect sense. If you want high throughput and low latency, the GC will need more memory (and possibly CPU cycles) to make room for application allocations without stopping it too often. On the other hand, if you want a low footprint and low latency, you must accept lower throughput. The GC then has to stop the application very frequently, which hits throughput hard.

    Therefore, it may seem that there is no way to improve throughput, latency, and footprint at the same time, at least without “some non-trivial development work”. However, we will show that it is actually possible to improve all three main Java performance metrics when a different approach to performance tuning is taken.

    Achieving higher throughput, lower response time, and smaller footprint

    As stated by another leading Java performance expert, Scott Oaks, author of the well-known “Java Performance: The Definitive Guide” book:

    The JVM is highly configurable with literally hundreds of command-line options and switches. These switches provide performance engineers a gold mine of possibilities to explore in the pursuit of the optimal configuration for a given workload on a given platform.”

    Scott Oaks, Architect at Oracle

    The key to unlocking JVM performance and efficiency lies in exploiting the incredibly vast optimization space that modern JVMs offer.

    A striking example of improving throughput, latency, and footprint all at the same time comes from an enterprise Java application supporting the CRM service of a leading Telco.

    We performed an optimization study with Akamas, our AI-powered solution, by setting the goal of minimizing the footprint of the application (JVM heap size). The customer did not want to make the application slower, so we included constraints to maintain the current throughput and response time, with a maximum degradation of 5% allowed. We used our Java OpenJDK Optimization Pack to quickly tune the key parameters among the hundreds the JVM offers.

    Akamas identified an optimal configuration in just 28 fully automated experiments run in about 20 hours, cutting the heap size by 85%: from 1.7 GB to 252 MB (see Figure 1).

    Chart showing JVM heap size reduced 85%, from 1.7 GB to 252 MB, after Akamas tuning
    Figure 1: Akamas quickly identifies the opportunity to safely reduce heap size compared to the baseline configuration.

    The result of this optimization study was considered very satisfying by the customer, as it provided the opportunity to safely reduce the heap size while preserving the defined SLOs.

    Besides reducing the memory footprint, this configuration is also an interesting outcome for the “JVM short blanket” discussion. The same optimal configuration increased throughput by 23% and reduced response time by 22% on average and 17% at the 90th percentile (see Figures 2 to 4). All these numbers come from the same Akamas optimization study on the Telco CRM application.

    Chart showing Java application throughput increased 23% after JVM tuning
    Figure 2: Throughput in the baseline configuration vs the optimal configuration.
    Chart showing average Java response time reduced 22% after JVM tuning
    Figure 3: Response time (average) in the baseline configuration vs the optimal configuration.
    Chart showing 90th-percentile Java response time reduced 17% after JVM tuning
    Figure 4: Response time (90th percentile) in the baseline configuration vs the optimal configuration.

    Let’s summarize the result of this optimization study. The JVM configuration identified by Akamas made the application run faster while also reducing the heap size by more than 85%. All three metrics (throughput, latency, footprint) improved at once, just by tuning JVM parameters well: an opportunity that would otherwise be left on the table.

    Conclusions

    In the Java performance world, the general rule is that you cannot improve application latency, throughput, and footprint at the same time without significant development work. This is what we call the “JVM short blanket”.

    Modern JVMs offer a goldmine of 700+ configuration options that software and performance engineers can tune to reach optimal performance and efficiency. As we have seen, it is possible to improve all three key metrics at the same time.

    Finding configurations that improve throughput, latency, and footprint together requires the ability to intelligently explore the vast space of application configurations. This is only made possible by AI techniques, such as the patented Reinforcement Learning behind Akamas, designed to solve optimization problems that are otherwise unmanageable even for the best human experts. The same approach extends beyond the JVM to other application runtimes and to Java workloads running on Kubernetes.

    This is the second entry in a series on JVM performance tuning and the AI-powered approach to performance optimization. You can read the first entry here. Keep on reading us!

    FAQs

    Can you improve Java throughput, latency, and memory footprint at the same time?

    Yes. The tradeoff is not a hard law of the JVM. In one Akamas study on a Telco CRM application, tuning JVM parameters cut heap size 85% while raising throughput 23% and lowering average response time 22%.

    What is Java performance tuning?

    Java performance tuning is the practice of adjusting JVM and application settings, such as heap sizing, garbage collector choice, and GC parameters, to improve throughput, response time, and resource usage for a given workload.

    How do you improve the performance of a Java application?

    Start by defining clear goals and SLOs, then explore the JVM configuration space rather than changing one flag at a time. Modern JVMs expose 700+ options, so an automated, AI-driven search finds better combinations faster than manual tuning.

    What is the “JVM short blanket”?

    The “JVM short blanket” is the common assumption that improving one or two of throughput, latency, and footprint always sacrifices the third. Real optimization studies show this assumption breaks once the full configuration space is explored.

    How many configuration options does the JVM have?

    Modern JVMs expose more than 700 command-line options and switches. Most are never touched, which is exactly why so much performance and efficiency is left unclaimed.

  • Beware: lowering GC time may not lead to better application performance

    Beware: lowering GC time may not lead to better application performance

    One of the most established approaches to improving Java application performance is to tune JVM options, in particular Garbage Collector (GC) parameters.

    Here is the surprising part: lowering GC overhead does not always make a Java application faster. In our benchmarks, a JVM configuration with roughly twice the GC overhead ran 29% faster than the default. The reason is that concurrent GC threads compete with application threads for CPU, and that work is never counted in the GC overhead metric. The rest of this post shows how we found this, and what it means for JVM tuning.

    The main task of garbage collection is to free memory up. That requires stopping the application threads during the stop-the-world (STW) pause; application threads then resume once the garbage collection has completed. The STW interval is measured by the GC pause metric.

    Diagram of Java application threads pausing during a stop-the-world GC pause while GC threads run
    Figure 1: Application and GC threads execution and Stop-The-Word pause

    The percentage of time spent performing garbage collection is called GC time or GC overhead.

    The conventional wisdom of GC performance is that you must always try to lower GC time as much as possible. This seems to make sense: by decreasing GC time, we get higher throughput, meaning application threads can run longer without interruption. However, when you run actual optimization studies, things can turn out very differently, as we will see.

    GC time and application throughput: the golden rule of JVM tuning

    The following chart, taken from the official Oracle documentation, shows the impact of GC time percentage on application throughput and scalability.

    Oracle chart showing how rising GC time percentage reduces Java application throughput and scalability
    Figure 2: impact of GC time percentage on application throughput (source: Oracle documentation)

    These curves basically follow the well-known Amdahl’s law, which states that the speedup of a parallel program is limited by its sequential part. In Java, the sequential part is the GC pause; the rest is parallel processing.

    Looking at this chart, it is easy to see why the general goal of improving Java application throughput via JVM tuning is stated as the “golden” rule: “keep the overhead of doing garbage collection as low as possible” (as stated in the Oracle documentation).

    This rule is so ingrained in our industry practices that it is not only the main best practice for JVM tuning; it is also hardcoded into many APM tools when they recommend how to tune the JVM.

    However, GC overhead is far from the only factor driving application performance. More importantly, by focusing only on reducing GC overhead you may actually end up slowing your application down. A very counterintuitive fact.

    Looking deeper into GC behaviour

    To see how counterintuitive GC behaviour can get, we used Renaissance, a popular open-source Java benchmarking suite (renaissance.dev) that includes a Spark-based application running on OpenJDK 11. We studied how application execution time varies as the JVM and GC parameters are tuned.

    To simplify this task we leveraged Akamas, our AI-powered optimization solution. Akamas launches the benchmark with different JVM configurations and automatically finds an optimal configuration driven by a custom goal, such as minimizing execution time. This let us run 80 experiments in about 20 hours, completely unattended.

    The following chart shows the results. Each dot is a benchmark execution with a specific set of JVM options. The yellow dot is the JVM with default settings (the baseline configuration); the red dot is the optimal configuration.

    Scatter plot of 80 JVM configurations where the optimal setup runs 29% faster despite higher GC overhead
    Figure 3: The optimal configuration is 29% faster despite higher GC time (source: Akamas)

    This chart reveals a couple of interesting findings:

    • The best configuration makes the application 29% faster than the baseline. That is not a small improvement, and it was achieved simply by reconfiguring the JVM.
    • The best configuration also has a higher GC overhead, by almost a factor of 2x. This is very counterintuitive and runs against the golden rule.

    The shape of the curve is worth a comment too. We might have expected a roughly linear relationship: the higher the GC overhead, the higher the execution time. Instead, the minimum execution times are reached at around 30% GC overhead.

    It is also worth noting that the baseline sits at 15% GC overhead, which is already considered quite high. Some APM tools warn about “high overhead” at 15%. And yet the surprising result is that a configuration with even higher GC overhead (around 30%) makes the application go faster.

    All of this raises the question: how can an application run faster when GC is leaving less time for the application threads? To find the answer, we had to go deeper, down to the OS level where the JVM threads are scheduled.

    Behind the scenes: how concurrent GC threads compete for CPU

    To understand the dynamics of JVM performance, we analyzed how application and GC threads are managed by the Linux CPU scheduler on the actual processors.

    Several tracing tools can be used for this. Examples include Linux perf, the main low-level performance analysis tool for Linux, and ftrace, a facility built into the Linux kernel that traces scheduling events. We chose Perfetto, a browser-based tracing tool built by Google. It is best known among Android developers for diagnosing mobile app performance, but it also works on standard Linux distributions and provides a clear visualization.

    The following chart shows the JVM threads (one per row) as they are scheduled on the CPUs. Application threads are at the top (Executor tasks); GC threads are at the bottom. The GC threads are the JVM threads that actually perform the GC work. For each thread, the bar shows when it is running: dark green when running on the CPU, light green when waiting to access the CPU.

    Perfetto CPU trace showing G1 concurrent GC threads competing with Java application threads for CPU
    Figure 4: GC threats stealing CPU cycles from application threads (source: Akamas)

    Notice that some GC threads run concurrently with the application threads. These are the “G1 Conc” threads. This is a design feature of the OpenJDK 11 G1 Garbage Collector, which uses background threads to perform part of the garbage collection process in order to reduce the STW pause.

    This is where the answer lies. The G1 GC concurrent threads compete with the application threads for CPU resources. Because these GC threads run concurrently with the application, their work is not counted in the GC overhead metric, which is exactly what breaks the golden rule.

    So when you tune the JVM by following the golden rule of reducing GC overhead alone, you cannot be sure it will improve application performance. You may even cause more harm than good: you might be asking the Garbage Collector to do more concurrent work, which keeps the application threads waiting and slows the application down.

    Conclusions

    The key takeaway is that GC time remains an important metric to watch, but the simple golden rule of always reducing GC overhead does not always work. That rule relies on a simplistic model of what happens at the JVM level. It no longer holds in modern systems, where the JVM and the underlying system interact in complex, sometimes unpredictable ways that have real effects on end-to-end application performance.

    This is just one instance of a broader situation in performance tuning today. The complexity of applications (monolithic or microservice-based) and infrastructures (on-premise, cloud, or hybrid) makes it very hard to tune by relying on predefined rules and vendor best practices.

    Akamas gives performance engineers the ability to optimize application performance by intelligently exploring thousands of configurations, without relying on predefined rules or human knowledge. Its specialized AI techniques find the optimal configuration for your custom goals (for example, performance and cost tradeoffs) and constraints (for example, SLOs) in just a few hours.

    If you want to go further on JVM tuning, see our guide on how to choose the right Java garbage collector, how Akamas handles application runtimes such as the JVM and Node.js, and, for Kubernetes, JVM on Kubernetes optimization and the State of Java on Kubernetes 2026.

    In the following blog entries we will continue to debunk other JVM performance tuning myths and advocate for a new approach to performance optimization. Stay tuned!

    FAQs

    What is GC overhead?

    GC overhead, also called GC time, is the percentage of time an application spends performing garbage collection instead of running application code. It is a standard JVM performance metric. As this article shows, it does not capture concurrent GC work, so it is an incomplete picture of GC cost.

    Is high GC overhead always bad?

    No. High GC overhead is often treated as a problem, and some APM tools flag it at 15%. But in our benchmarks a configuration at around 30% GC overhead ran 29% faster than the baseline. GC overhead should be read alongside end-to-end application performance, not on its own.

    How is GC overhead different from the “GC overhead limit exceeded” error?

    They are different things. GC overhead is a performance metric (a percentage of time). “GC overhead limit exceeded” is a specific OutOfMemoryError the JVM throws when the collector runs almost constantly while reclaiming very little memory. The metric describes cost; the error signals a memory problem.

    Which garbage collector and JDK did the study use?

    The study used the G1 Garbage Collector on OpenJDK 11, benchmarked with the Renaissance suite. The counterintuitive result comes largely from G1’s concurrent (“G1 Conc”) threads, whose CPU work is not counted in GC overhead.