0
0
Kubernetesdevops~3 mins

Why Memory requests and limits in Kubernetes? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if one app could silently crash all your others just by using too much memory?

The Scenario

Imagine running many apps on a shared computer without telling it how much memory each app needs. Sometimes one app uses too much memory, making others slow or crash.

The Problem

Manually guessing memory needs is slow and risky. If you give too little memory, apps crash. Too much memory wastes resources. Without limits, one app can hog all memory, breaking others.

The Solution

Memory requests and limits let you tell Kubernetes exactly how much memory each app needs and the max it can use. This keeps apps stable and the system balanced automatically.

Before vs After
Before
Run app without memory settings
kubectl run myapp --image=myimage
After
Set memory request and limit
kubectl run myapp --image=myimage --requests='memory=200Mi' --limits='memory=500Mi'
What It Enables

This lets Kubernetes manage resources smartly, keeping apps healthy and the system running smoothly even with many apps.

Real Life Example

A company runs many microservices on the same cluster. Setting memory requests and limits prevents one service from crashing others during traffic spikes.

Key Takeaways

Manual memory management causes crashes and slowdowns.

Memory requests reserve needed memory; limits cap max usage.

Using them keeps apps stable and resources balanced automatically.