<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dsplce.co</title>
    <description>The latest articles on DEV Community by dsplce.co (@dsplce-co).</description>
    <link>https://dev.to/dsplce-co</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3980080%2F1fef55d1-b7ab-4758-b48c-b8538b54f525.png</url>
      <title>DEV Community: dsplce.co</title>
      <link>https://dev.to/dsplce-co</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dsplce-co"/>
    <language>en</language>
    <item>
      <title>How to toggle realtime on a table in Supabase migrations</title>
      <dc:creator>dsplce.co</dc:creator>
      <pubDate>Thu, 11 Jun 2026 21:28:54 +0000</pubDate>
      <link>https://dev.to/dsplce-co/how-to-toggle-realtime-on-a-table-in-supabase-migrations-388m</link>
      <guid>https://dev.to/dsplce-co/how-to-toggle-realtime-on-a-table-in-supabase-migrations-388m</guid>
      <description>&lt;p&gt;You set up a table locally, opened it in Supabase Studio, flipped the Realtime toggle on, and everything worked — your frontend was getting live updates, subscriptions firing perfectly. Then you ran &lt;code&gt;supabase db diff&lt;/code&gt;, generated your migration, pushed it all to production… and Realtime is dead. No events, no subscriptions, nothing.&lt;/p&gt;

&lt;p&gt;You check the table — it's there. Columns, RLS policies, indexes, all present. But the Realtime toggle? Off. As if you never touched it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why?
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;supabase db diff&lt;/code&gt; command compares database schemas. Realtime configuration is not a schema change — it's a publication membership. Under the hood, flipping that toggle in Studio just adds your table to a Postgres publication called &lt;code&gt;supabase_realtime&lt;/code&gt;. That's it. And because it's neither a schema change nor a data change, &lt;code&gt;db diff&lt;/code&gt; is completely blind to it. It won't show up in the diff output, and it won't end up in your migration file.&lt;/p&gt;

&lt;p&gt;If you want Realtime to travel with your migrations, you just simply need to write the SQL yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what's the SQL?
&lt;/h2&gt;

&lt;p&gt;It's just one line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="n"&gt;PUBLICATION&lt;/span&gt; &lt;span class="n"&gt;supabase_realtime&lt;/span&gt; &lt;span class="k"&gt;ADD&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That adds your table to the publication. Any client subscribed to it will start receiving changes.&lt;/p&gt;

&lt;p&gt;Multiple tables at once:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="n"&gt;PUBLICATION&lt;/span&gt; &lt;span class="n"&gt;supabase_realtime&lt;/span&gt; &lt;span class="k"&gt;ADD&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;notifications&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removing a table from Realtime:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="n"&gt;PUBLICATION&lt;/span&gt; &lt;span class="n"&gt;supabase_realtime&lt;/span&gt; &lt;span class="k"&gt;DROP&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Turning it into a migration
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;supabase migration new enable_realtime_on_messages
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste the &lt;code&gt;ALTER PUBLICATION&lt;/code&gt; statement into the generated file and you're done. Next time you deploy, the table will be part of the &lt;code&gt;supabase_realtime&lt;/code&gt; publication in the target environment.&lt;/p&gt;

&lt;p&gt;One thing to watch out for — if someone already enabled Realtime on that table manually in production, the migration will fail with a duplicate table error.&lt;/p&gt;

&lt;h2&gt;
  
  
  The faster way — supabase-plus
&lt;/h2&gt;

&lt;p&gt;Keeping track of which tables have Realtime enabled, remembering the publication name, checking the current state before writing the migration — it adds up. &lt;a href="https://github.com/dsplce-co/supabase-plus" rel="noopener noreferrer"&gt;supabase-plus&lt;/a&gt; handles all of that with a single command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sbp manage realtime
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It connects to your local database, lists every table in the schema, and shows you which ones are currently subscribed to &lt;code&gt;supabase_realtime&lt;/code&gt;. From there it's an interactive multi-select — toggle tables on or off, and the tool generates the &lt;code&gt;ALTER PUBLICATION&lt;/code&gt; statements for you, drops them into a timestamped migration file in &lt;code&gt;supabase/migrations/&lt;/code&gt;, and optionally applies the migration to your local database right away.&lt;/p&gt;

&lt;p&gt;You can also scope it to a specific schema:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sbp manage realtime &lt;span class="nt"&gt;--schema&lt;/span&gt; private
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No looking up syntax, no guessing what's already enabled — the tool shows you the state and lets you change it in one step.&lt;/p&gt;

&lt;p&gt;One toggle in Studio, zero lines in your migration history. Now you know how to fix that.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to see running queries in Postgres and kill them</title>
      <dc:creator>dsplce.co</dc:creator>
      <pubDate>Thu, 11 Jun 2026 21:28:08 +0000</pubDate>
      <link>https://dev.to/dsplce-co/how-to-see-running-queries-in-postgres-and-kill-them-j5i</link>
      <guid>https://dev.to/dsplce-co/how-to-see-running-queries-in-postgres-and-kill-them-j5i</guid>
      <description>&lt;p&gt;Something is slow. Maybe a page takes forever to load, maybe a migration is hanging, maybe your Supabase dashboard just spins. You suspect a query is stuck somewhere in your database, but you can't see what's happening — Postgres doesn't exactly surface this on its own.&lt;/p&gt;

&lt;p&gt;Turns out it does. You just need to ask.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seeing what's running
&lt;/h2&gt;

&lt;p&gt;Postgres keeps track of every active connection and what it's doing in a system view called &lt;code&gt;pg_stat_activity&lt;/code&gt;. You can query it like any table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;pid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clock_timestamp&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;query_start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;duration&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;pg_stat_activity&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;state&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s1"&gt;'idle'&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That gives you every non-idle process — its process ID, current state, the SQL it's running, and how long it's been at it. If something has been running for minutes when it should take milliseconds, you've found your problem.&lt;/p&gt;

&lt;p&gt;A few things worth knowing about the columns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;pid&lt;/code&gt; — the process ID, which you'll need if you want to kill it&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;state&lt;/code&gt; — usually &lt;code&gt;active&lt;/code&gt; (running right now), &lt;code&gt;idle in transaction&lt;/code&gt; (sitting inside an open transaction doing nothing), or &lt;code&gt;idle&lt;/code&gt; (waiting for work)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;query&lt;/code&gt; — the actual SQL text&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;query_start&lt;/code&gt; — when the current query began&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to include the user and database to narrow things down:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;pid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;usename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;datname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clock_timestamp&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;query_start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;duration&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;pg_stat_activity&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;state&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s1"&gt;'idle'&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The dangerous one — idle in transaction
&lt;/h2&gt;

&lt;p&gt;An &lt;code&gt;active&lt;/code&gt; query that's been running for a while is usually just slow. An &lt;code&gt;idle in transaction&lt;/code&gt; connection is a different kind of problem — it means someone (or some code) opened a transaction and never committed or rolled it back. The connection is doing nothing, but it's still holding locks, which can block other queries from running.&lt;/p&gt;

&lt;p&gt;These are the ones that tend to cause cascading slowdowns. If you see one that's been sitting there for longer than expected, it's almost certainly a bug in application code — a missing &lt;code&gt;COMMIT&lt;/code&gt;, an unhandled exception that skipped the cleanup, or a connection pool that didn't reclaim the session properly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Killing a process
&lt;/h2&gt;

&lt;p&gt;Once you've identified the offending &lt;code&gt;pid&lt;/code&gt;, you have two options.&lt;/p&gt;

&lt;p&gt;The gentle approach — ask the query to cancel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;pg_cancel_backend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12345&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sends a cancel signal to the running query. If the process is &lt;code&gt;active&lt;/code&gt;, the query stops and the connection goes back to idle. It's the equivalent of hitting Ctrl+C — the session stays alive, no harm done.&lt;/p&gt;

&lt;p&gt;The forceful approach — terminate the connection entirely:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;pg_terminate_backend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12345&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This kills the entire backend process. The connection is dropped, any open transaction is rolled back, and the client gets disconnected. Use this when &lt;code&gt;pg_cancel_backend&lt;/code&gt; doesn't work — which tends to happen with &lt;code&gt;idle in transaction&lt;/code&gt; sessions, since there's no active query to cancel.&lt;/p&gt;

&lt;p&gt;Replace &lt;code&gt;12345&lt;/code&gt; with the actual &lt;code&gt;pid&lt;/code&gt; from your &lt;code&gt;pg_stat_activity&lt;/code&gt; query.&lt;/p&gt;

&lt;h2&gt;
  
  
  Killing in bulk
&lt;/h2&gt;

&lt;p&gt;If you've got several stuck connections and want to clear them all at once:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;pg_terminate_backend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;pg_stat_activity&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'idle in transaction'&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;query_start&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;interval&lt;/span&gt; &lt;span class="s1"&gt;'5 minutes'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That terminates every connection that's been idle in a transaction for more than five minutes. Adjust the interval to taste.&lt;/p&gt;

&lt;h2&gt;
  
  
  On Supabase specifically
&lt;/h2&gt;

&lt;p&gt;If you're on Supabase, you can run all of this through the SQL Editor in the dashboard. The same &lt;code&gt;pg_stat_activity&lt;/code&gt; view is available, and &lt;code&gt;pg_cancel_backend&lt;/code&gt; / &lt;code&gt;pg_terminate_backend&lt;/code&gt; both work. No extra permissions needed — the default &lt;code&gt;postgres&lt;/code&gt; role has access.&lt;/p&gt;

&lt;p&gt;One thing to keep in mind: Supabase runs background processes for Realtime, Auth, and PostgREST. You'll see these in &lt;code&gt;pg_stat_activity&lt;/code&gt; too. Don't kill them — they'll usually show up with usernames like &lt;code&gt;supabase_admin&lt;/code&gt; or &lt;code&gt;authenticator&lt;/code&gt;. Stick to terminating connections from your own application's role.&lt;/p&gt;

</description>
      <category>database</category>
      <category>performance</category>
      <category>postgres</category>
      <category>sql</category>
    </item>
    <item>
      <title>Kubernetes kills your pod? Here's why</title>
      <dc:creator>dsplce.co</dc:creator>
      <pubDate>Thu, 11 Jun 2026 21:27:31 +0000</pubDate>
      <link>https://dev.to/dsplce-co/kubernetes-kills-your-pod-heres-why-25a7</link>
      <guid>https://dev.to/dsplce-co/kubernetes-kills-your-pod-heres-why-25a7</guid>
      <description>&lt;p&gt;Your pods keep getting killed. Not crashing — killed. One moment they're running fine, the next they're gone and Kubernetes is spinning up replacements. You check the logs and there's nothing useful. The pod just… disappeared.&lt;/p&gt;

&lt;p&gt;Turns out Kubernetes killed it on purpose. And if you don't tell it how much memory your app actually needs, it'll keep doing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Kubernetes evicts pods
&lt;/h2&gt;

&lt;p&gt;Kubernetes runs on nodes — physical or virtual machines that host your containers. Each node has a finite amount of CPU and memory. When a node runs low on resources, Kubernetes has to make a choice: which pods stay, and which ones get evicted to free up space.&lt;/p&gt;

&lt;p&gt;The decision comes down to QoS classes — Quality of Service tiers that Kubernetes assigns to every pod based on how you've configured resource requests and limits.&lt;/p&gt;

&lt;p&gt;There are three classes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;BestEffort&lt;/strong&gt; — no resource requests or limits defined. Kubernetes has no idea how much CPU or memory the pod needs. These get killed first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Burstable&lt;/strong&gt; — requests and limits are defined, but they're different (e.g., &lt;code&gt;requests: 256Mi&lt;/code&gt;, &lt;code&gt;limits: 512Mi&lt;/code&gt;). The pod is guaranteed the request amount, but can burst up to the limit. Killed second.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Guaranteed&lt;/strong&gt; — requests and limits are set to the same value. Kubernetes reserves exactly that amount of resources for the pod. Killed last.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your pods don't have resource configuration at all, they're running as BestEffort. And when the node hits memory pressure, BestEffort pods are the first to go — no questions asked.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Guaranteed class
&lt;/h2&gt;

&lt;p&gt;Setting your pod to the Guaranteed class is one line in your deployment config. Define &lt;code&gt;requests&lt;/code&gt; and &lt;code&gt;limits&lt;/code&gt; for both CPU and memory, and make them identical:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;512Mi"&lt;/span&gt;
    &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;500m"&lt;/span&gt;
  &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;512Mi"&lt;/span&gt;
    &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;500m"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Kubernetes now knows this pod needs exactly 512 MiB of RAM and half a CPU core, and it reserves that capacity when scheduling the pod onto a node. If a node doesn't have 512 MiB available, the pod won't be placed there. And if the node runs into memory pressure later, this pod gets evicted last — only after all BestEffort and Burstable pods are gone.&lt;/p&gt;

&lt;h2&gt;
  
  
  The side effect — better autoscaling
&lt;/h2&gt;

&lt;p&gt;On managed Kubernetes platforms like &lt;a href="https://aws.amazon.com/eks/" rel="noopener noreferrer"&gt;EKS&lt;/a&gt;, this has a second benefit: the cluster autoscaler pays attention to resource requests when deciding whether to add new nodes.&lt;/p&gt;

&lt;p&gt;If your pods are BestEffort (no resource config), the autoscaler sees them as requiring zero resources. Ten pods running on a single node looks fine to it, even if that node is at 90% memory usage. It won't spin up a new node because, from its perspective, there's no unmet resource demand.&lt;/p&gt;

&lt;p&gt;But if those same pods are Guaranteed with &lt;code&gt;requests: 512Mi&lt;/code&gt;, and the current node doesn't have 512 MiB free, the autoscaler sees a pod that can't be scheduled and adds a new node to accommodate it. Your pods start spreading across multiple nodes instead of piling up on one.&lt;/p&gt;

&lt;p&gt;This is particularly rigid on EKS — other Kubernetes providers are a bit more lenient, but EKS strictly follows the scheduler's resource calculations. If you don't define requests, autoscaling won't trigger, and you'll end up with all your pods crammed onto a single node until it runs out of memory and starts evicting things.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trade-off
&lt;/h2&gt;

&lt;p&gt;The downside of Guaranteed is that you're committing to a specific memory limit. If your app grows and starts using more than what you've configured, the pod gets OOMKilled (out-of-memory killed) instead of being allowed to burst beyond the limit.&lt;/p&gt;

&lt;p&gt;With Burstable, you could set &lt;code&gt;requests: 256Mi&lt;/code&gt; and &lt;code&gt;limits: 1Gi&lt;/code&gt;, giving the app room to spike without getting killed. But you lose the scheduling guarantees — Kubernetes only reserves the 256 MiB request amount, so the pod might end up on a node that doesn't have the full gigabyte available.&lt;/p&gt;

&lt;p&gt;Guaranteed means you need to monitor memory usage and bump the limit when your app legitimately needs more. It's a bit more maintenance, but in exchange you get predictable scheduling, protection from eviction, and autoscaling that actually works.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to set it
&lt;/h2&gt;

&lt;p&gt;In your Kubernetes deployment manifest, add the &lt;code&gt;resources&lt;/code&gt; block under &lt;code&gt;containers&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;your-app&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;your-image:latest&lt;/span&gt;
        &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;512Mi"&lt;/span&gt;
            &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;500m"&lt;/span&gt;
          &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;512Mi"&lt;/span&gt;
            &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;500m"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apply it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; deployment.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the QoS class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pod &amp;lt;pod-name&amp;gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;jsonpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{.status.qosClass}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it says &lt;code&gt;Guaranteed&lt;/code&gt;, you're set.&lt;/p&gt;

&lt;h2&gt;
  
  
  Picking the right values
&lt;/h2&gt;

&lt;p&gt;Start by looking at what your pods are actually using. Get current memory consumption:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl top pods
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take the highest value you see, add 20-30% headroom, and use that as your request and limit. If a pod is sitting at 400 MiB, set it to 512 MiB. If it's consistently hitting 800 MiB, go with 1 GiB.&lt;/p&gt;

&lt;p&gt;For CPU, half a core (&lt;code&gt;500m&lt;/code&gt;) is a reasonable starting point for most apps. Bump it if you see CPU throttling in your metrics.&lt;/p&gt;

&lt;p&gt;And then monitor. If you see OOMKills in the pod events, the limit is too low — increase it. If memory usage grows over time as you ship new features, update the config to match.&lt;/p&gt;

&lt;p&gt;Kubernetes won't kill your pods arbitrarily once they're Guaranteed. But you have to tell it what "guaranteed" actually means.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>infrastructure</category>
      <category>kubernetes</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
