<?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: Keshav</title>
    <description>The latest articles on DEV Community by Keshav (@keshav_af7403d92948605d98).</description>
    <link>https://dev.to/keshav_af7403d92948605d98</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3469302%2F8e07a423-e227-498e-a7a6-3bef3afc7b3c.png</url>
      <title>DEV Community: Keshav</title>
      <link>https://dev.to/keshav_af7403d92948605d98</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/keshav_af7403d92948605d98"/>
    <language>en</language>
    <item>
      <title>How to Protect Your Systems with Throttling &amp; Rate Limiting - 5 Real-World Use Cases</title>
      <dc:creator>Keshav</dc:creator>
      <pubDate>Tue, 27 Oct 2026 14:17:25 +0000</pubDate>
      <link>https://dev.to/keshav_af7403d92948605d98/how-to-protect-your-systems-with-throttling-rate-limiting-5-real-world-use-cases-10k5</link>
      <guid>https://dev.to/keshav_af7403d92948605d98/how-to-protect-your-systems-with-throttling-rate-limiting-5-real-world-use-cases-10k5</guid>
      <description>&lt;h1&gt;
  
  
  Throttling &amp;amp; Rate Limiting: 5 Real‑World Use Cases
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; – Throttling is a defensive technique that controls the flow of requests to a target system, preventing overload, abuse, and costly spikes. By combining &lt;em&gt;slowing down&lt;/em&gt;, &lt;em&gt;rejecting&lt;/em&gt;, and &lt;em&gt;ignoring&lt;/em&gt; strategies, you can protect both public APIs and internal services. Below are five practical scenarios where rate limiting shines, from stopping DoS attacks to rationing expensive third‑party calls.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. What Is Throttling?
&lt;/h2&gt;

&lt;p&gt;Throttling is the process of &lt;strong&gt;ensuring that data requests are forwarded to a target system at an acceptable rate&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
When many users or subsystems send traffic to a single machine, a &lt;strong&gt;rate limiter&lt;/strong&gt; acts as a gatekeeper:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Buffering&lt;/strong&gt; – Drips requests slowly so the target never gets overwhelmed.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rejecting&lt;/strong&gt; – Drops requests that exceed capacity, returning an error (e.g., &lt;code&gt;429 Too Many Requests&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ignoring&lt;/strong&gt; – Silently discards requests but still returns a success response to the caller, useful for stealthy abuse mitigation.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Why it matters:&lt;/em&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prevents system crashes from sudden traffic spikes.
&lt;/li&gt;
&lt;li&gt;Keeps costs predictable by limiting compute usage.
&lt;/li&gt;
&lt;li&gt;Avoids cascading failures across dependent services.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  2. Why Do We Need Throttling?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Reason&lt;/th&gt;
&lt;th&gt;What It Protects&lt;/th&gt;
&lt;th&gt;Typical Scenario&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Prevent abuse&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;System uptime&lt;/td&gt;
&lt;td&gt;Rogue users hammering an API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Handle legitimate surges&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;User experience&lt;/td&gt;
&lt;td&gt;Viral traffic spikes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Control consumption cost&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Budget&lt;/td&gt;
&lt;td&gt;Expensive compute or third‑party calls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Avoid cascading failures&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;System stability&lt;/td&gt;
&lt;td&gt;One service overloads another&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  3. Throttling Strategies
&lt;/h2&gt;

&lt;h3&gt;
  
  
  3.1 Slowing Down (Buffering)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mechanism&lt;/strong&gt;: Queue requests and release them at a steady pace.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example&lt;/strong&gt;: Message brokers like &lt;strong&gt;SQS&lt;/strong&gt; or &lt;strong&gt;RabbitMQ&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benefit&lt;/strong&gt;: Keeps the consumer at a comfortable load level.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Incoming requests → Rate Limiter (queue) → Consumer (drips at 10 req/s)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.2 Rejecting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mechanism&lt;/strong&gt;: Drop excess requests outright.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example&lt;/strong&gt;: API servers capped at 100 req/s.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benefit&lt;/strong&gt;: No buffering, clear feedback (&lt;code&gt;429&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3.3 Ignoring
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mechanism&lt;/strong&gt;: Silently drop requests but return a success status.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use‑case&lt;/strong&gt;: Deceptive DoS mitigation—attackers think they succeeded.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benefit&lt;/strong&gt;: Keeps traffic patterns normal for monitoring tools.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4. Five Real‑World Use Cases
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.1 External Rate Limiter – Prevent Catastrophic DoS Attacks
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What&lt;/strong&gt;: All incoming traffic hits a rate limiter before reaching your services.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How&lt;/strong&gt;: Configure rules to block IPs, tokens, or user agents that exceed thresholds.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Result&lt;/strong&gt;: Attack traffic is dropped; legitimate traffic flows normally.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Example AWS API Gateway rate limit rule&lt;/span&gt;
&lt;span class="na"&gt;throttle&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;burst&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;
  &lt;span class="na"&gt;rate&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;
  &lt;span class="na"&gt;ip_whitelist&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;192.168.1.0/24"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4.2 External Rate Limiter – Gracefully Handle User Surges
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What&lt;/strong&gt;: A sudden influx of legitimate users (e.g., after a viral tweet).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How&lt;/strong&gt;: Allow a subset of requests to pass while dropping the rest.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Result&lt;/strong&gt;: The system stays responsive for some users; others receive a friendly “try again later” message instead of a hard 503.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  4.3 Internal Rate Limiter – Ration Compute for Tiered Pricing
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Scenario&lt;/strong&gt;: A CI/CD platform (e.g., CircleCI) offers free, paid, and unlimited tiers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What&lt;/strong&gt;: Before launching a build job, the API server checks the user’s quota.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How&lt;/strong&gt;: The rate limiter consults a database of consumed minutes.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Result&lt;/strong&gt;: Users stay within their allocated build time; over‑usage is blocked.
&lt;/li&gt;
&lt;/ul&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="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;build_minutes&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;builds&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;window_start&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4.4 Internal Rate Limiter – Avoid Over‑Using Expensive Third‑Party APIs
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Scenario&lt;/strong&gt;: Your service calls a paid ML API that costs $5 per request.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What&lt;/strong&gt;: Workers consult a rate limiter before each external call.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How&lt;/strong&gt;: The limiter enforces a daily or hourly cap.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Result&lt;/strong&gt;: You stay within budget and avoid unexpected bill spikes.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rate_limiter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;allow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ml_api&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ml_api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Rate limit exceeded&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4.5 Internal Rate Limiter – Protect Unprotected Systems (e.g., Hard Deletes)
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Scenario&lt;/strong&gt;: Deleting millions of rows in a single query can lock tables and crash the DB.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What&lt;/strong&gt;: Split the delete into smaller batches.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How&lt;/strong&gt;: Use a scheduler or a rate limiter to pace the deletes.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Result&lt;/strong&gt;: The database remains responsive; the operation completes without downtime.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'2024-01-01'&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;-- run every minute&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5. Key Takeaways
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Takeaway&lt;/th&gt;
&lt;th&gt;Why It Matters&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Rate limiting is not just for APIs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Internal services, third‑party calls, and even database operations benefit from controlled traffic.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Choose the right strategy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Buffering for smooth load, rejecting for hard caps, ignoring for stealthy defense.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Combine external &amp;amp; internal limits&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Protect the edge of your system &lt;em&gt;and&lt;/em&gt; the core of your infrastructure.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tie limits to business logic&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tiered pricing, cost controls, and SLA guarantees all rely on well‑configured throttling.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Monitor &amp;amp; adjust&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Traffic patterns change; keep your limits tuned to real usage.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;By integrating thoughtful throttling mechanisms, you can keep your services robust, cost‑effective, and user‑friendly—even under the most demanding conditions. Happy throttling!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>technology</category>
      <category>programming</category>
      <category>python</category>
    </item>
  </channel>
</rss>
