<?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 Vieveganthaneswaran on Medium]]></title>
        <description><![CDATA[Stories by Vieveganthaneswaran on Medium]]></description>
        <link>https://medium.com/@vieveganthaneswaran?source=rss-357a5e56ac8d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xr-EnMp5745qHbYA</url>
            <title>Stories by Vieveganthaneswaran on Medium</title>
            <link>https://medium.com/@vieveganthaneswaran?source=rss-357a5e56ac8d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 22:55:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vieveganthaneswaran/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[ The Complete Design Pattern Diagnostic Framework]]></title>
            <link>https://medium.com/@vieveganthaneswaran/the-complete-design-pattern-diagnostic-framework-c9a0d7fc9a14?source=rss-357a5e56ac8d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9a0d7fc9a14</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Vieveganthaneswaran]]></dc:creator>
            <pubDate>Fri, 20 Feb 2026 08:36:41 GMT</pubDate>
            <atom:updated>2026-02-20T08:36:41.728Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 1: Creation Patterns — “How do I build this object?”</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QRXVptd_95BQQRBNBqwoQA.png" /></figure><h3>🚨 The Creation Problem</h3><p><strong>You’re staring at a constructor and something feels wrong:</strong></p><pre>// What is all this? Which parameter is which?<br>new Pizza(12, true, false, true, false, 2, &quot;cheese&quot;, null, true, false);</pre><p>Or maybe:</p><pre>// Why is this so slow?<br>for (int i = 0; i &lt; 1000; i++) {<br>    Enemy enemy = new Enemy();  // 2 seconds each! 😱<br>}</pre><p>Or perhaps:</p><pre>// This switch is EVERYWHERE!<br>if (type.equals(&quot;EMAIL&quot;)) {<br>    return new EmailNotification();<br>} else if (type.equals(&quot;SMS&quot;)) {<br>    return new SMSNotification();<br>}</pre><p><strong>You have a CREATION problem.</strong></p><p>But which pattern solves it? Let’s diagnose.</p><h3>🌳 The Creation Decision Tree</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nQguMzMCqW61QTJObtVY_w.png" /></figure><h3>✅ When to Use It</h3><p><strong>The One Question:</strong> <em>“Does this object require step-by-step construction with many optional parameters?”</em></p><h3>💡 The Problem</h3><pre>// ❌ BAD: Telescoping constructors - Which is which?!<br>Pizza pizza = new Pizza(12, true, false, true, &quot;thin&quot;, &quot;cheese&quot;, 2);<br>// Wait... is &quot;cheese&quot; the 5th or 6th parameter? 😕</pre><h3>✅ The Solution (Basic Java)</h3><pre>// The Product - Immutable<br>public class Pizza {<br>    private final int size;<br>    private final boolean cheese;<br>    private final boolean pepperoni;<br>    private final String crust;<br>    <br>    private Pizza(PizzaBuilder builder) {<br>        this.size = builder.size;<br>        this.cheese = builder.cheese;<br>        this.pepperoni = builder.pepperoni;<br>        this.crust = builder.crust;<br>    }<br>    <br>    // Static nested Builder<br>    public static class PizzaBuilder {<br>        // Required parameters<br>        private final int size;<br>        <br>        // Optional parameters - with defaults<br>        private boolean cheese = false;<br>        private boolean pepperoni = false;<br>        private String crust = &quot;regular&quot;;<br>        <br>        public PizzaBuilder(int size) {<br>            this.size = size;<br>        }<br>        <br>        public PizzaBuilder withCheese(boolean cheese) {<br>            this.cheese = cheese;<br>            return this;<br>        }<br>        <br>        public PizzaBuilder withPepperoni(boolean pepperoni) {<br>            this.pepperoni = pepperoni;<br>            return this;<br>        }<br>        <br>        public PizzaBuilder withCrust(String crust) {<br>            this.crust = crust;<br>            return this;<br>        }<br>        <br>        public Pizza build() {<br>            return new Pizza(this);<br>        }<br>    }<br>}</pre><pre>// 🎯 Client code - Beautiful and clear!<br>Pizza pizza = new Pizza.PizzaBuilder(12)<br>    .withCheese(true)<br>    .withPepperoni(true)<br>    .withCrust(&quot;thin&quot;)<br>    .build();</pre><h3>🎯 Conceptual Understanding</h3><p><strong>Builder is like ordering at Subway:</strong></p><ul><li>You MUST choose bread size (required parameter in constructor)</li><li>Everything else is optional (cheese, toasted, veggies)</li><li>The sandwich artist builds it step by step</li><li>You can’t change it once built (immutable)</li></ul><h3>📋 Pattern 2: PROTOTYPE</h3><h3>✅ When to Use It</h3><p><strong>The One Question:</strong> <em>“Is creating new objects more expensive than cloning existing ones?”</em></p><h3>💡 The Problem</h3><pre>// ❌ BAD: Creating 1000 enemies = 1000 expensive operations<br>for (int i = 0; i &lt; 1000; i++) {<br>    Enemy enemy = new Enemy();  // Loads texture, AI, stats from disk! (2 seconds each)<br>    game.add(enemy);  // 2000 seconds total! 😱<br>}</pre><h3>✅ The Solution (Basic Java)</h3><pre>// Step 1: Implement Cloneable<br>public abstract class Enemy implements Cloneable {<br>    protected String name;<br>    protected int health;<br>    protected byte[] texture;  // Expensive to load!<br>    <br>    public Enemy() {<br>        // Expensive operations here<br>        loadTextureFromDisk();<br>        initializeAI();<br>    }<br>    <br>    @Override<br>    public Enemy clone() {<br>        try {<br>            Enemy cloned = (Enemy) super.clone();<br>            // Deep copy mutable fields<br>            cloned.texture = this.texture.clone();<br>            return cloned;<br>        } catch (CloneNotSupportedException e) {<br>            throw new RuntimeException(e);<br>        }<br>    }<br>}</pre><pre>// Step 2: Concrete prototype<br>public class Orc extends Enemy {<br>    public Orc() {<br>        super();<br>        this.name = &quot;Orc&quot;;<br>        this.health = 100;<br>    }<br>}</pre><pre>// Step 3: Prototype registry<br>public class EnemyRegistry {<br>    private Map&lt;String, Enemy&gt; prototypes = new HashMap&lt;&gt;();<br>    <br>    public EnemyRegistry() {<br>        // Load prototypes ONCE<br>        prototypes.put(&quot;orc&quot;, new Orc());  // Expensive, but happens once<br>    }<br>    <br>    public Enemy createEnemy(String type) {<br>        return prototypes.get(type).clone();  // Cheap!<br>    }<br>}</pre><pre>// 🎯 Client code<br>EnemyRegistry registry = new EnemyRegistry();  // Expensive setup once<br>List&lt;Enemy&gt; horde = new ArrayList&lt;&gt;();<br>for (int i = 0; i &lt; 1000; i++) {<br>    horde.add(registry.createEnemy(&quot;orc&quot;));  // Each clone is cheap!<br>}</pre><h3>🎯 Conceptual Understanding</h3><p><strong>Prototype is like a cookie cutter:</strong></p><ul><li>Make ONE master cookie (expensive, detailed)</li><li>Use it to stamp out many identical cookies (cheap)</li><li>Each cookie can still be decorated differently</li></ul><p><strong>⚠️ Critical: Shallow vs Deep Clone</strong></p><pre>// Shallow clone - References shared! 💥<br>cloned.list = original.list;  // Changes affect both!</pre><pre>// Deep clone - Independent copy ✅<br>cloned.list = new ArrayList&lt;&gt;(original.list);</pre><h3>🔁 Pattern 3: OBJECT POOL</h3><h3>✅ When to Use It</h3><p><strong>The One Question:</strong> <em>“Is acquiring/releasing these resources expensive and limited?”</em></p><h3>💡 The Problem</h3><pre>// ❌ BAD: Each request opens a new database connection<br>public void handleRequest() {<br>    Connection conn = new DatabaseConnection();  // TCP handshake, auth (200ms!)<br>    conn.query(&quot;...&quot;);<br>    conn.close();  // Tears down (100ms!)<br>}<br>// 1000 requests = 300,000ms = 5 minutes just in connection overhead! 😱</pre><h3>✅ The Solution (Basic Java)</h3><pre>public class ConnectionPool {<br>    private List&lt;Connection&gt; available = new ArrayList&lt;&gt;();<br>    private List&lt;Connection&gt; inUse = new ArrayList&lt;&gt;();<br>    private final int MAX_SIZE = 10;<br>    <br>    public ConnectionPool() {<br>        // Pre-create connections<br>        for (int i = 0; i &lt; 5; i++) {<br>            available.add(new DatabaseConnection());  // Expensive, but done once<br>        }<br>    }<br>    <br>    public synchronized Connection getConnection() {<br>        if (available.isEmpty()) {<br>            if (inUse.size() &lt; MAX_SIZE) {<br>                available.add(new DatabaseConnection());  // Create new if under limit<br>            } else {<br>                throw new RuntimeException(&quot;Max connections reached&quot;);<br>            }<br>        }<br>        Connection conn = available.remove(available.size() - 1);<br>        inUse.add(conn);<br>        return conn;<br>    }<br>    <br>    public synchronized void releaseConnection(Connection conn) {<br>        inUse.remove(conn);<br>        available.add(conn);<br>    }<br>}</pre><pre>// 🎯 Client code with try-with-resources<br>try (Connection conn = pool.getConnection()) {<br>    conn.query(&quot;SELECT * FROM users&quot;);  // Reused connection<br>} // Auto-closed and returned to pool</pre><h3>🎯 Conceptual Understanding</h3><p><strong>Object Pool is like a car rental service:</strong></p><ul><li>Maintaining a fleet of cars is expensive</li><li>Customers rent, use, return (don’t buy new each time)</li><li>Limited number available at once</li></ul><h3>🏭 Pattern 4: FACTORY METHOD</h3><h3>✅ When to Use It</h3><p><strong>The One Question:</strong> <em>“Does the client not know the exact type until runtime?”</em></p><h3>💡 The Problem</h3><pre>// ❌ BAD: Switch statements EVERYWHERE<br>Notification notification;<br>if (type.equals(&quot;EMAIL&quot;)) {<br>    notification = new EmailNotification();<br>} else if (type.equals(&quot;SMS&quot;)) {<br>    notification = new SMSNotification();<br>}<br>// This appears in 47 files! If you add PUSH, change 47 files! 😱</pre><h3>✅ The Solution (Basic Java)</h3><pre>// Step 1: Product interface<br>public interface Notification {<br>    void send(String message);<br>}</pre><pre>// Step 2: Concrete products<br>public class EmailNotification implements Notification {<br>    public void send(String message) {<br>        System.out.println(&quot;Sending email: &quot; + message);<br>    }<br>}</pre><pre>public class SMSNotification implements Notification {<br>    public void send(String message) {<br>        System.out.println(&quot;Sending SMS: &quot; + message);<br>    }<br>}</pre><pre>// Step 3: Factory interface<br>public abstract class NotificationFactory {<br>    public abstract Notification createNotification();<br>    <br>    public void sendNotification(String message) {<br>        Notification notification = createNotification();<br>        notification.send(message);<br>    }<br>}</pre><pre>// Step 4: Concrete factories<br>public class EmailNotificationFactory extends NotificationFactory {<br>    @Override<br>    public Notification createNotification() {<br>        return new EmailNotification();<br>    }<br>}</pre><pre>public class SMSNotificationFactory extends NotificationFactory {<br>    @Override<br>    public Notification createNotification() {<br>        return new SMSNotification();<br>    }<br>}</pre><pre>// 🎯 Client code<br>NotificationFactory factory;<br>if (user.prefersEmail()) {<br>    factory = new EmailNotificationFactory();<br>} else {<br>    factory = new SMSNotificationFactory();<br>}<br>factory.sendNotification(&quot;Hello!&quot;);  // Creates right type automatically</pre><h3>🎯 Conceptual Understanding</h3><p><strong>Factory Method is like a restaurant kitchen:</strong></p><ul><li>You order “dessert” (abstract product)</li><li>Kitchen decides to give you cake or ice cream (concrete product)</li><li>You don’t care how it’s made, just that you get it</li></ul><h3>🏭🏭 Pattern 5: ABSTRACT FACTORY</h3><h3>✅ When to Use It</h3><p><strong>The One Question:</strong> <em>“Do you need FAMILIES of related objects that must work together?”</em></p><h3>💡 The Problem</h3><pre>// ❌ BAD: Mixing families causes bugs!<br>Button button = new WindowsButton();<br>Checkbox checkbox = new MacCheckbox();  // 💥 Mac checkbox on Windows button!</pre><h3>✅ The Solution (Basic Java)</h3><pre>// Step 1: Abstract products<br>public interface Button {<br>    void render();<br>}</pre><pre>public interface Checkbox {<br>    void render();<br>}</pre><pre>// Step 2: Concrete products for Windows family<br>public class WindowsButton implements Button {<br>    public void render() { System.out.println(&quot;Windows button&quot;); }<br>}</pre><pre>public class WindowsCheckbox implements Checkbox {<br>    public void render() { System.out.println(&quot;Windows checkbox&quot;); }<br>}</pre><pre>// Step 3: Concrete products for Mac family<br>public class MacButton implements Button {<br>    public void render() { System.out.println(&quot;Mac button&quot;); }<br>}</pre><pre>public class MacCheckbox implements Checkbox {<br>    public void render() { System.out.println(&quot;Mac checkbox&quot;); }<br>}</pre><pre>// Step 4: THE ABSTRACT FACTORY<br>public interface UIFactory {<br>    Button createButton();<br>    Checkbox createCheckbox();<br>}</pre><pre>// Step 5: Concrete factories<br>public class WindowsUIFactory implements UIFactory {<br>    public Button createButton() { return new WindowsButton(); }<br>    public Checkbox createCheckbox() { return new WindowsCheckbox(); }<br>}</pre><pre>public class MacUIFactory implements UIFactory {<br>    public Button createButton() { return new MacButton(); }<br>    public Checkbox createCheckbox() { return new MacCheckbox(); }<br>}</pre><pre>// 🎯 Client code<br>UIFactory factory;<br>if (Platform.current() == Platform.WINDOWS) {<br>    factory = new WindowsUIFactory();<br>} else {<br>    factory = new MacUIFactory();<br>}</pre><pre>Button button = factory.createButton();<br>Checkbox checkbox = factory.createCheckbox();</pre><h3>🎯 Conceptual Understanding</h3><p><strong>Abstract Factory is like IKEA vs Ashley Furniture:</strong></p><ul><li>IKEA: All furniture matches (same style)</li><li>Ashley: Different style</li><li>You don’t mix because they won’t match</li></ul><h3>1️⃣ Pattern 6: SINGLETON</h3><h3>✅ When to Use It</h3><p><strong>The One Question:</strong> <em>“Must there be exactly ONE instance globally?”</em></p><h3>PoolDo you need lazy initialization?➡️ <strong>SINGLETON</strong>Eager initialization</h3><h3>💡 The Problem</h3><pre>// ❌ BAD: Multiple loggers, multiple files!<br>Logger logger1 = new Logger();  // Opens &quot;app.log&quot;<br>Logger logger</pre><p>2 = new Logger(); // Also opens “app.log” — collision!</p><pre>## ✅ The Solution (Basic Java)</pre><pre>```java<br>public class Logger {<br>    private static Logger instance;<br>    <br>    private Logger() {<br>        // Private constructor<br>    }<br>    <br>    public static synchronized Logger getInstance() {<br>        if (instance == null) {<br>            instance = new Logger();<br>        }<br>        return instance;<br>    }<br>    <br>    public void log(String message) {<br>        System.out.println(message);<br>    }<br>}</pre><pre>// 🎯 Client code<br>Logger logger = Logger.getInstance();<br>logger.log(&quot;Singleton in action!&quot;);</pre><h3>🎯 Summary</h3><ul><li><strong>Creation patterns</strong> solve problems around <em>how objects are created</em>.</li><li>Ask the <strong>right diagnostic questions</strong> before picking a pattern.</li><li><strong>Builder</strong> = step-by-step, complex objects</li><li><strong>Prototype</strong> = expensive objects that can be cloned</li><li><strong>Object Pool</strong> = expensive, limited resources reused</li><li><strong>Factory Method</strong> = runtime type choice</li><li><strong>Abstract Factory</strong> = family of compatible objects</li><li><strong>Singleton</strong> = exactly one global instance</li></ul><p>✅ Armed with this framework, you can confidently pick the right creation pattern <strong>without guessing</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9a0d7fc9a14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rate Limiting Explained: A Complete Conceptual Guide Using a Movie Ticket Booking Example]]></title>
            <link>https://medium.com/@vieveganthaneswaran/rate-limiting-explained-a-complete-conceptual-guide-using-a-movie-ticket-booking-example-8badbd042afd?source=rss-357a5e56ac8d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8badbd042afd</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[rate-limiting]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Vieveganthaneswaran]]></dc:creator>
            <pubDate>Wed, 11 Feb 2026 04:52:24 GMT</pubDate>
            <atom:updated>2026-02-11T04:52:24.749Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XVSMBkizkzzGMuBWhxpkww.png" /></figure><p>If you’ve ever built an API, you’ve probably heard this sentence:</p><blockquote><em>“We need to add rate limiting.”</em></blockquote><p>Most developers nod, add a library, set “100 requests per minute,” and move on.</p><p>But rate limiting is much deeper than that.</p><p>It’s not just a security feature.<br>It’s not just about blocking users.<br>And it’s definitely not just “requests per minute.”</p><p>This article is a concept-only, end-to-end guide to rate limiting, with a real-world movie ticket booking example:</p><ul><li>What problem rate limiting solves</li><li>How different rate-limiting strategies work</li><li>Burst limits, fairness, and UX trade-offs</li><li>Where rate limiting lives in real systems</li></ul><p>No code. No math. Just understanding.</p><h3>What Is Rate Limiting, Really?</h3><p>At its core, rate limiting controls how frequently an action can happen.</p><p>In APIs, that usually means:</p><blockquote><em>Limiting how many requests a client can make in a given period of time.</em></blockquote><p>But conceptually, rate limiting answers three questions:</p><blockquote><em>Who is making the request?<br>How many requests are allowed?<br>Over what time period?</em></blockquote><p>Every rate-limiting system — no matter how complex — boils down to this.</p><h3>Why Rate Limiting Exists (Beyond “Security”)</h3><p>Many people think rate limiting exists only to stop attackers. That’s only part of the story.</p><h3>Rate limiting exists to:</h3><ul><li>Protect servers from overload</li><li>Prevent one user from degrading others’ experience</li><li>Keep response times predictable</li><li>Control costs (CPU, DB, third-party APIs)</li><li>Shape traffic into manageable patterns</li></ul><p>In short:</p><blockquote><em>Rate limiting is about system survival and fairness.</em></blockquote><p>Even legitimate traffic can crash a system if it’s unbounded.</p><p>Example: Imagine a movie ticket booking API. On a Friday evening, 10,000 users hit the /book-ticket endpoint simultaneously. Without rate limiting, the server could crash, leaving everyone frustrated.</p><h3>How Systems Identify “Who” to Limit</h3><p>Rate limits are always tied to an identity, like:</p><ul><li>IP address</li><li>User ID (after login)</li><li>API key</li><li>Device ID</li></ul><p>Example: In our movie ticket system, rate limiting by user ID ensures one user doesn’t book hundreds of seats in seconds, while IP-based limiting prevents a single network from overwhelming the system.</p><h3>Fixed Window Rate Limiting (The Simplest Form)</h3><p>A naïve rule:</p><blockquote><em>“Allow 100 requests per minute.”</em></blockquote><h3>How it works</h3><p>Requests are counted in fixed time windows.<br>At the end of the window, the counter resets.</p><h3>Problem</h3><p>Users can game the system at window boundaries.</p><p>Example: A user sends 100 requests at 11:59:59 PM, then another 100 at 12:00:00 AM. That’s 200 requests in a fraction of a second — potentially booking more seats than allowed.</p><h3>Sliding Window Rate Limiting (Fairness Over Time)</h3><p>Sliding window rate limiting improves on fixed windows.</p><p>Instead of counting requests per clock minute, it counts requests in the last N seconds, continuously moving forward.</p><h3>Why it matters</h3><ul><li>Eliminates boundary abuse</li><li>Enforces fairness continuously</li></ul><p>Movie ticket example: If a user tries to refresh the booking page repeatedly in 1 minute, the system counts requests in the last 60 seconds. Only the allowed number of bookings go through, preventing abuse but still allowing fair users to book tickets.</p><h3>Token Bucket Rate Limiting (The Most Practical Model)</h3><p>Token bucket is the most widely used mental model in real systems.</p><h3>Core idea</h3><ul><li>The system gives each user a bucket of tokens</li><li>Tokens refill steadily over time</li><li>Each booking consumes a token</li><li>If no tokens remain, the request is rejected</li></ul><h3>Key insight</h3><blockquote><em>Bucket size = burst limit<br>Refill rate = sustained rate</em></blockquote><p>Movie ticket example:</p><ul><li>Each user can book up to 5 tickets instantly (bucket size = 5).</li><li>After that, the bucket refills at 1 ticket per minute (refill rate).</li><li>This allows users to book a small burst of tickets quickly, but prevents a single user from booking 100 tickets at once.</li></ul><h3>Leaky Bucket Rate Limiting (Traffic Shaping)</h3><p>Leaky bucket behaves differently.</p><ul><li>Requests enter a queue</li><li>Requests leave at a fixed rate</li><li>If the queue is full, new requests are dropped</li></ul><h3>Key characteristic</h3><ul><li>No bursts allowed</li><li>Traffic is smoothed aggressively</li></ul><p>Movie ticket example: If 10 users try to book tickets at the same time, their requests are queued and processed one by one. Users may experience a small delay, but the system never overloads. This ensures stability, especially during peak times.</p><h3>What Is a Burst Limit?</h3><p>A burst is a sudden spike in requests.</p><p>Burst limits define how much spike a system can tolerate.</p><p>Movie ticket example:</p><ul><li>Token bucket allows a user to book 5 tickets instantly (burst).</li><li>Refill rate ensures that long-term booking rate is still controlled.</li></ul><p>This balances UX and protection.</p><h3>Soft Limits vs Hard Limits</h3><p>Not all limits are strict.</p><ul><li>Hard limit: Request is rejected immediately (HTTP 429)</li><li>Soft limit: Request is slowed down or warned, giving users a chance</li></ul><p>Movie ticket example: Premium users may experience soft limits — a short wait before the request is processed, instead of being rejected outright.</p><h3>Rate Limiting vs Throttling</h3><ul><li>Rate limiting: deciding <em>whether</em> a request is allowed</li><li>Throttling: controlling <em>how fast</em> requests are processed</li></ul><p>Movie ticket example:</p><ul><li>Rate limiting stops a user from overbooking.</li><li>Throttling spreads requests evenly so the booking engine doesn’t overload.</li></ul><h3>Where Rate Limiting Lives in Real Systems</h3><p>Rate limiting can exist at multiple layers:</p><ul><li>Application level: Logic inside the backend</li><li>Infrastructure level: API gateways, load balancers, CDNs</li><li>Distributed systems: Shared storage like Redis</li></ul><p>Movie ticket example:</p><ul><li>Application-level limit prevents one user from booking too many tickets</li><li>Gateway-level limit prevents hundreds of users from crashing the server simultaneously</li><li>Redis or distributed counters ensure limits work across multiple servers</li></ul><h3>Common Mistakes Developers Make</h3><ul><li>Treating rate limiting as only a security feature</li><li>Using fixed windows blindly</li><li>Ignoring burst behavior</li><li>Not communicating limits to clients</li><li>Applying the same limit everywhere</li></ul><p>Movie ticket example: Applying the same rate limit to VIP users, normal users, and API clients leads to bad UX.</p><h3>Rate Limiting Is a UX Feature</h3><p>Bad rate limiting feels random and frustrating.<br>Good rate limiting:</p><ul><li>Protects the system silently</li><li>Feels fair</li><li>Communicates clearly</li><li>Handles bursts gracefully</li></ul><p>In short:</p><blockquote><em>Rate limiting is part of your product design.</em></blockquote><h3>Final Takeaway</h3><p>Rate limiting is not about stopping users — it’s about predictability, fairness, and stability.</p><p>Once you understand:</p><ul><li>Identity</li><li>Time windows</li><li>Burst behavior</li><li>Strategy trade-offs</li></ul><p>…you stop thinking of rate limiting as a “library feature” and start thinking of it as a design decision.</p><p>Rate limiting makes your system safe, fair, and user-friendly — even during the busiest Friday night movie releases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8badbd042afd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>