Course contentsShow
← Docker, Kubernetes & CI/CD
Lesson 777 of 80211. Production Operations and ReliabilityFree lesson

Establishing Resource Baselines Through Monitoring

Analyze historical metrics to determine the current average and peak resource consumption patterns of your containerized applications.

In this lesson, you will learn how to transition from guesswork to data-driven decision-making by analyzing historical metrics to establish accurate CPU and memory baselines for your containerized services.

The Problem of Static Guesswork

In production environments, developers often assign Kubernetes requests and limits based on "gut feeling" or arbitrary defaults. If these values are too high, you waste expensive compute capacity; if too low, your application risks being throttled or killed by the OOM (Out of Memory) killer. Establishing a baseline is the process of using historical performance data to align your configuration with reality.

Analyzing Patterns

To establish a baseline, you must look beyond instantaneous usage and analyze time-series data from your monitoring stack (e.g., Prometheus). You aren’t just looking for the average; you are looking for the peak.

  1. Define the Window: Pull metrics from a representative period (e.g., the last 7–14 days) that includes a full business cycle of traffic.
  2. Calculate the P95/P99: Ignore outliers and noise. Calculate the 95th or 99th percentile of resource usage to ensure your container is provisioned to handle almost every spike without needing to burst.
  3. Identify the Floor: Identify the "idle" or "baseline" consumption during low-traffic periods to set your requests.

Practical Application

If your monitoring dashboard reveals that your service consistently consumes 150Mi of RAM during off-peak hours but jumps to 450Mi during peak traffic, your configuration should reflect this:

resources:
  requests:
    memory: "200Mi" # Slightly above idle floor
  limits:
    memory: "512Mi" # Above peak observed usage

By reviewing these metrics monthly, you can adjust your resource definitions to match actual demand. This turns your resource configuration from a static guess into a dynamic, performance-informed policy that optimizes both cost and stability. When you detect that your P99 usage is trending upward over time, you gain an early warning sign that your application may require code optimization or horizontal scaling before an incident occurs.

Key Takeaway: Use historical P95/P99 metrics to set resource requests and limits, ensuring your containers are sized based on actual peak demand rather than arbitrary estimates.