Stage 4, Part 4 of 9 · p. 32, Workloads & Lifecycle Deep Dive

PART 4: CAPACITY PLANNING & COST MODELING

20. Workload Sizing Fundamentals

The Sizing Formula

text
Total capacity = sum(replicas) × requests × overcommit_factor

Example:
  - 10 apps
  - 3 replicas each
  - 500m CPU, 512Mi memory per Pod
  - 2x CPU overcommit, 1.5x memory overcommit

CPU: 10 × 3 × 500m × 2 = 30 cores
Memory: 10 × 3 × 512Mi × 1.5 = 23 GiB

Right-Sizing

SignalAction
CPU throttling > 5%Increase CPU limit
OOMKilledIncrease memory limit
Low utilization (< 20%)Decrease requests
High utilization (> 80%)Increase requests

The VPA Recommendation Workflow

bash
# Install VPA
kubectl apply -f https://github.com/kubernetes/autoscaler/raw/master/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml

# Create VPA in recommendation mode
kubectl apply -f - <<EOF
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: web-vpa
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: web
  updatePolicy:
    updateMode: "Off"        # Only recommendations
EOF

# Check recommendations
kubectl describe vpa web-vpa

21. Disruption Budget and Availability Math

Availability During Drain

With N replicas and PDB minAvailable: M:

text
Max pods that can be down = N - M

Example: 5 replicas, minAvailable: 3
Max down = 2
Drain time = 2 × pod_shutdown_time

The Drain Time Formula

text
Drain time = (replicas - minAvailable) × (terminationGracePeriodSeconds + eviction overhead)

Example:
  - 5 replicas
  - minAvailable: 3
  - terminationGracePeriodSeconds: 30

Drain time = 2 × 30s = 60s

Availability Target

text
Availability = 1 - (downtime during disruption / total time)

With PDB, downtime is bounded by:
  (N - M) / N × disruption_duration

22. SLA & Availability Design

Availability Math

text
99.9%   = 8.76 hours downtime/year
99.99%  = 52.56 minutes downtime/year
99.999% = 5.26 minutes downtime/year

Workload SLA Design

TargetArchitecture
99.9%3 replicas, PDB minAvailable: 2
99.99%3 replicas across 3 AZs, PDB, anti-affinity
99.999%Multi-region, 5+ replicas, chaos-tested

1:1 copy of the class Google Doc, code in code blocks.