<?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 Pradeep Kumar on Medium]]></title>
        <description><![CDATA[Stories by Pradeep Kumar on Medium]]></description>
        <link>https://medium.com/@pradeepchaudhary1997?source=rss-a44e82ef9f50------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Nx1_UhZq-zBidiFpziX8EQ.jpeg</url>
            <title>Stories by Pradeep Kumar on Medium</title>
            <link>https://medium.com/@pradeepchaudhary1997?source=rss-a44e82ef9f50------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 19:32:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pradeepchaudhary1997/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[Rate Limiters 101: The Tiny Algorithm Behind Every '429 Too Many Requests']]></title>
            <link>https://medium.com/@pradeepchaudhary1997/rate-limiters-101-the-tiny-algorithm-behind-every-429-too-many-requests-d0faa07b5435?source=rss-a44e82ef9f50------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0faa07b5435</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Pradeep Kumar]]></dc:creator>
            <pubDate>Fri, 31 Jul 2026 07:22:44 GMT</pubDate>
            <atom:updated>2026-07-31T07:22:44.531Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rate Limiter &amp; Its 5 Applications in production</h3><h4>How a deceptively simple counter protects nearly every system you use every day</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vuWQeM8B82ahCvDyA-gw7g.png" /></figure><p>Every time you refresh Twitter too fast, retry a failed login, or hammer an API in a for loop, something quietly steps in and says: <em>&quot;slow down.&quot;</em> That something is a <strong>rate limiter</strong> — one of the most under-discussed but universally deployed pieces of infrastructure in modern software.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yUioLopmx3L3yuLHY2_GSg.png" /></figure><p><strong>In this article, we’ll break down:</strong></p><ol><li>What a rate limiter actually is</li><li>The core algorithms behind it (with diagrams)</li><li><strong>5 real production applications</strong> where rate limiting is doing invisible, critical work</li><li>How to think about building one yourself</li></ol><h3>What Is a Rate Limiter?</h3><p>A rate limiter controls <strong>how many requests</strong> a client (a user, an IP, an API key, a service) can make <strong>within a given time window</strong>. If the client exceeds that quota, the system rejects, delays, or throttles further requests — usually returning an HTTP 429 Too Many Requests.</p><p>It sits at the boundary between “the world” and “your system,” acting as a shock absorber:</p><ul><li>It protects backend resources from being overwhelmed</li><li>It ensures fair usage across many tenants</li><li>It defends against abuse, scraping, and brute-force attacks</li><li>It keeps costs predictable when calling paid third-party APIs</li></ul><p><strong>Think of it as a bouncer at a club door</strong>: not blocking people from entering forever, just controlling <em>the rate</em> at which they’re let in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*Xhc1rinsiFCwRzeTu1r9UA.png" /></figure><h3>The Core Algorithms</h3><p>There are five well-known algorithms for implementing rate limiting. Let’s visualize the three most important ones.</p><h3>1. Token Bucket</h3><p>The most widely used algorithm in production (used by AWS, Stripe, and most API gateways). A bucket holds tokens, refilled at a fixed rate. Every request consumes one token. No tokens left? The request is rejected or queued.</p><p><strong>Why it’s popular:</strong> it naturally allows short bursts (up to the bucket size) while still enforcing a long-term average rate — which matches real traffic patterns far better than a rigid cap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PdYEo7p6A_BaQ_QXqMNCUA.png" /></figure><h3>2. Leaky Bucket</h3><p>Requests are pushed into a FIFO queue (the “bucket”) and processed at a strictly constant output rate, like water leaking from a hole. If the queue is full, new requests are dropped.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rItmp0PZdBPdgayEvZRB_w.png" /></figure><p><strong>Why it’s used:</strong> it produces perfectly smoothed, constant-rate output — ideal when the downstream system genuinely cannot handle <em>any</em> burst (e.g., legacy systems, hardware controllers, some payment processors).</p><h3>3. Fixed Window vs. Sliding Window Counter</h3><p>Fixed windows are the simplest to implement (a counter that resets every N seconds) but suffer from a classic <strong>boundary burst problem</strong>: a client can send the full quota right at the end of one window and again immediately at the start of the next, doubling the effective rate for a few seconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MeN_D2BCSJgwe4DpHpXtYQ.png" /></figure><p>Sliding window counters fix this by blending the previous and current window counts, weighted by elapsed time.</p><h3>The 5 Applications in Production</h3><p>This is where rate limiting stops being a computer-science exercise and starts being the thing quietly keeping real systems alive.</p><h3>1. Public API Gateway Protection</h3><p>Every major API provider — Stripe, GitHub, Twitter/X, Google Maps — puts a rate limiter directly in the API gateway, keyed by API key or client ID. This is the first and most classic use case: <strong>protecting shared backend services from any single noisy client.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2D2SaFW9VcMudaSgvijNA.png" /></figure><p>Without this, one runaway script or misconfigured integration could exhaust database connections or CPU meant for thousands of other tenants. This is also usually where <strong>tiered plans</strong> live — free-tier users might get 60 requests/minute, paid users 6,000/minute, all enforced by the same limiter with different configs per key.</p><h3>2. Brute-Force &amp; Credential-Stuffing Protection</h3><p>Login endpoints, password-reset forms, and OTP verification endpoints are prime attack targets. A rate limiter keyed on user_id + IP (not just IP alone, since attackers rotate IPs) throttles repeated attempts, typically combined with exponential backoff or a CAPTCHA challenge after a threshold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVmAJbnCuxf31f4XmEF2QA.png" /></figure><p>This is a <strong>security control</strong>, not just a performance one — it’s the difference between an attacker needing hours vs. years to brute-force a password, and it’s a standard requirement in security audits (OWASP explicitly recommends it for authentication endpoints).</p><h3>3. Distributed Rate Limiting Across Microservices</h3><p><strong>The tricky part:</strong> in production you rarely have <em>one</em> server. You have a fleet behind a load balancer. A naive in-memory counter on each instance won’t enforce a <em>global</em> limit — a client could just get routed to a fresh server with a fresh counter.</p><p>The standard fix is a <strong>shared, centralized store</strong> (usually Redis) that all instances check atomically, often via a Lua script to avoid race conditions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMPw4fOAo7Dro_8qGsnFRQ.png" /></figure><p>This pattern is what powers rate limiting at companies like Discord, Shopify, and Cloudflare’s edge network — Redis’s INCR + EXPIRE combo (or more precise Lua-based sliding window scripts) is practically the industry-standard building block here.</p><h3>4. Respecting Third-Party API Limits (Outbound / Client-Side)</h3><p>Rate limiting isn’t only defensive — it’s also something <em>you</em> need to implement when <strong>calling</strong> other people’s APIs. If your service bulk-sends emails via SendGrid, syncs data via the GitHub API, or charges cards via Stripe, blowing past their rate limit gets your integration throttled or banned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*306mtSUmKp5GkYLwFgy6Gw.png" /></figure><p>Here, the rate limiter lives in your outbound client layer, usually paired with a retry queue and exponential backoff whenever the provider responds with a 429. This is a very common (and often overlooked) production requirement for any service with heavy external API dependencies.</p><h3>5. Messaging, Notifications &amp; Spam Prevention</h3><p>Push notifications, SMS alerts, and in-app messages are cheap to trigger programmatically but expensive (and annoying) to over-send. A per-user rate limiter ensures that a burst of backend events — say, 50 price-drop triggers in a minute — collapses into one notification instead of 50.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FWXCkNBZ-Qmau6KqkbHWJg.png" /></figure><p><strong>Beyond user experience, this also protects you financially:</strong> SMS providers like Twilio charge per message, and email/SMS carriers actively penalize senders with <strong>spam-like sending patterns</strong>, which can get a sending domain or number blacklisted entirely.</p><p><strong>In Short:</strong></p><p>Rate limiting looks like a small utility function, but in production it’s doing five very different jobs at once: <strong>capacity protection, security enforcement, multi-tenant fairness, outbound compliance, and user-experience control.</strong> Almost every scalable system you interact with — from your bank’s login page to your Slack notifications — has one quietly running in the background.</p><p>The next time you see a 429 Too Many Requests, you&#39;ll know exactly which bucket just ran dry.</p><p>If you found this useful, consider following for more deep dives into distributed systems fundamentals.</p><p><strong>I Run LiveCohort on System Design checkout here:</strong></p><p><a href="https://livecohortbypradeep.com/">Live Cohort to - Crack Product-Based Company Interviews</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0faa07b5435" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Honest LLD Interview Experience at Razorpay ]]></title>
            <link>https://medium.com/@pradeepchaudhary1997/honest-lld-interview-experience-at-razorpay-9a75d6e805c6?source=rss-a44e82ef9f50------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a75d6e805c6</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[low-level-design]]></category>
            <dc:creator><![CDATA[Pradeep Kumar]]></dc:creator>
            <pubDate>Wed, 25 Mar 2026 14:54:14 GMT</pubDate>
            <atom:updated>2026-03-25T14:54:14.318Z</atom:updated>
            <content:encoded><![CDATA[<h3>LLD Interview Experience Razorpay</h3><p><strong>Razorpay SDE-2 LLD Round Experience (Honest, slightly detailed)</strong></p><p>Hey folks,<br>I recently went through Razorpay’s SDE-2 interviews and wanted to share how the LLD round actually felt. Writing this because I feel most resources make this round look easier than it really is.</p><p>The question was:<br><strong>“Design a payment processing system.”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*dVcJm1WrYl2rmvbrRr3AuQ.avif" /></figure><h3>Started with Basic Requirements then the interview got shifted gears to more question answers over edge cases :(</h3><blockquote>Multiple payment methods (Card, UPI, etc.)</blockquote><blockquote>Retry on failures</blockquote><blockquote>No duplicate payments</blockquote><blockquote>Should be easy to extend</blockquote><p>At surface level, it sounds like a standard LLD question. But they were expecting a real depth.</p><p>I began with the usual structure:</p><ul><li>Payment</li><li>PaymentMethod (interface)</li><li>PaymentProcessor</li></ul><blockquote>Explained a simple flow:<br>User initiates → Payment created → Processor delegates to method</blockquote><p>At this point, things felt normal. But then the interviewer started digging into edge cases, and that’s where the round really began.</p><h3>Idempotency</h3><p>First question:</p><blockquote><em>“What if the same request comes twice?”</em></blockquote><p>I initially gave a generic answer (check if payment exists), but he pushed further:</p><blockquote><em>“How do you </em>know<em> it’s the same request?”</em></blockquote><p>That’s when I introduced <strong>idempotency keys</strong>.</p><p>So the design evolved:</p><ul><li>Each request carries a unique key</li><li>System stores and checks it before processing</li></ul><p>This became a central part of the discussion.<br>Honestly, if you don’t bring this up in a payment system, it doesn’t look good.</p><p>He was mostly interested in the questions and not the code of LLD</p><p>then he asked how will you handle the failures???</p><p>I said we’ll retry on failure.</p><ul><li>Fixed retry vs exponential backoff</li><li>Max retry limits</li><li>Handling dependency failures</li></ul><p>Then the bigger question:</p><blockquote><em>“Will you retry synchronously?”</em></blockquote><p>That didn’t scale, so we moved to:</p><ul><li>Async retries using queue</li><li>Workers processing retries</li></ul><p>This part changed my initial design quite a bit mid-way.</p><p>Then came the most interesting question:</p><blockquote><em>“Payment succeeded at bank, but your system crashed before marking it SUCCESS.”</em></blockquote><p>This took a few seconds to process.</p><p>We discussed:</p><ul><li>Bank webhooks/callbacks</li><li>Reconciliation jobs</li><li>Eventual consistency</li></ul><p>Then he added another layer:</p><blockquote><em>“What if webhook also fails?”</em></blockquote><p>So we covered:</p><ul><li>Retrying webhook handling</li><li>Dead-letter queues</li></ul><p>This part felt very practical.</p><h3>Then He asked:</h3><blockquote><em>“What if we add a new payment method tomorrow?”</em></blockquote><p>Initially, I said we can just extend the interface.</p><p>But he pushed:</p><blockquote><em>“Will all methods behave the same?”</em></blockquote><p>Then I refined:</p><ul><li>Separate validation logic</li><li>Different processing flows per method</li><li>Strategy pattern for flexibility</li></ul><p>Final question:</p><blockquote><em>“Two threads process the same payment?”</em></blockquote><p>We discussed:</p><ul><li>Idempotency as first layer</li><li>DB constraints</li><li>Locking mechanisms (briefly)</li></ul><p>This round didn’t feel like:<br>“Design classes and you’re done”</p><p>It felt more like:<br>“Design something that won’t break under real conditions”</p><p>They kept pushing on:</p><ul><li>Edge cases</li><li>Failures</li><li>Race conditions</li></ul><p>If you’re preparing for SDE-2, especially fintech:</p><p>It’s not enough to know:</p><ul><li>Design patterns</li><li>Clean class diagrams</li></ul><p>You need to think in terms of:<br>“What can go wrong in production?”</p><p>A good signal is:<br>If your design already handles:</p><ul><li>Duplicate requests</li><li>Failures</li><li>Retries</li></ul><p>…you’re probably on the right track.</p><p>Hope this helps someone preparing.<br>Happy to discuss more if needed</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a75d6e805c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>