Day 2 : OS Tuning – Why Your Kernel Is Sabotaging Your 8GB IDP

Lesson 2 15 min

Architecture View

Host OS (8GB RAM) Memory Hierarchy Hot Tier – Active Pages (2.5GB) Warm Tier – File-Backed (1.5GB) Cold Tier – Inactive → Swap /proc Filesystem /proc/meminfo /proc/swaps /proc/sys/vm/swappiness Swap on SSD – 4GB (vm.swappiness=10) K3d Cluster nano-system namespace FastAPI Backend (64Mi / 128Mi) React + Nginx (32Mi / 64Mi) Monitoring Targets ArgoCD (~600Mi) vCluster (~400Mi) Crossplane (~800Mi) User Browser React Dashboard (TanStack Query, 3s polling)

DON'T DO THIS

Request/Response Flow

User React App (30080) Nginx Proxy FastAPI Backend (8000) /proc FS Linux Kernel Load Dashboard Mount useQuery Hook Loop: Every 3 seconds GET /api/memory/stats Proxy to Backend Read /proc/meminfo MemTotal, MemAvailable, SwapTotal Read vm.swappiness 10 Calculate Pressure Level ALT: Available Memory > 40% → low > 20% → medium > 10% → high else → critical JSON Response Forward Response Update Chart (Last 20) Render Dashboard Click “Test Pressure” kubectl apply memory-pressure-pod Memory Hog allocates 200MB vm.swappiness=10 → avoid preemptive swap pressure_level = "high" Display Warning

sudo fallocate -l 16G /swapfile
sudo swapon /swapfile

Code

Then they walk away, leaving you with a system that **thrashes itself to death**. Why? Because they never told you about `vm.swappiness`.

Here's what actually happens on an 8GB machine when you blindly enable swap:

1. **Minute 0:** You deploy ArgoCD. It consumes 600MB. Fine.
2. **Minute 5:** You deploy a vCluster. Another 400MB. Still okay.
3. **Minute 10:** You deploy Crossplane with 3 providers. 800MB more.
4. **Minute 12:** **Kernel panic mode.** Linux sees 7.2GB used and thinks "I need to be proactive!" It starts swapping out **actively-used pages** (like ArgoCD's Redis cache) to disk.
5. **Minute 13:** ArgoCD tries to reconcile. Needs Redis. **Page fault.** Waits for disk I/O.
6. **Minute 14:** Your terminal is frozen. `kubectl` takes 30 seconds to respond.
7. **Minute 15:** You rage-quit and buy a $3,000 MacBook Pro.

**The problem isn't swap. The problem is the kernel's default swappiness of 60.**

---

### The Nano Architecture: Kernel-Aware Memory Management

In the Nano-IDP, we treat memory as a **three-tier hierarchy**:

┌─────────────────────────────────────────┐
│ Hot Tier: Active Anonymous Pages │ ← K8s control plane, API server
│ (Stay in RAM at all costs) │ Target: 2.5GB
├─────────────────────────────────────────┤
│ Warm Tier: File-Backed Pages │ ← Container images, logs
│ (Kernel can drop, reload from disk) │ Target: 1.5GB
├─────────────────────────────────────────┤
│ Cold Tier: Inactive Anonymous Pages │ ← Idle vClusters, paused pods
│ (Swap these aggressively) │ Swap: 4GB on SSD
└─────────────────────────────────────────┘

Memory Map (8GB Breakdown)

Physical RAM: 8192 MB Kernel Space: 1800 MB Kernel Code
200 MB Kernel Data
150 MB
Page Cache
1200 MB (Reclaimable)
Buffers
250 MB (Reclaimable)
K3d Control Plane: 1400 MB K3s Server
800 MB
K3s Agent
600 MB
Workload Pods: 2800 MB ArgoCD
600 MB
vCluster
400 MB
Crossplane
800 MB
Memory Monitor
96 MB
User Workloads
904 MB
Available: 2192 MB Free Pages
1500 MB
Kernel Reserved
692 MB
Swap Space: 4096 MB (SSD) Used: ~800 MB (Inactive Pages) Free: ~3296 MB Memory Pressure Thresholds Low: > 3200 MB Available (40%) Medium: > 1600 MB Available (20%) High: > 800 MB Available (10%) Critical: < 800 MB Available — OOM Risk Falls below 1.5GB Reclaimable
Need help?