Observability

Mastering Kubernetes Resource Management in 2025: Beyond Default Limits and HPA

Learn how to profile workloads and master CPU/memory requests, limits, and HPA in Kubernetes for 2025—complete with best practices, YAML snippets, and real‑world examples.

Younes Hairej profile picture
Younes Hairej6 min read
A futuristic silhouette walks a glowing tightrope suspended above digital clouds and a neon grid, balancing two weights labeled “CPU” and “Memory,” with floating holographic tech icons surrounding the scene.

Introduction

Managing resources in Kubernetes has always been a balancing act. In 2025, as clusters grow and multi‑tenant scenarios proliferate, it's no longer enough to slap on arbitrary CPU limits or default HPA settings. At Aokumo, we've seen two extremes: workloads throttled by overly tight limits and clusters destabilized by "noisy neighbors." The secret? Intimately understand your workload—is it CPU‑heavy, memory‑bound, or a bursty batch job?—and let observability data drive your requests, limits, and autoscaling rules.

This post dives into the CPU‑limits debate, the evolving role of the Horizontal Pod Autoscaler (HPA), common resource setup pitfalls, and actionable best practices—backed by Aokumo insights and the latest in community chatter on X (formerly Twitter).

1. Understanding Your Workload Patterns

Before touching requests, limits, or HPA, collect metrics to answer:

  • Steady vs. bursty: Does your pod spike at startup, then settle?
  • CPU vs. memory bound: Are you crunching numbers or holding large in‑memory datasets?
  • Duration & concurrency: Do short‑lived jobs flood the CPU, or do long‑running services trickle load?

Aokumo Tip: Integrate Prometheus (or Metrics Server + custom exporters) and visualize per‑pod CPU/memory over days. Look for recurring spikes—e.g., many apps hit 300% CPU at launch, then drop to 50%—so your requests reflect the true baseline, not just the peak.

2. The CPU Limits Debate

Why Limits Hurt

  • Unnecessary throttling: Kubernetes enforces limits strictly—if a pod requests 100m and hits 200m, it's capped, even if a cluster spare CPU exists. This can spike latency and trigger liveness‑probe failures.
  • False resource starvation: Similar to "you built a 1‑lane road but cap cars at 1—even though 3 lanes are free," limits block healthy usage.

When You Still Need Them

  • Multi‑tenancy & noisy neighbors: One runaway job can crush co-tenants in shared clusters (SaaS platforms, internal dev/test clusters).
  • Regulated or cost‑capped environments: Some managed offerings (e.g. IBM Code Engine) require limits for billing and isolation.
  • Policy enforcement via tools: Rancher or Popeye may inject or check limits automatically; disabling them can conflict with organization standards.

Multi-tenant implementation: In multi-tenant clusters, set limits to achieve QoS=Guaranteed (requests=limits) for critical pods, ensuring priority during eviction. Use generous limits (e.g., 3x requests) to minimize throttling, and monitor container_cpu_cfs_throttled_seconds_total to adjust dynamically. Combine with ResourceQuota to cap total usage per namespace.

Community Insights: On X, Kubernetes architects actively debate CPU limits versus HPA for handling workloads of 200-350% CPU utilization. Most favor accurate requests with HPA for peaks, but several note that multi-tenant environments still benefit from limits. As @k8s_engineer noted, "The key is setting limits high enough to avoid throttling during normal operation, but low enough to prevent resource starvation."

Aokumo Insight: Don't default to "no limits." Instead, profile and apply limits only where measurement shows true worst‑case spikes beyond acceptable thresholds—and always monitor for throttling (container_cpu_cfs_throttled_seconds_total).

3. HPA & Resource Requests: Getting Them Aligned

The HPA scales based on a percentage of CPU request, not the limit. If your request is too low, even 90% usage may only spin up one extra pod.

  • Accurate requests = foundation for HPA: Use historical metrics or tools like CAST AI to recommend requests.
  • K8s 1.30 upgrade: Stable per‑container metrics let HPA use fine‑grained data; no more guessing at aggregate pod CPU.
  • Autoscaler coordination: For complete resource management, coordinate HPA (horizontal scaling) with VPA in "recommendation" mode (for request adjustments) and ensure your Cluster Autoscaler can accommodate HPA-triggered growth to prevent pending pods.

Pitfall: Missing requests → HPA does nothing ("undefined utilization").

Tip: Always pair HPA with sensible requests. For example, if your service idles at ~50m and peaks at 500m, set the request to 200 m and the target CPU utilization to 60%.

4. Common Challenges & Solutions

Kubernetes resource allocation challenges

Kubernetes resource allocation challenges

5. Best Practices & Tooling

Measure Then Configure

  • Baseline 72‑hour CPU/memory profile before setting requests.
  • Identify "start spikes" vs "steady state" in your observability dashboard.

Setting Up Observability

  • Deploy a complete monitoring stack with Prometheus, Grafana, and AlertManager to track resource utilization.
  • Create dashboards showing container_cpu_usage_seconds_total and container_memory_working_set_bytes over time.
  • Set up key Prometheus queries like rate(container_cpu_cfs_throttled_seconds_total[5m]) to detect throttling events.
  • For managed alternatives, consider Sysdig Monitor or Datadog for deeper resource insights with lower operational overhead.

Requests = Minimum, Limits = Safety Net

  • Always set requests.
  • Set limits only when needed for isolation; leave them generous (e.g., request = 200m, limit = 600m).
Kubernetes resource management flow

Kubernetes resource management flow

HPA Tuning

  • Use targetCPUUtilizationPercentage of 50–70% for web services.
  • For batch or burst jobs, consider custom or external metrics (QPS, queue length).
  • Leverage stable per‑container metrics in K8s 1.30 for multi‑container pods.
  • If using older Kubernetes versions (pre-1.30), use Resource metrics instead of ContainerResource.

Probe Configuration

  • Add startupProbes for apps with slow initialization, to avoid premature restarts.
  • Tune periodSeconds and failureThreshold to match actual load patterns.

Rightsizing & Cost Optimization

  • Use CAST AI or Kubecost to get automated request/limit recommendations.
  • Automate "sleep mode" for non‑prod with tools like Winter Soldier (Devtron) or vCluster hibernation.
  • Identify overprovisioned pods and reduce requests by 20-40% based on historical usage.
  • Consider spot instances via Cluster Autoscaler for non-critical workloads to reduce costs.

Policy & Quota Management

  • Define LimitRanges per namespace: min, max, and default requests/limits.
  • Enforce ResourceQuotas to prevent a rogue team from exhausting cluster resources.
  • In multi-tenant clusters, set appropriate limits to ensure critical pods receive the Guaranteed QoS class.

6. Code Examples

1. HPA with Stability Windows

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: web-service-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: web-service
  minReplicas: 3
  maxReplicas: 12
  metrics:
    - type: ContainerResource
      containerResource:
        name: cpu
        container: app                     # per-container metrics (K8s ≥1.30)
        target:
          type: Utilization
          averageUtilization: 60
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 300     # wait 5 min before down‑scaling
      policies:
        - type: Percent
          value: 20
          periodSeconds: 60
    scaleUp:
      stabilizationWindowSeconds: 60      # wait 1 min before up‑scaling
      policies:
        - type: Pods
          value: 2
          periodSeconds: 60
        - type: Percent
          value: 50
          periodSeconds: 60
      selectPolicy: Max

2. Namespace LimitRange

apiVersion: v1
kind: LimitRange
metadata:
  name: default-limits
  namespace: team-apps
spec:
  limits:
    - type: Container
      default:
        cpu: "400m"
        memory: "512Mi"
      defaultRequest:
        cpu: "100m"
        memory: "128Mi"
      min:
        cpu: "50m"
        memory: "64Mi"
      max:
        cpu: "2000m"
        memory: "2Gi"

Load Testing Strategies

For validating your resource configuration and HPA behavior under load, consider these approaches:

  1. Synthetic HTTP testing tools like K6, Fortio, or Locust to simulate real-world API traffic patterns
  2. Resource consumption simulators that directly target CPU/memory usage
  3. Node stress testing to validate pod eviction and QoS behavior under resource pressure

The key is to test with both gradual and sudden load changes to ensure your configuration responds appropriately to different traffic patterns.

7. Case Study: Peak Startup Workload

A fintech customer ran a data‑ingestion job that spiked at 400% CPU for 30 seconds on each pod and then settled at 60%. They had set requests to 100 m, limits to 200 m, and an HPA target of 75%, but the pods restarted repeatedly at initialization, and the HPA never kicked in.

Aokumo approach:

  • Measured a 30‑second spike → added a startupProbe with a 60s timeout.
  • Raised request to 250m (reflecting average + 1σ), limit to 600m.
  • Tuned HPA to target 60% on the new request.

Result: Zero restarts, smooth autoscaling from 3→12 pods under load, and a 20% reduction in wasted CPU.

Conclusion

In 2025, one‑size‑fits‑all resource settings no longer cut it. By grounding your requests, limits, and HPA rules in real workload patterns, you'll avoid throttling, contain noisy neighbors, and unlock true autoscaling.

Your next steps:

  1. Profile your workloads for 72 hrs.
  2. Apply baseline requests before tweaking limits.
  3. Tune HPA using per‑container metrics.
  4. Automate rightsizing with CAST AI or Kubecost.
  5. Harden probes to match your app's behavior.

Need hands‑on help? Schedule a free resource audit with Aokumo's Kubernetes experts and turn your cluster into a self‑tuning powerhouse. We'll help you identify throttling issues, optimize costs, and implement the right scaling strategy for your workloads.