<?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: Ashutosh Singh</title>
    <description>The latest articles on DEV Community by Ashutosh Singh (@ashutosh_singh_7acdabdece).</description>
    <link>https://dev.to/ashutosh_singh_7acdabdece</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%2F3985823%2F82a64491-148c-4ad5-996a-1760bf0407ff.jpg</url>
      <title>DEV Community: Ashutosh Singh</title>
      <link>https://dev.to/ashutosh_singh_7acdabdece</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ashutosh_singh_7acdabdece"/>
    <language>en</language>
    <item>
      <title>Idempotency: The Concept That Separates Senior Engineers</title>
      <dc:creator>Ashutosh Singh</dc:creator>
      <pubDate>Tue, 23 Jun 2026 08:03:02 +0000</pubDate>
      <link>https://dev.to/ashutosh_singh_7acdabdece/idempotency-the-concept-that-separates-senior-engineers-3lil</link>
      <guid>https://dev.to/ashutosh_singh_7acdabdece/idempotency-the-concept-that-separates-senior-engineers-3lil</guid>
      <description>&lt;h2&gt;
  
  
  "Just retry it" is the most dangerous advice in distributed systems
&lt;/h2&gt;

&lt;p&gt;You click &lt;strong&gt;"Pay $500."&lt;/strong&gt; The request reaches the server… but the response times out on the way back. Did it work? You have no idea. So you click again.&lt;/p&gt;

&lt;p&gt;Now you've been charged twice.&lt;/p&gt;

&lt;p&gt;This is the problem &lt;strong&gt;idempotency&lt;/strong&gt; solves - and handling it well is one of the clearest signals of a senior engineer. Let's go deep, with code.&lt;/p&gt;

&lt;h2&gt;
  
  
  What "idempotent" actually means
&lt;/h2&gt;

&lt;p&gt;An operation is idempotent if performing it &lt;strong&gt;once or ten times has the same effect&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;PUT&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt; → naturally idempotent&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;POST&lt;/code&gt; that charges a card, creates an order, or sends an email → &lt;strong&gt;not&lt;/strong&gt; idempotent&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The moment a network can fail (always) and a client can retry (always), non-idempotent writes become dangerous.&lt;/p&gt;

&lt;h2&gt;
  
  
  Idempotency keys: the Stripe pattern
&lt;/h2&gt;

&lt;p&gt;The client generates a &lt;strong&gt;unique key per logical operation&lt;/strong&gt; and sends it with the request:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
http
POST /charges
Idempotency-Key: a1b2c3d4-....

Server logic, in pseudocode:


record = store.get(key)
if record exists and completed:
    return record.response        # a retry — don't reprocess
result = process(request)
store.save(key, result)
return result
Simple in theory. The depth is entirely in the edge cases.

Edge case 1 — The concurrent-retry race
Two retries land in the same millisecond. Both run store.get(key) → both see nothing → both call process() → double charge.

A naive "check-then-write" recreates the exact bug you're trying to fix. You need an atomic claim — a unique constraint:


CREATE TABLE idempotency_keys (
  key         TEXT PRIMARY KEY,
  status      TEXT NOT NULL,         -- 'in_progress' | 'completed'
  response    JSONB,
  created_at  TIMESTAMPTZ DEFAULT now()
);

-- Atomically claim the key. Only ONE concurrent request wins.
INSERT INTO idempotency_keys (key, status)
VALUES ($1, 'in_progress')
ON CONFLICT (key) DO NOTHING;
If the insert affects 0 rows, someone else owns the key → you wait/poll for their result or return 409 Conflict. The database's uniqueness guarantee does the hard concurrency work for you.

Edge case 2 — Store the RESPONSE, not just "done"
On a retry you must return the same response the client missed the first time — same charge ID, same status code, same body. Otherwise the client can't reconcile what happened.

So when the first request completes, persist its full response:


UPDATE idempotency_keys
SET status = 'completed', response = $2
WHERE key = $1;
Now any later retry replays that exact response.

Edge case 3 — Partial failures &amp;amp; atomicity
The nastiest case: you charged the card but crashed before saving the result. The key never reaches completed, so a retry charges again.

Two defenses:

Wrap the idempotency record + the side effect in one transaction — only works when the side effect lives in the same database.
For external side effects (charging via a payment processor), record in_progress before the call, and on a retry of an in_progress key, reconcile with the processor (using your key) instead of blindly re-charging.
This is why payment APIs lean heavily on the provider also being idempotent end-to-end.

Edge case 4 — Key scope &amp;amp; expiry
Scope keys per endpoint + account, so the same key string can't collide across users.
Expire them (Stripe uses ~24h) — long enough to cover retries, short enough not to store forever.
Reusing a key with a different payload should error, not silently return the old result.
The mental model: stop chasing "exactly once"
Don't try to guarantee a request runs exactly once. Make it safe to run any number of times.

"Exactly-once delivery" is largely a myth. At-least-once delivery + idempotency = exactly-once effects.

That single reframe is what makes payment, order, and messaging systems reliable — and it's a favourite senior interview probe.

Wrapping up
Idempotency looks like a one-liner ("just store the key") and turns out to be four subtle problems: the race, the response replay, partial-failure atomicity, and key scope/expiry. Nail those and your retries stop being scary.

Disclosure: I work on PrepGrind, a free playground for building &amp;amp; stress-testing systems like this — but the patterns above stand on their own.

How do you handle the concurrent-retry race in your systems — a unique constraint, a distributed lock, or something else? Curious what's worked for others.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
    <item>
      <title>The IPL final. 50+ MILLION people streaming the same match at the same second - a real world record set on Hotstar. 🏏</title>
      <dc:creator>Ashutosh Singh</dc:creator>
      <pubDate>Thu, 18 Jun 2026 14:49:09 +0000</pubDate>
      <link>https://dev.to/ashutosh_singh_7acdabdece/the-ipl-final-50-million-people-streaming-the-same-match-at-the-same-second-a-real-world-record-56k0</link>
      <guid>https://dev.to/ashutosh_singh_7acdabdece/the-ipl-final-50-million-people-streaming-the-same-match-at-the-same-second-a-real-world-record-56k0</guid>
      <description>&lt;p&gt;Hotstar once streamed the Cricket World Cup final to ~59 MILLION people at the same second.&lt;/p&gt;

&lt;p&gt;That's not a typo. ~59,000,000 concurrent viewers - a world record. &lt;/p&gt;

&lt;p&gt;How does a system survive that? A few things Hotstar actually does:&lt;/p&gt;

&lt;p&gt;→ Plan for the "tsunami," not the average. The scary moment isn't steady load — it's a wicket falling, when millions refresh and rejoin in the same few seconds. They design for that spike, not the baseline.&lt;/p&gt;

&lt;p&gt;→ Pre-provision capacity. Reactive autoscaling is too slow — servers take minutes to boot, spikes happen in seconds. So Hotstar predicts concurrency and scales up BEFORE the match, keeping warm capacity ready.&lt;/p&gt;

&lt;p&gt;→ Segment + multi-CDN fan-out. The live feed is chopped into tiny 2–6s chunks pushed to CDN edges across multiple providers. Millions pull from the nearest edge, not the origin. One encode, served to millions.&lt;/p&gt;

&lt;p&gt;→ Graceful degradation ("panic mode"). Under extreme load, Hotstar sheds non-essential features and lowers quality to keep the core stream alive. A slightly lower-res match beats a crashed one.&lt;/p&gt;

&lt;p&gt;→ Trade latency for stability. Live runs ~10–30s behind real-time on purpose — that buffer absorbs the spikes.&lt;/p&gt;

&lt;p&gt;The big lesson: at this scale you don't fight the load head-on. You predict it, pre-provision for it, push everything to the edge, and degrade gracefully instead of failing.&lt;/p&gt;

&lt;p&gt;You can build a live streaming design — origin, transcoding, CDN edge — and push traffic through it to watch where it strains 👇 (free, no signup)&lt;br&gt;
prepgrind.xyz&lt;/p&gt;

&lt;p&gt;What would you reach for first to handle 50M+ concurrent viewers?&lt;/p&gt;

&lt;h1&gt;
  
  
  SystemDesign #SoftwareEngineering #DistributedSystems #InterviewPrep
&lt;/h1&gt;

</description>
      <category>architecture</category>
      <category>infrastructure</category>
      <category>performance</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>How Netflix Streams to 320+ Million Users Without Crashing</title>
      <dc:creator>Ashutosh Singh</dc:creator>
      <pubDate>Tue, 16 Jun 2026 05:57:13 +0000</pubDate>
      <link>https://dev.to/ashutosh_singh_7acdabdece/how-netflix-streams-to-320-million-users-without-crashing-167b</link>
      <guid>https://dev.to/ashutosh_singh_7acdabdece/how-netflix-streams-to-320-million-users-without-crashing-167b</guid>
      <description>&lt;p&gt;Netflix is roughly &lt;strong&gt;15% of all downstream internet traffic&lt;/strong&gt;. It streams to &lt;strong&gt;320M+ subscribers&lt;/strong&gt; across the planet, at peak hours, and almost never goes down.&lt;/p&gt;

&lt;p&gt;If you've ever sat in a system design interview and your first instinct was &lt;em&gt;"add more servers"&lt;/em&gt; — Netflix is the case study that breaks that instinct. Their whole architecture is built on the opposite idea:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Don't bring users to your servers. Bring the data to the users.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's break down how they actually do it.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The CDN is the product: Open Connect
&lt;/h2&gt;

&lt;p&gt;Most companies rent a CDN (Cloudflare, Akamai, CloudFront). Netflix built its own — &lt;strong&gt;Open Connect&lt;/strong&gt; — and physically ships caching appliances &lt;em&gt;into ISPs' data centers&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;So when you hit play in Bangalore or Berlin, the video doesn't come from a Netflix origin across the world. It streams from a box &lt;strong&gt;a few miles away, inside your own ISP's network&lt;/strong&gt;.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lower latency + fewer hops&lt;/strong&gt; → faster start, less buffering.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Less backbone traffic&lt;/strong&gt; → cheaper for both Netflix and the ISP (a win-win that got ISPs to host the boxes for free).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The lesson: at massive read scale, the network &lt;em&gt;is&lt;/em&gt; the bottleneck, not compute.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Pre-positioning: cache before the request
&lt;/h2&gt;

&lt;p&gt;Here's the clever part. Netflix knows what's popular in each region, so it &lt;strong&gt;pushes those titles to edge servers overnight&lt;/strong&gt;, during off-peak hours — &lt;em&gt;before anyone presses play&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;By the time you're watching at 9pm, the content is already sitting on the box next to you. This is caching taken to its logical extreme: you don't cache &lt;em&gt;on&lt;/em&gt; the first request, you predict and &lt;strong&gt;pre-warm&lt;/strong&gt; the cache.&lt;/p&gt;

&lt;p&gt;Origin (S3)  ──(overnight push)──►  Open Connect @ ISP  ──►  You&lt;br&gt;
cold                                   warm (pre-positioned)     fast&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Adaptive Bitrate Streaming (ABR)
&lt;/h2&gt;

&lt;p&gt;A video isn't stored as one file. It's &lt;strong&gt;encoded into many quality levels&lt;/strong&gt; and chopped into small segments (a few seconds each).&lt;/p&gt;

&lt;p&gt;Your player constantly measures your bandwidth and &lt;strong&gt;switches quality on the fly&lt;/strong&gt; — segment by segment. Network dips? It drops to a lower bitrate instead of buffering. Network recovers? It bumps back up.&lt;/p&gt;

&lt;p&gt;The principle: &lt;strong&gt;degrade gracefully instead of failing.&lt;/strong&gt; A slightly blurry stream beats a spinning wheel every time.&lt;/p&gt;
&lt;h2&gt;
  
  
  4. Encode once, serve billions
&lt;/h2&gt;

&lt;p&gt;Transcoding every title into dozens of resolutions and codecs is enormously expensive — so it's done &lt;strong&gt;once, offline&lt;/strong&gt;, in a massive parallel pipeline:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Split the source video into chunks&lt;/li&gt;
&lt;li&gt;Encode chunks in parallel across a worker fleet&lt;/li&gt;
&lt;li&gt;Reassemble into per-quality streams&lt;/li&gt;
&lt;li&gt;Distribute to Open Connect&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Heavy, slow work happens on the &lt;strong&gt;cold path&lt;/strong&gt; (offline). The &lt;strong&gt;hot path&lt;/strong&gt; (playback) only ever serves pre-built files. Keeping these two paths separate is a pattern you'll reuse everywhere.&lt;/p&gt;
&lt;h2&gt;
  
  
  5. Microservices + designing for failure
&lt;/h2&gt;

&lt;p&gt;Behind playback sits a mesh of &lt;strong&gt;hundreds of microservices&lt;/strong&gt; (auth, recommendations, billing, metadata, playback…). At that scale, &lt;strong&gt;something is always failing.&lt;/strong&gt; Netflix's answer is to assume it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chaos Monkey&lt;/strong&gt; randomly kills services &lt;em&gt;in production&lt;/em&gt; to prove the system survives.&lt;/li&gt;
&lt;li&gt;Circuit breakers, fallbacks, and timeouts so one slow service doesn't cascade.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't engineer for "nothing breaks." You engineer for "things break and users don't notice."&lt;/p&gt;
&lt;h2&gt;
  
  
  What this means for your own designs
&lt;/h2&gt;

&lt;p&gt;If you only remember four things from Netflix:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Move data to the edge&lt;/strong&gt; (CDN / caching) before you scale compute.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pre-warm&lt;/strong&gt; caches for predictable, read-heavy load.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Degrade gracefully&lt;/strong&gt; (adaptive quality, fallbacks) instead of failing hard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Separate the cold path from the hot path&lt;/strong&gt; (offline transcoding vs. live playback).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These show up in almost every large-scale read-heavy system — video, feeds, search, even maps.&lt;/p&gt;
&lt;h2&gt;
  
  
  Try breaking it yourself
&lt;/h2&gt;

&lt;p&gt;Reading about this is one thing; &lt;em&gt;feeling&lt;/em&gt; it is another. If you want to actually build a streaming design — drop in a CDN, edge servers, and an origin, then push live traffic through it and watch where it falls over — that's exactly what we built &lt;strong&gt;&lt;a href="https://www.prepgrind.xyz" rel="noopener noreferrer"&gt;PrepGrind&lt;/a&gt;&lt;/strong&gt; for. (Disclosure: it's our tool; free to start, no signup.)&lt;/p&gt;



&lt;p&gt;What would you reach for &lt;em&gt;first&lt;/em&gt; to handle Netflix-scale traffic — CDN, caching, or something else? Curious how others approach it. 👇&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
        &lt;div class="c-embed__cover"&gt;
          &lt;a href="https://www.prepgrind.xyz/" class="c-link align-middle" rel="noopener noreferrer"&gt;
            &lt;img alt="" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.prepgrind.xyz%2Fog-image.png" height="420" class="m-0" width="800"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="c-embed__body"&gt;
        &lt;h2 class="fs-xl lh-tight"&gt;
          &lt;a href="https://www.prepgrind.xyz/" rel="noopener noreferrer" class="c-link"&gt;
            PrepGrind — Interactive System Design &amp;amp; DSA Interview Prep Playground
          &lt;/a&gt;
        &lt;/h2&gt;
          &lt;p class="truncate-at-3"&gt;
            Learn system design and DSA the visual way. Drag-and-drop architecture canvas, live traffic simulation, 33 real case studies, and guided algorithm walkthroughs — free.
          &lt;/p&gt;
        &lt;div class="color-secondary fs-s flex items-center"&gt;
            &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.prepgrind.xyz%2Ffavicon.svg" width="48" height="46"&gt;
          prepgrind.xyz
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>systemdesign</category>
      <category>architecture</category>
      <category>scalability</category>
      <category>backend</category>
    </item>
    <item>
      <title>9 Years in Software Engineering - Excited to Join the DEV Community</title>
      <dc:creator>Ashutosh Singh</dc:creator>
      <pubDate>Mon, 15 Jun 2026 15:25:51 +0000</pubDate>
      <link>https://dev.to/ashutosh_singh_7acdabdece/9-years-in-software-engineering-excited-to-join-the-dev-community-1a83</link>
      <guid>https://dev.to/ashutosh_singh_7acdabdece/9-years-in-software-engineering-excited-to-join-the-dev-community-1a83</guid>
      <description>&lt;p&gt;Hi everyone &lt;/p&gt;

&lt;p&gt;I'm Ashutosh, a Principal Engineer with 8+ years of experience building scalable software systems and leading engineering teams.&lt;/p&gt;

&lt;p&gt;Currently, I'm working on large-scale educational platforms and pursuing an M.Tech in AI &amp;amp; Data Science from IIT Patna.&lt;/p&gt;

&lt;p&gt;Over the years, I've worked across backend engineering, system design, cloud architecture, and more recently AI-powered applications.&lt;/p&gt;

&lt;p&gt;I'm joining DEV to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Share practical system design lessons&lt;/li&gt;
&lt;li&gt;Write about AI and software engineering&lt;/li&gt;
&lt;li&gt;Discuss engineering leadership and architecture decisions&lt;/li&gt;
&lt;li&gt;Document my journey of building products from scratch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One thing I've learned after 9 years in engineering:&lt;/p&gt;

&lt;p&gt;Building software is only half the challenge. Understanding users and solving the right problems is often the harder part.&lt;/p&gt;

&lt;p&gt;Looking forward to learning from the community and contributing wherever I can.&lt;/p&gt;

&lt;p&gt;What's one engineering topic you'd like to see covered more often?&lt;/p&gt;

&lt;h1&gt;
  
  
  introductions #softwareengineering #systemdesign #ai
&lt;/h1&gt;

</description>
      <category>ai</category>
      <category>community</category>
      <category>softwareengineering</category>
      <category>systemdesign</category>
    </item>
  </channel>
</rss>
