<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arul Prasath Velusamy on Medium]]></title>
        <description><![CDATA[Stories by Arul Prasath Velusamy on Medium]]></description>
        <link>https://medium.com/@arulprasath73?source=rss-342ca3cf9604------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iIOBtllIqNkE5Im3pk277w@2x.jpeg</url>
            <title>Stories by Arul Prasath Velusamy on Medium</title>
            <link>https://medium.com/@arulprasath73?source=rss-342ca3cf9604------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 03:35:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arulprasath73/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Demystifying Kubernetes Requests and Limits: From YAML to Linux cgroups]]></title>
            <link>https://medium.com/@arulprasath73/demystifying-kubernetes-requests-and-limits-from-yaml-to-linux-cgroups-c642b7b49b06?source=rss-342ca3cf9604------2</link>
            <guid isPermaLink="false">https://medium.com/p/c642b7b49b06</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cgroup]]></category>
            <category><![CDATA[namespaces]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Arul Prasath Velusamy]]></dc:creator>
            <pubDate>Sun, 14 Sep 2025 07:22:59 GMT</pubDate>
            <atom:updated>2025-09-14T07:39:34.663Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXNN0n7ToLm9NzGxD4ieKw.png" /><figcaption>Image source: For the Love of God, Stop Using CPU Limits on Kubernetes</figcaption></figure><h3>When working with Kubernetes, two fields in a Pod spec often raise questions:</h3><ul><li>resources.requests</li><li>resources.limits</li></ul><p>On the surface, these look simple — “minimum” and “maximum” resource hints. But under the hood, they map directly to Linux kernel primitives (cgroups and the CPU scheduler), which makes them a lot more interesting. Let’s peel this apart.</p><h3>Requests vs Limits in Kubernetes</h3><p>When defining CPU and memory for containers, you’ll usually see something like this:</p><pre>resources:<br>  requests:<br>    cpu: &quot;500m&quot;<br>    memory: &quot;512Mi&quot;<br>  limits:<br>    cpu: &quot;1&quot;<br>    memory: &quot;1Gi&quot;</pre><p><strong>Requests</strong></p><ul><li>Tell the Kubernetes scheduler <em>where</em> to place the Pod.</li><li>Act like a <em>minimum guarantee, </em>the Pod will always get at least this much CPU share or memory reservation.</li></ul><p><strong>Limits</strong></p><ul><li>Act like a ceiling, the container can never consume more than this much.</li><li>For <strong>CPU</strong>: if the process exceeds its allowed quota in the current scheduling window, the kernel will throttle it.</li><li>For <strong>Memory</strong>: if the container tries to go above the limit, it risks being killed by the <strong>OOMKiller</strong>.</li></ul><h3>Linux cgroups</h3><p>Underneath Kubernetes, Linux <strong>control groups</strong> (cgroups) do the heavy lifting.</p><ul><li><strong>Namespaces</strong> = provide isolation (PID tree, network stack, etc.).</li><li><strong>cgroups</strong> = control how much CPU, memory, I/O, and other resources processes can consume.</li></ul><p>They form a tree - a parent can limit all its children together.</p><p>If a parent has 512MB max memory, the sum of its children’s usage can never exceed that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*4HYYq4qmsDX5O-bPNq1VFg.jpeg" /><figcaption>Linux cgroups dividing CPU, memory, network, and storage I/O into isolated groups (#1–#10).</figcaption></figure><h3>CPU Under the Hood (CFS + Weight vs Quotas)</h3><p>Linux uses the <strong>Completely Fair Scheduler (CFS)</strong> with two main knobs:</p><ul><li>cpu.weight (relative share)</li><li>cpu.max (hard cap)</li></ul><p>Kubernetes maps these as follows:</p><ul><li>resources.requests.cpu → <strong>cpu.weight</strong></li><li>Decides how much CPU share a Pod gets compared to others during contention.</li><li>Example: Pod A requests 500m, Pod B requests 500m, Pod C requests 1000m. Then A:B:C get ~25% : 25% : 50% of the CPU when busy.</li><li>resources.limits.cpu → <strong>cpu.max</strong></li><li>Defines the maximum runtime per 100ms period.</li><li>If a container hits this cap, it’s throttled, even if spare CPU is lying idle.</li></ul><h3>Memory Under the Hood</h3><p>For memory, cgroups expose:</p><ul><li>memory.max — maximum memory usage.</li><li>If a container crosses it → Linux OOMKiller may step in.</li></ul><p>Here:</p><ul><li>resources.limits.memory → memory.max</li><li>resources.requests.memory → <em>scheduler hint only</em> (doesn’t affect runtime enforcement).</li></ul><h3>Kubernetes CPU Units vs Linux CPU Shares</h3><ul><li>In Kubernetes: 1 CPU = one vCPU core = 1000 millicores.</li><li>In cgroups: 1 CPU = 1024 shares.</li><li>Mapping: 1000m in Kubernetes ≈ 1024 shares in cgroups.</li></ul><p>So:</p><ul><li>500m = ~512 shares.</li><li>250m = ~256 shares.</li></ul><p>Kubernetes handles this conversion automatically before passing specs to the container runtime (containerd / CRI-O).</p><h3>Lifecycle: Kubernetes → containerd → runc → cgroups</h3><p>When you define resources in a Pod spec, the journey looks like this:</p><ol><li><strong>Kubernetes (API + Scheduler)</strong></li></ol><ul><li>You submit a Pod manifest.</li><li>The Scheduler decides which Node has enough capacity for the Pod (based on <em>requests</em>).</li></ul><p><strong>2. kubelet</strong></p><ul><li>Runs on each Node.</li><li>Passes Pod specs (including resource requests/limits) to the container runtime via the <strong>Container Runtime Interface (CRI)</strong>.</li></ul><p><strong>3. containerd (or CRI-O)</strong></p><ul><li>A container runtime that manages container lifecycle.</li><li>It translates Kubernetes specs into a low-level runtime specification (OCI spec).</li><li>Defines the cgroup configuration (CPU shares, CPU max, memory limits, etc.).</li></ul><p><strong>4. runc</strong></p><ul><li>A lightweight CLI tool that actually spawns the container using Linux namespaces and cgroups.</li><li>runc applies the OCI spec provided by containerd.</li></ul><p><strong>5. cgroups (Linux kernel)</strong></p><ul><li>Enforces the actual limits.</li><li>CPU usage is controlled with cpu.weight and cpu.max.</li><li>Memory usage is controlled with memory.max.</li></ul><p>This flow ensures that what you declare in your Kubernetes YAML is consistently enforced all the way down at the kernel level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MIc1pqx2R33VsmQ7OwPlXA.png" /><figcaption>Image source : A Discussion on Container Runtime — Starting with Dockershim Being Deleted by Kubernetes</figcaption></figure><h3>Closing Summary</h3><p>Kubernetes resource requests and limits are more than just YAML fields — they directly translate into Linux kernel controls. Requests guide scheduling decisions, while limits are enforced at runtime by cgroups. CPU requests become proportional shares, CPU limits become enforced quotas, and memory limits define strict ceilings. Understanding this lifecycle — from Kubernetes API to containerd, runc, and finally cgroups — helps ensure you set the right values for performance and stability.</p><h3><strong>Further Reading: The Debate on CPU Limits in Kubernetes</strong></h3><ul><li><a href="https://home.robusta.dev/blog/stop-using-cpu-limits">https://home.robusta.dev/blog/stop-using-cpu-limits</a></li><li><a href="https://kubernetes.io/blog/2023/11/16/the-case-for-kubernetes-resource-limits/">https://kubernetes.io/blog/2023/11/16/the-case-for-kubernetes-resource-limits/</a></li><li><a href="https://dnastacio.medium.com/why-you-should-keep-using-cpu-limits-on-kubernetes-60c4e50dfc61">https://dnastacio.medium.com/why-you-should-keep-using-cpu-limits-on-kubernetes-60c4e50dfc61</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c642b7b49b06" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>