Disclaimer: I have found it a lil tough to translate my mental model about XYZ topic in words to juniors. I’m able to explain it to them, but I’m making up stuff on the fly when I do that. So, I’m using LLM to do this now. Most of what you see below is LLM. I have pestered LLMs enough till I like what I read.
When building applications, you’ll hear people casually toss around CPU, RAM, Disk like everyone’s born knowing how they fit together.
Here’s a way to lock the picture in your head-a restaurant analogy.
🌟 The Restaurant Analogy
- CPU = The Chef
- Purpose: Does the actual cooking (computation).
- Fast, skilled, but limited hands. If overloaded, dishes (tasks) wait.
- Key metric: Speed (GHz) and how many chefs you have (cores).
- RAM = The Kitchen Counter
- Purpose: Holds ingredients the chef is actively using.
- It’s close by, quick to grab from, but space is limited.
- Key metric: Size (GB). Too little counter space = constant running to the pantry (slow).
- Disk = The Pantry/Fridge
- Purpose: Long-term storage of all ingredients.
- Huge, but slow compared to the counter.
- Key metric: Capacity (GB/TB). Some pantries are faster (SSD) than others (HDD).
🌟 How They Work Together
- A customer places an order (your program runs).
- The chef (CPU) gets busy.
- Chef grabs ingredients from the counter (RAM).
- If they’re there already → fast.
- If not → chef yells to the waiter: “Fetch from pantry!” (disk).
- If the pantry is slow (old hard drive), the chef spends time waiting instead of cooking.
- This is why SSDs feel snappy.
- If the counter is too small (low RAM), ingredients keep being shuffled back to pantry.
- This is “swapping” → painfully slow.
🌟 Toolbox View
- CPU (Compute Power) → Crunching numbers. The more chefs and faster knives, the quicker the output.
- RAM (Working Memory) → Active space. The bigger the counter, the more simultaneous dishes/ingredints the chef can juggle.
- Disk (Storage) → The giant pantry. Holds everything, but too slow to cook directly from.
🌟 Performance Principles
- CPU bottleneck → Chef is overloaded. Adding more chefs (cores) or faster chefs (GHz) helps.
- RAM bottleneck → Counter space is too small. More RAM = fewer pantry runs.
- Disk bottleneck → Pantry is slow. SSD = faster pantry than HDD.
🌟 Key Extras
- Cache (L1/L2/L3) = Mini spice racks next to the chef. Super tiny, blazing fast.
- Virtual Memory = Pretending pantry space (disk) is counter space (RAM). Works, but chef hates it.
- Throughput vs Latency:
- CPU = how fast the chef can chop one onion (latency).
- RAM/Disk = how many onions can be carried at once (throughput).
🎯 Memorable Takeaway
CPU = Chef, RAM = Counter, Disk = Pantry.
The chef only works efficiently if:
- The counter is big enough,
- The pantry is stocked and reasonably fast.
- And the chef isn’t overloaded.
🍳 Disk: IOPS vs Bandwidth
(Chef’s Pantry Woes)
Picture your pantry. It’s not just about how big it is (storage capacity). It’s about how fast your sous-chefs can:
- Grab 1 ingredient quickly (IOPS)
- Carry a whole sack of potatoes at once (Bandwidth)
🥄 IOPS = How many times per second you can open the pantry door.
- Small random grabs.
- Like yelling “Get me a clove of garlic!” 10,000 times.
- SSDs are speedy errand boys-they dart in and out with tiny stuff, no problem.
🍲 Bandwidth = How much total weight they can carry per trip.
- Huge loads.
- “Bring me 10kg of rice in one go.”
- If your pantry is fast, and you batch requests, the pipeline flows.
Kitchen Drama:
- If you scream 100 tiny requests per second but your errand boy has two legs and no arms → you’ll stall. That’s an IOPS cap.
- If your errand boy is strong but the hallway is narrow → you hit bandwidth limits.
- If you batch smartly (“get all the onions in one trip”) → you maximize both.
🧠 CPU iowait = Chef twiddling thumbs
Let’s say the chef (CPU) is ready to cook, knife in hand.
But…
🥶 “Where’s the garlic?”
🙄 “Still coming from the pantry.”
😤 “Fine, I’ll wait.”
iowait = Time the chef spends doing nothing while waiting for the pantry boy.
- Disk slow → iowait high.
- Chef isn’t lazy, he’s blocked.
But if the network waiter is late (not disk), the chef isn’t even counted as iowait. He just… sits silently staring at the door, and the manager (OS) logs it as “idle” or “waiting on someone else.”
Metaphor twist:
- iowait is blameable delay.
- Network stalls are ghost delays-they don’t show up as iowait but your food is still late
🧍CPU Noisy Neighbor = The Other Chef Hogging the Stove
Now imagine:
You’re the main chef. You’ve prepped your dish.
You reach for the stove, and-BAM-some junior from another kitchen is already hogging it.
This is Noisy Neighbor syndrome.
🍽️ VM World = Shared Kitchen
- That other chef? Belongs to another restaurant. But you’re both renting the same kitchen.
- When you want the stove, the landlord says “Wait, he’s using it right now.”
- That’s %steal → CPU time stolen from you.
🥣 Container World = Shared Utensils
- You and another container share the knife set.
- You hit your CPU limits (ulimits/cgroups) → kernel yanks the knife out of your hand mid-chop. That’s throttling.
🔥 Worst case?
- Chef gets part-time access to the stove, the pan, and the ladle-but guests expect full-course meals.
- You’ll miss your SLA.
- Guests walk out.
- Michelin star revoked.
🧂 RAM Overcommit = The Lying Sous-Chef
Alright-back to the kitchen counter (RAM).
You say, “I need space for 4 cutting boards.”
Your sous-chef says:
“Absolutely, Chef. There’s plenty of room. We’ll figure it out.”
They lie.
They’re gambling you won’t use all 4 boards at once.
This is overcommit.
- You think you have 4 counters.
- But when you reach for board #3, the sous-chef says:
“Uhhh… one sec, I need to move these dirty bowls to the pantry first.”
Boom. Swap kicks in.
You just paid a massive latency tax because the sous-chef promised you virtual counter space instead of real wood.
📉 Transparent Huge Pages?
Those are giant chopping boards.
If you only want to slice a lime, the chef still gets the giant board. Waste of space. And when there’s a space crunch, folding and unfolding those is SLOW.
🧃 Page Cache = Pre-chopped Veggies
RAM stores stuff you used recently (file data) in page cache, like mise en place-not active ingredients, but quick to grab again.
Don’t wipe it unless you’re desperate.
It’s smart.
🔁 Summary: Kitchen Operations Breakdown
| Metaphor Component | Real Component | When It Goes Wrong |
|---|---|---|
| Chef | CPU | He’s idle, waiting for disk (iowait), or throttled (limits). |
| Knife/Stove/Tools | CPU Cores | Other chefs hog them (steal time or CPU contention). |
| Kitchen Counter | RAM | Too small? You juggle. Overcommitted? OS lies, leads to swap. |
| Pantry | Disk | Slow errand boy, or too many small trips = app stalls. |
| Walkway Width | Disk Bandwidth | Bulk transfers get bottlenecked. |
| Trips to Pantry | Disk IOPS | You need a fast runner (SSD), or fewer small trips. |
| Sous-Chef’s Fake Promises | Overcommit Memory | You crash during the rush. OOM killer slaps your station. |
| Giant Chopping Boards | Transparent Huge Pages | Good for steakhouse, bad for sushi bar. |