<?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: Hitender Shekhawat</title>
    <description>The latest articles on DEV Community by Hitender Shekhawat (@hitender-shekhawat).</description>
    <link>https://dev.to/hitender-shekhawat</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%2F3944317%2F9ab7372d-3231-4041-9753-e11c7f5980b7.png</url>
      <title>DEV Community: Hitender Shekhawat</title>
      <link>https://dev.to/hitender-shekhawat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hitender-shekhawat"/>
    <language>en</language>
    <item>
      <title>The 10-Minute Race: Scaling the "Cancel Order" Button to 100K+ Requests Per Second</title>
      <dc:creator>Hitender Shekhawat</dc:creator>
      <pubDate>Thu, 21 May 2026 16:00:50 +0000</pubDate>
      <link>https://dev.to/hitender-shekhawat/the-10-minute-race-scaling-the-cancel-order-button-to-100k-requests-per-second-2mon</link>
      <guid>https://dev.to/hitender-shekhawat/the-10-minute-race-scaling-the-cancel-order-button-to-100k-requests-per-second-2mon</guid>
      <description>&lt;p&gt;We've all been there. You order a pint of ice cream on an ultra-fast delivery app like &lt;strong&gt;Flipkart Minutes&lt;/strong&gt;. The app promises it'll arrive in 10 minutes.&lt;/p&gt;

&lt;p&gt;But what if 10 minutes pass, your ice cream is stuck in traffic, and you want to cancel? The app should give you a &lt;strong&gt;"Cancel Order"&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;Now look at it from the driver's perspective. If they just arrived at your doorstep, you shouldn't be able to cancel the order at the last second and get free ice cream. The button must vanish the exact millisecond the driver arrives.&lt;/p&gt;

&lt;p&gt;Handling this for one person is easy. But how do you build this when &lt;strong&gt;60,000 people are ordering at the same time&lt;/strong&gt;, flooding your system with &lt;strong&gt;100,000+ requests every single second&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;Let's dive in.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The Context: A Tale of Two Pages
&lt;/h2&gt;

&lt;p&gt;To understand the scale, we have to look at how customers actually behave on the app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Map Viewers&lt;/strong&gt; — Most users sit on the map screen watching the delivery icon move. The UI automatically refreshes &lt;strong&gt;every 30 seconds&lt;/strong&gt;. Over a 15-minute delivery, that's &lt;strong&gt;30 hits per user&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Chat Viewers&lt;/strong&gt; — Some users open the customer support chat. The app checks cancellation eligibility &lt;strong&gt;once&lt;/strong&gt; when the page opens. But if the driver arrives while the user is typing, the button needs to disappear in real-time &lt;strong&gt;without a page refresh&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Combined, these actions generate a massive wall of traffic — &lt;strong&gt;100,000+ Requests Per Second (RPS)&lt;/strong&gt; — hitting our backend.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. The Problem Statement
&lt;/h2&gt;

&lt;p&gt;We have three core systems to work with:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;System&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;UI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The customer's app (Map and Chat pages)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Eligibility Service&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The brain that decides: &lt;em&gt;"Should I show the cancel button right now?"&lt;/em&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fulfillment&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The muscle on the ground tracking driver GPS and status&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The Rules:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If &lt;code&gt;Time &amp;gt; 10 minutes&lt;/code&gt; → &lt;strong&gt;Show&lt;/strong&gt; the Cancel Button.&lt;/li&gt;
&lt;li&gt;If &lt;code&gt;Driver Status = "Arrived at Doorstep"&lt;/code&gt; → &lt;strong&gt;Hide&lt;/strong&gt; the Cancel Button immediately.&lt;/li&gt;
&lt;li&gt;The system must handle &lt;strong&gt;100k+ RPS&lt;/strong&gt; without breaking a sweat.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. The Solutions: From Bad to Brilliant
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Solution 1: The Chain Reaction (Direct API Calls)
&lt;/h3&gt;

&lt;p&gt;The most obvious idea is a simple chain. Every time a user's app refreshes, the Eligibility Service asks Fulfillment for the latest update.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcaf06ln8y7oae099rj5b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcaf06ln8y7oae099rj5b.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it's a bad idea:&lt;/strong&gt; The Fulfillment system is incredibly busy updating live GPS coordinates and assigning drivers. If you hammer it with 100,000 read requests every second just to check a button status, its database will lock up, causing the &lt;strong&gt;entire app to crash&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Solution 2: The "Are We There Yet?" Loop (Background Workers)
&lt;/h3&gt;

&lt;p&gt;To protect Fulfillment, we introduce background workers in the Eligibility Service to constantly poll order statuses and save them to a local cache.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjkkfwtyqan3ijtlinrg6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjkkfwtyqan3ijtlinrg6.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it's a bad idea:&lt;/strong&gt; Running continuous loops over 60,000 active orders is incredibly wasteful. More than &lt;strong&gt;95%&lt;/strong&gt; of the time, the driver hasn't arrived and the time hasn't run out. You are burning massive amounts of server energy asking the same question over and over. Plus, the 2-second polling delay opens a window where a clever user could &lt;strong&gt;abuse the cancel button&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Solution 3: Smart Math + Event-Driven Push (The Big Tech Way)
&lt;/h3&gt;

&lt;p&gt;This is how tech giants scale to millions of users. We do two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Stop using timers&lt;/strong&gt; to track time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use events&lt;/strong&gt; for real-world changes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Step A — Do the Math Upfront (The Read Path)
&lt;/h4&gt;

&lt;p&gt;When an order is placed at &lt;code&gt;8:00 PM&lt;/code&gt;, we don't set a 10-minute timer. Instead, the Eligibility Service saves a dead-simple stamp in a super-fast in-memory cache (Redis):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Cancellation_Allowed_After: 8:10 PM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the Map UI polls every 30 seconds, the Eligibility Service does a sub-millisecond lookup from the cache and runs this ultra-fast block of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passed_sla&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;current_time&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;promised_delivery_timestamp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;is_at_doorstep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dp_status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ARRIVED_AT_DOORSTEP&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;passed_sla&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;is_at_doorstep&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;show_cancel_button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&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;return&lt;/span&gt; &lt;span class="nx"&gt;show_cancel_button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No databases are harmed. No background loops are running. &lt;strong&gt;The clock does the work for us.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidx213uvczf3xgw66ivu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidx213uvczf3xgw66ivu.png" alt=" " width="799" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step B — The Live Switch (The Write / Push Path)
&lt;/h4&gt;

&lt;p&gt;What about the support chat page that needs &lt;strong&gt;real-time accuracy&lt;/strong&gt;?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The moment the driver reaches the doorstep, &lt;strong&gt;Fulfillment&lt;/strong&gt; emits a notification to a message broker (Kafka): &lt;em&gt;"Order 123: Driver Arrived!"&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Eligibility Service&lt;/strong&gt; listens to this event and immediately flips the status in Redis to &lt;code&gt;Driver_Arrived = True&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It instantly broadcasts a small message directly to the active &lt;strong&gt;Chat UI&lt;/strong&gt; via a persistent pipeline (&lt;strong&gt;WebSockets&lt;/strong&gt;).&lt;/li&gt;
&lt;li&gt;The button vanishes from the customer's screen instantly.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F930hqbcus4jtsea0qx1d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F930hqbcus4jtsea0qx1d.png" alt=" " width="799" height="436"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Takeaway
&lt;/h2&gt;

&lt;p&gt;Scaling systems to massive traffic isn't about buying bigger servers — it's about &lt;strong&gt;being lazy in a smart way&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Don't track time with active loops&lt;/strong&gt; — calculate timestamps upfront.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't ask for updates&lt;/strong&gt; — let the real world send you events when things change.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>performance</category>
      <category>systemdesign</category>
    </item>
  </channel>
</rss>
