<?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: Anik Sikder</title>
    <description>The latest articles on DEV Community by Anik Sikder (@anik_sikder_313).</description>
    <link>https://dev.to/anik_sikder_313</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%2F3417201%2F1a7e8243-c383-4bb6-ae0f-26a963e461f2.png</url>
      <title>DEV Community: Anik Sikder</title>
      <link>https://dev.to/anik_sikder_313</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anik_sikder_313"/>
    <language>en</language>
    <item>
      <title>Multiplexing vs Connection Pooling: Why HTTP/2 Changed Everything</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Sat, 01 Aug 2026 14:47:07 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/multiplexing-vs-connection-pooling-why-http2-changed-everything-3ikh</link>
      <guid>https://dev.to/anik_sikder_313/multiplexing-vs-connection-pooling-why-http2-changed-everything-3ikh</guid>
      <description>&lt;p&gt;In the previous articles of this series, we explored a recurring theme:&lt;/p&gt;

&lt;p&gt;Every generation of web infrastructure solved one bottleneck only to expose another.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;HTTP/1.0 suffered from connection setup overhead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTTP/1.1 introduced persistent connections.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then browsers started requesting hundreds of assets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Persistent connections helped, but a new problem emerged: &lt;strong&gt;Head-of-Line Blocking&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To work around it, browsers began opening multiple TCP connections.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That workaround became known as &lt;strong&gt;Connection Pooling&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For years, Connection Pooling was the hidden engine powering the modern web.&lt;/p&gt;

&lt;p&gt;Then HTTP/2 arrived and asked a dangerous question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What if we stopped opening more connections and instead made a single connection smarter?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That idea became &lt;strong&gt;Multiplexing&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This article explores why that shift fundamentally changed web architecture.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem Nobody Intended to Create
&lt;/h2&gt;

&lt;p&gt;Imagine it's 2012.&lt;/p&gt;

&lt;p&gt;A user opens your e-commerce homepage.&lt;/p&gt;

&lt;p&gt;The browser needs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;HTML&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CSS files&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScript bundles&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Product images&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Recommendation widgets&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Analytics scripts&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tracking pixels&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fonts&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A single page can easily require:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;100+ requests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yet HTTP/1.1 processes requests sequentially on a connection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection 1

Request A
Response A

Request B
Response B

Request C
Response C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser quickly discovers something painful:&lt;/p&gt;

&lt;p&gt;If Request A is slow,&lt;/p&gt;

&lt;p&gt;everything behind it waits.&lt;/p&gt;

&lt;p&gt;This becomes Head-of-Line Blocking.&lt;/p&gt;




&lt;h2&gt;
  
  
  The First Large-Scale Workaround
&lt;/h2&gt;

&lt;p&gt;Browser vendors couldn't change HTTP overnight.&lt;/p&gt;

&lt;p&gt;So they found another solution.&lt;/p&gt;

&lt;p&gt;Open more TCP connections.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 Connection
100 Requests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Browsers evolved toward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection 1
Connection 2
Connection 3
Connection 4
Connection 5
Connection 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each connection handles separate requests.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection 1 -&amp;gt; CSS
Connection 2 -&amp;gt; JS
Connection 3 -&amp;gt; Image
Connection 4 -&amp;gt; Image
Connection 5 -&amp;gt; Font
Connection 6 -&amp;gt; API
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now multiple requests can progress simultaneously.&lt;/p&gt;

&lt;p&gt;This dramatically improved page load performance.&lt;/p&gt;

&lt;p&gt;The strategy became known as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Connection Pooling&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  What Exactly Is Connection Pooling?
&lt;/h2&gt;

&lt;p&gt;Connection Pooling means maintaining a collection of reusable connections instead of creating a new connection for every request.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request
Create TCP
TLS
Send
Close
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for every operation,&lt;/p&gt;

&lt;p&gt;the browser maintains a pool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Pool

Connection 1
Connection 2
Connection 3
Connection 4
Connection 5
Connection 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Incoming requests are assigned to available connections.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request A -&amp;gt; Connection 1
Request B -&amp;gt; Connection 2
Request C -&amp;gt; Connection 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This reduces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;TCP handshake cost&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TLS handshake cost&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connection setup latency&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For years, this approach worked surprisingly well.&lt;/p&gt;

&lt;p&gt;But it introduced new operational problems.&lt;/p&gt;




&lt;h2&gt;
  
  
  Postmortem: The Scaling Problem Nobody Talks About
&lt;/h2&gt;

&lt;p&gt;Imagine a popular online marketplace.&lt;/p&gt;

&lt;p&gt;Traffic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;500,000 active users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Browser behavior:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6 connections per origin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Potential active connections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3,000,000 TCP connections
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now consider the infrastructure.&lt;/p&gt;

&lt;p&gt;Every connection consumes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Memory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Kernel resources&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TCP buffers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TLS state&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Suddenly the architecture team realizes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We are spending more resources managing connections than delivering content.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The system is technically healthy.&lt;/p&gt;

&lt;p&gt;Yet servers remain under pressure.&lt;/p&gt;

&lt;p&gt;Not because requests are expensive.&lt;/p&gt;

&lt;p&gt;Because connections are expensive.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hidden Cost of Connection Pooling
&lt;/h2&gt;

&lt;p&gt;Most performance discussions focus on requests.&lt;/p&gt;

&lt;p&gt;Infrastructure teams focus on connections.&lt;/p&gt;

&lt;p&gt;Each TCP connection carries overhead.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client
   │
TCP State
TLS State
Receive Buffer
Send Buffer
Kernel Metadata
   │
Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Multiply this by millions of active connections.&lt;/p&gt;

&lt;p&gt;The resource footprint becomes enormous.&lt;/p&gt;

&lt;p&gt;This is why large-scale systems obsess over connection efficiency.&lt;/p&gt;




&lt;h2&gt;
  
  
  Another Problem: Congestion Control
&lt;/h2&gt;

&lt;p&gt;Each TCP connection behaves independently.&lt;/p&gt;

&lt;p&gt;Imagine six connections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection 1
Connection 2
Connection 3
Connection 4
Connection 5
Connection 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Its own congestion window&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Its own retransmissions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Its own packet loss handling&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The network now sees six competing traffic flows from the same browser.&lt;/p&gt;

&lt;p&gt;This is inefficient.&lt;/p&gt;

&lt;p&gt;The browser is essentially pretending to be six different clients.&lt;/p&gt;

&lt;p&gt;The protocol wasn't designed for this.&lt;/p&gt;

&lt;p&gt;It was a workaround.&lt;/p&gt;




&lt;h2&gt;
  
  
  The HTTP/2 Idea
&lt;/h2&gt;

&lt;p&gt;Engineers looked at the situation and asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why are we creating six connections just to achieve parallelism?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What if one connection could handle many requests simultaneously?&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection 1
Connection 2
Connection 3
Connection 4
Connection 5
Connection 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection 1
 ├─ Request A
 ├─ Request B
 ├─ Request C
 ├─ Request D
 ├─ Request E
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One connection.&lt;/p&gt;

&lt;p&gt;Many independent conversations.&lt;/p&gt;

&lt;p&gt;That idea became:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Multiplexing&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Understanding Multiplexing
&lt;/h2&gt;

&lt;p&gt;In HTTP/2, requests no longer own connections.&lt;/p&gt;

&lt;p&gt;They own streams.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TCP Connection
     │
 ┌───┼───────────┐
 │   │           │
Stream 1
Stream 2
Stream 3
Stream 4
Stream 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each request receives its own stream.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stream 1 -&amp;gt; CSS
Stream 2 -&amp;gt; JS
Stream 3 -&amp;gt; Image
Stream 4 -&amp;gt; API
Stream 5 -&amp;gt; Font
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All streams share the same TCP connection.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Magic: Interleaving
&lt;/h2&gt;

&lt;h3&gt;
  
  
  HTTP/1.1:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request A
Response A
Request B
Response B
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  HTTP/2:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A1
B1
C1
A2
B2
C2
A3
B3
C3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Data from different streams becomes interleaved.&lt;/p&gt;

&lt;p&gt;The connection continuously carries frames from multiple requests.&lt;/p&gt;

&lt;p&gt;No request owns the connection.&lt;/p&gt;

&lt;p&gt;The connection belongs to everyone.&lt;/p&gt;

&lt;p&gt;This is true multiplexing.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real Example: Product Page Load
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Suppose a product page requires:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML
5 CSS files
10 JS files
20 images
2 APIs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  HTTP/1.1:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser

Connection 1
Connection 2
Connection 3
Connection 4
Connection 5
Connection 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Requests are distributed across the pool.&lt;/p&gt;

&lt;p&gt;Some connections become idle.&lt;/p&gt;

&lt;p&gt;Others become overloaded.&lt;/p&gt;

&lt;p&gt;Load balancing is imperfect.&lt;/p&gt;




&lt;p&gt;HTTP/2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Single Connection

Stream 1
Stream 2
Stream 3
...
Stream 38
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All resources travel simultaneously through the same connection.&lt;/p&gt;

&lt;p&gt;The browser no longer plays connection management games.&lt;/p&gt;

&lt;p&gt;The protocol handles concurrency natively.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Business Impact
&lt;/h2&gt;

&lt;p&gt;Most executives never hear the term Multiplexing.&lt;/p&gt;

&lt;p&gt;They only see metrics.&lt;/p&gt;

&lt;p&gt;Before:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Page Load Time: 4.2s
Bounce Rate: Higher
Conversion Rate: Lower
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After optimization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Page Load Time: 2.8s
Bounce Rate: Lower
Conversion Rate: Higher
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Users do not care whether the improvement came from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;TCP tuning&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiplexing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compression&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Prioritization&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They only experience speed.&lt;/p&gt;

&lt;p&gt;For many businesses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Faster Pages
=
More Revenue
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The Developer Impact
&lt;/h2&gt;

&lt;p&gt;Before HTTP/2, frontend engineers developed strange habits.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;h3&gt;
  
  
  CSS Sprites
&lt;/h3&gt;

&lt;p&gt;Combining many images into one file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;icon1.png
icon2.png
icon3.png
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;became&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sprites.png
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  JavaScript Bundling
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;20 JS Files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;became&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.bundle.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Domain Sharding
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;img1.example.com
img2.example.com
img3.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This trick forced browsers to create more connection pools.&lt;/p&gt;

&lt;p&gt;These techniques existed largely because HTTP/1.1 had connection limitations.&lt;/p&gt;

&lt;p&gt;Multiplexing removed many of those constraints.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Postmortem Nobody Expected
&lt;/h2&gt;

&lt;p&gt;Many teams upgraded to HTTP/2 expecting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6 Connections
↓
1 Connection
↓
6x Faster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reality was more complicated.&lt;/p&gt;

&lt;p&gt;A surprising issue emerged.&lt;/p&gt;

&lt;p&gt;HTTP/2 still runs on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TCP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And TCP still suffers from packet loss.&lt;/p&gt;

&lt;p&gt;If a packet is lost:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TCP waits
TCP retransmits
TCP recovers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All streams share that same connection.&lt;/p&gt;

&lt;p&gt;Meaning:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stream 1 waits
Stream 2 waits
Stream 3 waits
Stream 4 waits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This became a new form of Head-of-Line Blocking.&lt;/p&gt;

&lt;p&gt;Not at the HTTP layer.&lt;/p&gt;

&lt;p&gt;At the TCP layer.&lt;/p&gt;

&lt;p&gt;HTTP/2 solved one bottleneck while exposing another.&lt;/p&gt;

&lt;p&gt;Exactly the same pattern we've seen throughout internet history.&lt;/p&gt;




&lt;h2&gt;
  
  
  Connection Pooling vs Multiplexing
&lt;/h2&gt;

&lt;p&gt;Connection Pooling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Many Connections
One Request Flow Per Connection
Parallelism Through More Connections
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection 1 -&amp;gt; Request A
Connection 2 -&amp;gt; Request B
Connection 3 -&amp;gt; Request C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Multiplexing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;One Connection
Many Streams
Parallelism Inside Connection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection 1
 ├─ Stream A
 ├─ Stream B
 ├─ Stream C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Connection Pooling optimizes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection Reuse
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Multiplexing optimizes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection Utilization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Connection Pooling says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let's create several reusable highways.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Multiplexing says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let's build one intelligent highway with many lanes.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Bigger Lesson
&lt;/h2&gt;

&lt;p&gt;Connection Pooling was never the final destination.&lt;/p&gt;

&lt;p&gt;It was an engineering workaround.&lt;/p&gt;

&lt;p&gt;Multiplexing was the architectural correction.&lt;/p&gt;

&lt;p&gt;The web spent years fighting the limitations of HTTP/1.1 by opening more and more connections.&lt;/p&gt;

&lt;p&gt;HTTP/2 changed the question entirely.&lt;/p&gt;

&lt;p&gt;Instead of asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How many connections do we need?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Engineers began asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How much work can one connection perform?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That shift seems small.&lt;/p&gt;

&lt;p&gt;But it fundamentally changed how browsers, servers, load balancers, CDNs, and modern applications communicate.&lt;/p&gt;

&lt;p&gt;And it paved the road for the next evolution of the web:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP/3 and QUIC&lt;/strong&gt;, where engineers finally attempted to eliminate TCP-level Head-of-Line Blocking itself.&lt;/p&gt;

</description>
      <category>performance</category>
      <category>tcpip</category>
      <category>networking</category>
      <category>distributedsystems</category>
    </item>
    <item>
      <title>Publish-Subscribe: How Modern Systems Scale Without Becoming a Monolith</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Thu, 30 Jul 2026 17:53:36 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/publish-subscribe-how-modern-systems-scale-without-becoming-a-monolith-4i12</link>
      <guid>https://dev.to/anik_sikder_313/publish-subscribe-how-modern-systems-scale-without-becoming-a-monolith-4i12</guid>
      <description>&lt;p&gt;When an online order is placed, the customer sees a simple message:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Your order has been confirmed."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Behind that message, however, an entire chain of events begins.&lt;/p&gt;

&lt;p&gt;The inventory must be updated.&lt;/p&gt;

&lt;p&gt;The payment must be recorded.&lt;/p&gt;

&lt;p&gt;The customer should receive an email.&lt;/p&gt;

&lt;p&gt;Analytics dashboards need updating.&lt;/p&gt;

&lt;p&gt;Fraud detection systems may need to run.&lt;/p&gt;

&lt;p&gt;Loyalty points might need to be awarded.&lt;/p&gt;

&lt;p&gt;Shipping labels may need to be generated.&lt;/p&gt;

&lt;p&gt;In small systems, developers often connect these actions directly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Service
 ├── Update Inventory
 ├── Send Email
 ├── Update Analytics
 ├── Create Invoice
 └── Start Shipping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first, this seems perfectly reasonable.&lt;/p&gt;

&lt;p&gt;Then the business grows.&lt;/p&gt;

&lt;p&gt;And everything starts breaking.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Architecture That Works Until It Doesn't
&lt;/h2&gt;

&lt;p&gt;Imagine an e-commerce platform processing 50 orders per day.&lt;/p&gt;

&lt;p&gt;A customer places an order.&lt;/p&gt;

&lt;p&gt;The Order Service directly calls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Inventory Service
Email Service
Analytics Service
Billing Service
Shipping Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything succeeds.&lt;/p&gt;

&lt;p&gt;Everyone is happy.&lt;/p&gt;

&lt;p&gt;The architecture appears simple.&lt;/p&gt;

&lt;p&gt;The problem is that simplicity is deceptive.&lt;/p&gt;

&lt;p&gt;The Order Service now depends on every downstream service.&lt;/p&gt;

&lt;p&gt;If any one of them is slow, the entire workflow becomes slow.&lt;/p&gt;

&lt;p&gt;If any one of them fails, the customer experience can fail.&lt;/p&gt;

&lt;p&gt;The more business capabilities added, the larger this dependency chain becomes.&lt;/p&gt;

&lt;p&gt;Over time the Order Service quietly transforms into the center of the entire company.&lt;/p&gt;

&lt;p&gt;Every new feature adds another dependency.&lt;/p&gt;

&lt;p&gt;Every new dependency increases risk.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Real Failure Scenario
&lt;/h2&gt;

&lt;p&gt;Consider this order workflow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer
    ↓
Order Service
    ↓
Inventory Service
    ↓
Email Service
    ↓
Analytics Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One day the Email Service experiences an outage.&lt;/p&gt;

&lt;p&gt;Now what happens?&lt;/p&gt;

&lt;p&gt;Many systems accidentally end up with behavior like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;create_order&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nf"&gt;reserve_inventory&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nf"&gt;send_confirmation_email&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nf"&gt;update_analytics&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Email fails.&lt;/p&gt;

&lt;p&gt;The transaction stops.&lt;/p&gt;

&lt;p&gt;Analytics never updates.&lt;/p&gt;

&lt;p&gt;The customer may not even receive order confirmation.&lt;/p&gt;

&lt;p&gt;A problem in one subsystem cascades across the platform.&lt;/p&gt;

&lt;p&gt;This is known as &lt;strong&gt;tight coupling&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The services are technically separate.&lt;/p&gt;

&lt;p&gt;Operationally, they are not.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Postmortem Nobody Wants to Write
&lt;/h2&gt;

&lt;p&gt;A common production incident looks something like this:&lt;/p&gt;

&lt;h3&gt;
  
  
  What happened?
&lt;/h3&gt;

&lt;p&gt;A third-party email provider experienced elevated latency.&lt;/p&gt;

&lt;h3&gt;
  
  
  Impact
&lt;/h3&gt;

&lt;p&gt;Order creation response times increased from:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;200ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;8-15 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Business Impact
&lt;/h3&gt;

&lt;p&gt;Customers abandoned checkout.&lt;/p&gt;

&lt;p&gt;Conversion rates dropped.&lt;/p&gt;

&lt;p&gt;Support tickets increased.&lt;/p&gt;

&lt;p&gt;Revenue was affected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Root Cause
&lt;/h3&gt;

&lt;p&gt;The Order Service was waiting for Email Service completion before responding.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architectural Problem
&lt;/h3&gt;

&lt;p&gt;The platform treated a non-critical operation as a critical dependency.&lt;/p&gt;




&lt;p&gt;Notice something important.&lt;/p&gt;

&lt;p&gt;The email system wasn't actually required to create the order.&lt;/p&gt;

&lt;p&gt;The order should have succeeded regardless.&lt;/p&gt;

&lt;p&gt;The architecture created the outage.&lt;/p&gt;

&lt;p&gt;Not the email provider.&lt;/p&gt;




&lt;h1&gt;
  
  
  Enter Publish-Subscribe
&lt;/h1&gt;

&lt;p&gt;Instead of directly calling every service, the Order Service publishes an event.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Service
      ↓
Order Created Event
      ↓
Message Broker
      ↓
Inventory
Email
Analytics
Billing
Shipping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the Order Service only has one responsibility:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create Order
Publish Event
Done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It no longer cares who needs the information.&lt;/p&gt;

&lt;p&gt;It simply announces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Created
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Anyone interested can react.&lt;/p&gt;

&lt;p&gt;This changes everything.&lt;/p&gt;




&lt;h2&gt;
  
  
  Thinking in Events Instead of Calls
&lt;/h2&gt;

&lt;p&gt;Traditional systems think:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Do this.
Then do that.
Then do another thing.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Event-driven systems think:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Something happened.
Whoever cares can respond.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That shift sounds small.&lt;/p&gt;

&lt;p&gt;Architecturally, it is enormous.&lt;/p&gt;

&lt;p&gt;The producer no longer knows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Who consumes the event&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How many consumers exist&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When consumers process it&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What consumers do with it&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The producer simply publishes facts.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Message Broker Becomes the Traffic Controller
&lt;/h2&gt;

&lt;p&gt;A message broker sits between producers and consumers.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Apache Kafka&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RabbitMQ&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Amazon SNS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Amazon SQS&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The broker receives events and distributes them to interested systems.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Publisher
    ↓
Broker
 ├── Inventory
 ├── Email
 ├── Billing
 ├── Analytics
 └── Fraud Detection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Services no longer communicate directly.&lt;/p&gt;

&lt;p&gt;The broker acts as the central nervous system.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Business Leaders Should Care
&lt;/h1&gt;

&lt;p&gt;Most architectural decisions eventually become business decisions.&lt;/p&gt;

&lt;p&gt;Publish-Subscribe creates advantages that executives feel directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Faster Feature Delivery
&lt;/h2&gt;

&lt;p&gt;Imagine marketing wants a loyalty points system.&lt;/p&gt;

&lt;p&gt;In a tightly coupled architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Modify Order Service
Retest Order Service
Redeploy Order Service
Risk Order Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Pub/Sub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create Loyalty Consumer
Subscribe to Order Created
Deploy Independently
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The order system remains untouched.&lt;/p&gt;

&lt;p&gt;New business capabilities can be added safely.&lt;/p&gt;




&lt;h2&gt;
  
  
  Reduced Revenue Risk
&lt;/h2&gt;

&lt;p&gt;If Analytics fails:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Orders continue.
Payments continue.
Customers continue.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only analytics is affected.&lt;/p&gt;

&lt;p&gt;The failure is isolated.&lt;/p&gt;

&lt;p&gt;This dramatically reduces blast radius.&lt;/p&gt;




&lt;h2&gt;
  
  
  Better Organizational Scaling
&lt;/h2&gt;

&lt;p&gt;As companies grow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Payments Team
Inventory Team
Data Team
Growth Team
Customer Team
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each team can consume events independently.&lt;/p&gt;

&lt;p&gt;Teams become less dependent on one another.&lt;/p&gt;

&lt;p&gt;This increases development velocity.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Developers Love Event-Driven Systems
&lt;/h1&gt;

&lt;p&gt;Developers eventually discover a painful truth:&lt;/p&gt;

&lt;p&gt;The hardest part of scaling is not traffic.&lt;/p&gt;

&lt;p&gt;It's dependencies.&lt;/p&gt;

&lt;p&gt;Pub/Sub removes many of them.&lt;/p&gt;




&lt;h2&gt;
  
  
  Loose Coupling
&lt;/h2&gt;

&lt;p&gt;Without Pub/Sub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Service
    ↓
Inventory
    ↓
Email
    ↓
Analytics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With Pub/Sub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Service
      ↓
Broker
      ↓
Consumers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The producer has one dependency.&lt;/p&gt;

&lt;p&gt;Instead of ten.&lt;/p&gt;




&lt;h2&gt;
  
  
  Independent Deployments
&lt;/h2&gt;

&lt;p&gt;A team can deploy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Recommendation Engine
Fraud Detection
Customer Segmentation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;without touching the ordering system.&lt;/p&gt;

&lt;p&gt;This dramatically reduces deployment risk.&lt;/p&gt;




&lt;h2&gt;
  
  
  Better Resilience
&lt;/h2&gt;

&lt;p&gt;Suppose Billing Service crashes.&lt;/p&gt;

&lt;p&gt;The broker stores events.&lt;/p&gt;

&lt;p&gt;When Billing returns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Created Event #1001
Order Created Event #1002
Order Created Event #1003
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can still be processed.&lt;/p&gt;

&lt;p&gt;The platform recovers automatically.&lt;/p&gt;




&lt;h1&gt;
  
  
  But Publish-Subscribe Creates New Problems
&lt;/h1&gt;

&lt;p&gt;Many architecture articles stop at benefits.&lt;/p&gt;

&lt;p&gt;Production systems do not.&lt;/p&gt;

&lt;p&gt;Every architectural gain introduces tradeoffs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Problem #1: Eventual Consistency
&lt;/h2&gt;

&lt;p&gt;In synchronous systems:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Created
Inventory Updated
Response Returned
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything happens immediately.&lt;/p&gt;

&lt;p&gt;In Pub/Sub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Created
Response Returned

Inventory Updated Later
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is now a time gap.&lt;/p&gt;

&lt;p&gt;Systems may temporarily disagree.&lt;/p&gt;

&lt;p&gt;This is called:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Eventual Consistency&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One of the most misunderstood realities of distributed systems.&lt;/p&gt;




&lt;h2&gt;
  
  
  Problem #2: Duplicate Events
&lt;/h2&gt;

&lt;p&gt;Networks fail.&lt;/p&gt;

&lt;p&gt;Retries happen.&lt;/p&gt;

&lt;p&gt;Consumers crash.&lt;/p&gt;

&lt;p&gt;The same event may arrive twice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Created #123
Order Created #123
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Consumers must be idempotent.&lt;/p&gt;

&lt;p&gt;Otherwise:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Inventory reduced twice
Customer charged twice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Production incidents happen.&lt;/p&gt;




&lt;h2&gt;
  
  
  Problem #3: Observability Becomes Hard
&lt;/h2&gt;

&lt;p&gt;In monolithic workflows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request → Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Easy to trace.&lt;/p&gt;

&lt;p&gt;In event-driven systems:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Created
    ↓
Inventory Updated
    ↓
Billing Created
    ↓
Email Sent
    ↓
Analytics Updated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A single customer action can generate dozens of events.&lt;/p&gt;

&lt;p&gt;Tracking failures becomes significantly harder.&lt;/p&gt;

&lt;p&gt;This is why mature organizations invest heavily in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Distributed tracing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Correlation IDs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Event monitoring&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Audit logs&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  How Large Platforms Actually Think
&lt;/h1&gt;

&lt;p&gt;The most successful architectures do not ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Which service should call which?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead they ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What business events exist?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Created
Payment Authorized
Shipment Created
Invoice Generated
User Registered
Subscription Renewed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These events become the language of the business.&lt;/p&gt;

&lt;p&gt;Systems are then built around reacting to those events.&lt;/p&gt;

&lt;p&gt;The result is an architecture that grows with the company instead of fighting it.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Real Lesson
&lt;/h1&gt;

&lt;p&gt;Publish-Subscribe is not primarily about messaging.&lt;/p&gt;

&lt;p&gt;It is about organizational scalability.&lt;/p&gt;

&lt;p&gt;It allows systems to evolve without every team depending on every other team.&lt;/p&gt;

&lt;p&gt;It reduces blast radius.&lt;/p&gt;

&lt;p&gt;It improves resilience.&lt;/p&gt;

&lt;p&gt;It accelerates feature delivery.&lt;/p&gt;

&lt;p&gt;But it also introduces complexity, eventual consistency, and operational challenges that teams must be prepared to handle.&lt;/p&gt;

&lt;p&gt;The companies that scale successfully are rarely the ones with the most services.&lt;/p&gt;

&lt;p&gt;They are the ones with the clearest events.&lt;/p&gt;

&lt;p&gt;Because once systems start speaking in events instead of direct dependencies, growth becomes far easier to sustain.&lt;/p&gt;




&lt;h3&gt;
  
  
  Key Takeaway
&lt;/h3&gt;

&lt;p&gt;A mature architecture doesn't ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Who should I call next?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What happened?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That single shift from commands to events is one of the biggest architectural transitions in modern software systems.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>pubsub</category>
      <category>softwareengineering</category>
      <category>distributedsystems</category>
    </item>
    <item>
      <title>Server-Sent Events (SSE): When the Web Learned to Listen</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Mon, 27 Jul 2026 16:58:10 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/server-sent-events-sse-when-the-web-learned-to-listen-1njb</link>
      <guid>https://dev.to/anik_sikder_313/server-sent-events-sse-when-the-web-learned-to-listen-1njb</guid>
      <description>&lt;p&gt;For years, the web operated on a simple principle:&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="nx"&gt;Browser&lt;/span&gt; &lt;span class="nx"&gt;asks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="nx"&gt;Server&lt;/span&gt; &lt;span class="nx"&gt;answers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="nx"&gt;Connection&lt;/span&gt; &lt;span class="nx"&gt;closes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This model worked perfectly when websites were mostly documents.&lt;/p&gt;

&lt;p&gt;A user opened a page.&lt;/p&gt;

&lt;p&gt;The browser requested data.&lt;/p&gt;

&lt;p&gt;The server responded.&lt;/p&gt;

&lt;p&gt;Everyone moved on.&lt;/p&gt;

&lt;p&gt;But then the internet changed.&lt;/p&gt;

&lt;p&gt;Businesses wanted live stock prices.&lt;/p&gt;

&lt;p&gt;Operations teams wanted real-time monitoring dashboards.&lt;/p&gt;

&lt;p&gt;Support agents wanted instant notifications.&lt;/p&gt;

&lt;p&gt;Users expected applications to update the moment something happened.&lt;/p&gt;

&lt;p&gt;The old request-response model suddenly felt too slow.&lt;/p&gt;

&lt;p&gt;The challenge wasn't that servers couldn't produce updates quickly.&lt;/p&gt;

&lt;p&gt;The challenge was getting those updates to users immediately.&lt;/p&gt;

&lt;p&gt;And that led engineers down a fascinating path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;Request-Response
        ↓
Polling
        ↓
Long Polling
        ↓
Server-Sent Events (SSE)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SSE wasn't just another protocol.&lt;/p&gt;

&lt;p&gt;It was the web's attempt to become truly real-time while still staying within the familiar world of HTTP.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Business Problem Nobody Could Ignore
&lt;/h2&gt;

&lt;p&gt;Imagine you're running a stock trading platform.&lt;/p&gt;

&lt;p&gt;At market open, prices can change thousands of times every second.&lt;/p&gt;

&lt;p&gt;Your users expect something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;AAPL&lt;/span&gt;  &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mf"&gt;202.15&lt;/span&gt;
&lt;span class="n"&gt;MSFT&lt;/span&gt;  &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mf"&gt;541.22&lt;/span&gt;
&lt;span class="n"&gt;NVDA&lt;/span&gt;  &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mf"&gt;193.47&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And when prices change:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;AAPL&lt;/span&gt;  &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mf"&gt;202.31&lt;/span&gt;
&lt;span class="n"&gt;MSFT&lt;/span&gt;  &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mf"&gt;541.40&lt;/span&gt;
&lt;span class="n"&gt;NVDA&lt;/span&gt;  &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mf"&gt;193.61&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The update should appear instantly.&lt;/p&gt;

&lt;p&gt;Not five seconds later.&lt;/p&gt;

&lt;p&gt;Not after a page refresh.&lt;/p&gt;

&lt;p&gt;Not after clicking a button.&lt;/p&gt;

&lt;p&gt;Immediately.&lt;/p&gt;

&lt;p&gt;From a business perspective, this sounds simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Show customers the latest information as soon as it changes."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From a system design perspective, it's much harder.&lt;/p&gt;

&lt;p&gt;How does the browser know when something changes?&lt;/p&gt;




&lt;h2&gt;
  
  
  The First Attempt: Polling
&lt;/h2&gt;

&lt;p&gt;The most obvious solution was polling.&lt;/p&gt;

&lt;p&gt;The browser repeatedly asked:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Any updates?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every few seconds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;Browser&lt;/span&gt;
    &lt;span class="err"&gt;│&lt;/span&gt;
    &lt;span class="err"&gt;├──&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;
    &lt;span class="err"&gt;├──&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;
    &lt;span class="err"&gt;├──&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;
    &lt;span class="err"&gt;├──&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;
    &lt;span class="err"&gt;└──&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most of the time the server replied:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nothing changed.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Imagine 100,000 users checking every second.&lt;/p&gt;

&lt;p&gt;Even when no new information existed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;000&lt;/span&gt; &lt;span class="nx"&gt;Requests&lt;/span&gt;
          &lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;000&lt;/span&gt; &lt;span class="nx"&gt;Responses&lt;/span&gt;
          &lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="nx"&gt;No&lt;/span&gt; &lt;span class="nx"&gt;Useful&lt;/span&gt; &lt;span class="nx"&gt;Data&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The system was working hard to accomplish almost nothing.&lt;/p&gt;

&lt;p&gt;The architecture scaled poorly.&lt;/p&gt;

&lt;p&gt;Infrastructure costs increased.&lt;/p&gt;

&lt;p&gt;Servers processed millions of unnecessary requests.&lt;/p&gt;

&lt;p&gt;Engineers needed something better.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Second Attempt: Long Polling
&lt;/h2&gt;

&lt;p&gt;Long Polling improved efficiency.&lt;/p&gt;

&lt;p&gt;Instead of responding immediately, the server waited.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;Browser&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;
       &lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="n"&gt;Server&lt;/span&gt; &lt;span class="n"&gt;Waits&lt;/span&gt;
       &lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="n"&gt;Event&lt;/span&gt; &lt;span class="n"&gt;Happens&lt;/span&gt;
       &lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="n"&gt;Server&lt;/span&gt; &lt;span class="n"&gt;Responds&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a stock price changed, the server responded instantly.&lt;/p&gt;

&lt;p&gt;If nothing happened, the connection stayed open.&lt;/p&gt;

&lt;p&gt;This dramatically reduced useless requests.&lt;/p&gt;

&lt;p&gt;But Long Polling still had a problem.&lt;/p&gt;

&lt;p&gt;After every response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Response Received
        ↓
Create New Request
        ↓
Wait Again
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The cycle never truly disappeared.&lt;/p&gt;

&lt;p&gt;The browser was still repeatedly initiating communication.&lt;/p&gt;

&lt;p&gt;Just less frequently.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Simple Question That Changed Everything
&lt;/h2&gt;

&lt;p&gt;Eventually engineers asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why is the browser constantly asking for updates?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If the server already knows when something changes, why not let the server send the update directly?&lt;/p&gt;

&lt;p&gt;That question led to Server-Sent Events.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Server-Sent Events (SSE)?
&lt;/h2&gt;

&lt;p&gt;Server-Sent Events allow a browser to open a single HTTP connection and keep it alive.&lt;/p&gt;

&lt;p&gt;Instead of repeatedly asking for information, the browser simply listens.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;Browser&lt;/span&gt;
     &lt;span class="err"&gt;│&lt;/span&gt;
     &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="k"&gt;Open&lt;/span&gt; &lt;span class="k"&gt;Connection&lt;/span&gt;
     &lt;span class="err"&gt;▼&lt;/span&gt;
&lt;span class="n"&gt;Server&lt;/span&gt;
     &lt;span class="err"&gt;│&lt;/span&gt;
     &lt;span class="err"&gt;├──&lt;/span&gt; &lt;span class="n"&gt;Event&lt;/span&gt;
     &lt;span class="err"&gt;├──&lt;/span&gt; &lt;span class="n"&gt;Event&lt;/span&gt;
     &lt;span class="err"&gt;├──&lt;/span&gt; &lt;span class="n"&gt;Event&lt;/span&gt;
     &lt;span class="err"&gt;└──&lt;/span&gt; &lt;span class="n"&gt;Event&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server pushes updates whenever something happens.&lt;/p&gt;

&lt;p&gt;No polling loop.&lt;/p&gt;

&lt;p&gt;No repeated requests.&lt;/p&gt;

&lt;p&gt;No constant reconnecting.&lt;/p&gt;

&lt;p&gt;The browser becomes a subscriber.&lt;/p&gt;

&lt;p&gt;The server becomes a publisher.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Different Way of Thinking
&lt;/h2&gt;

&lt;p&gt;Polling asks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Did anything happen?
Did anything happen?
Did anything happen?
Did anything happen?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SSE says:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Tell me when something happens.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That sounds like a small difference.&lt;/p&gt;

&lt;p&gt;Architecturally, it's huge.&lt;/p&gt;




&lt;h2&gt;
  
  
  Inside a Real SSE Connection
&lt;/h2&gt;

&lt;p&gt;From the browser's perspective, creating an SSE connection is surprisingly simple.&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;events&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;EventSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/events&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser sends a normal HTTP request.&lt;/p&gt;

&lt;p&gt;The server responds with a special content type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;stream&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But unlike a normal HTTP response, the server doesn't close the connection.&lt;/p&gt;

&lt;p&gt;Instead, it keeps streaming data.&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="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;New&lt;/span&gt; &lt;span class="nx"&gt;Order&lt;/span&gt; &lt;span class="nx"&gt;Created&lt;/span&gt;

&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Payment&lt;/span&gt; &lt;span class="nx"&gt;Received&lt;/span&gt;

&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Shipment&lt;/span&gt; &lt;span class="nx"&gt;Dispatched&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser receives each event immediately.&lt;/p&gt;

&lt;p&gt;The connection remains open.&lt;/p&gt;

&lt;p&gt;The stream continues.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real System Example: E-Commerce Operations Dashboard
&lt;/h2&gt;

&lt;p&gt;Consider a large e-commerce company.&lt;/p&gt;

&lt;p&gt;The operations team monitors incoming orders in real time.&lt;/p&gt;

&lt;p&gt;Without SSE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dashboard
    ↓
Poll Every 5 Seconds
    ↓
Check For New Orders
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A customer places an order.&lt;/p&gt;

&lt;p&gt;The operations team might not see it for several seconds.&lt;/p&gt;

&lt;p&gt;With SSE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer Places Order
          ↓
Order Service
          ↓
Event Bus
          ↓
Notification Service
          ↓
SSE Gateway
          ↓
Dashboard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The moment the order is created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;New Order Received
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;appears on the dashboard.&lt;/p&gt;

&lt;p&gt;No refresh required.&lt;/p&gt;

&lt;p&gt;No polling required.&lt;/p&gt;

&lt;p&gt;To the user, the system feels alive.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real System Example: Monitoring Platforms
&lt;/h2&gt;

&lt;p&gt;Modern monitoring tools often display:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;CPU utilization&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Memory usage&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Error rates&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Request latency&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Active users&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Imagine a platform monitoring thousands of servers.&lt;/p&gt;

&lt;p&gt;Every metric changes continuously.&lt;/p&gt;

&lt;p&gt;Polling every few seconds creates unnecessary traffic.&lt;/p&gt;

&lt;p&gt;Instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Monitoring Agent
  ↓
Metrics Service
  ↓
Event Stream
  ↓
SSE
  ↓
Dashboard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As metrics change, updates appear instantly.&lt;/p&gt;

&lt;p&gt;Operations teams gain near real-time visibility into system health.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real System Example: AI Response Streaming
&lt;/h2&gt;

&lt;p&gt;Today, one of the most recognizable uses of SSE is AI.&lt;/p&gt;

&lt;p&gt;When you ask ChatGPT a question, the model doesn't generate an entire response instantly.&lt;/p&gt;

&lt;p&gt;It generates tokens one at a time.&lt;/p&gt;

&lt;p&gt;Without streaming:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Question
       ↓
Wait 10 Seconds
       ↓
Entire Answer Appears
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the user's perspective:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System feels slow.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With SSE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Question
       ↓
Wait 1 Second
       ↓
Words Begin Appearing
       ↓
Response Continues Streaming
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The total generation time may still be ten seconds.&lt;/p&gt;

&lt;p&gt;But the experience feels dramatically faster.&lt;/p&gt;

&lt;p&gt;This reveals an important system design principle:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Users experience latency differently than systems measure latency.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A ten-second wait feels frustrating.&lt;/p&gt;

&lt;p&gt;A ten-second stream feels interactive.&lt;/p&gt;

&lt;p&gt;SSE helps bridge that gap.&lt;/p&gt;

&lt;p&gt;This is one reason AI products feel conversational rather than delayed.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Product Teams Love SSE
&lt;/h2&gt;

&lt;p&gt;From a product perspective, SSE improves perceived responsiveness.&lt;/p&gt;

&lt;p&gt;Users don't care how elegant your architecture is.&lt;/p&gt;

&lt;p&gt;They care about what they see.&lt;/p&gt;

&lt;p&gt;Compare:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Click
     ↓
Wait
     ↓
Wait
     ↓
Wait
     ↓
Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Versus:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Click
     ↓
Response Starts
     ↓
More Content
     ↓
More Content
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second experience feels dramatically faster even if total processing time is identical.&lt;/p&gt;

&lt;p&gt;That translates directly into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Better engagement&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Better user satisfaction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Higher retention&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;More trust in the product&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why Developers Love SSE
&lt;/h2&gt;

&lt;p&gt;One reason SSE became popular is that it works with existing HTTP infrastructure.&lt;/p&gt;

&lt;p&gt;There is no entirely new protocol to learn.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser
   ↓
HTTP
   ↓
Load Balancer
   ↓
Reverse Proxy
   ↓
Application Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything already understands HTTP.&lt;/p&gt;

&lt;p&gt;This makes adoption much easier.&lt;/p&gt;

&lt;p&gt;Developers also benefit from automatic reconnection.&lt;/p&gt;

&lt;p&gt;If a connection drops:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection Lost
        ↓
Browser Detects Failure
        ↓
Automatic Reconnect
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser handles much of the recovery logic automatically.&lt;/p&gt;

&lt;p&gt;Less code.&lt;/p&gt;

&lt;p&gt;Less complexity.&lt;/p&gt;

&lt;p&gt;Fewer edge cases.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Architects Choose SSE
&lt;/h2&gt;

&lt;p&gt;A common question is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why not just use WebSockets?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The answer depends on communication patterns.&lt;/p&gt;

&lt;p&gt;Consider stock prices:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Market
   ↓
User
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or monitoring dashboards:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server
   ↓
Dashboard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or AI response streaming:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Model
   ↓
Browser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In all of these systems:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server talks constantly.
Client rarely talks.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SSE fits naturally.&lt;/p&gt;

&lt;p&gt;WebSockets support two-way communication:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client ↔ Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But many systems don't need that capability.&lt;/p&gt;

&lt;p&gt;Using WebSockets in these situations can introduce complexity without delivering meaningful benefits.&lt;/p&gt;

&lt;p&gt;One of the most important lessons in architecture is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The best solution is not the most powerful one. It's the simplest one that satisfies the requirements.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For many one-way streaming workloads, SSE is exactly that solution.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hidden Challenge
&lt;/h2&gt;

&lt;p&gt;Every architectural improvement introduces a new bottleneck.&lt;/p&gt;

&lt;p&gt;Polling creates too many requests.&lt;/p&gt;

&lt;p&gt;SSE solves that problem.&lt;/p&gt;

&lt;p&gt;But it introduces another.&lt;/p&gt;

&lt;p&gt;Persistent connections.&lt;/p&gt;

&lt;p&gt;Imagine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;500,000 Active Users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Polling might create:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Millions of Requests Per Minute
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SSE creates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;500,000 Open Connections
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The request problem improves.&lt;/p&gt;

&lt;p&gt;The connection management problem appears.&lt;/p&gt;

&lt;p&gt;Infrastructure teams now worry about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Memory consumption&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;File descriptor limits&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Load balancer behavior&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Proxy timeouts&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reconnection storms&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Horizontal scaling&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From an operations perspective:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Fewer Requests
≠
Less Work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The workload simply shifts.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where SSE Starts To Break Down
&lt;/h2&gt;

&lt;p&gt;SSE is excellent for one-way communication.&lt;/p&gt;

&lt;p&gt;But some systems require continuous communication in both directions.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Chat applications&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiplayer games&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Collaborative editors&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Trading platforms&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Video conferencing systems&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These applications need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client ↔ Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;communication.&lt;/p&gt;

&lt;p&gt;SSE only provides:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server → Client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At that point, WebSockets usually become the better architectural choice.&lt;/p&gt;




&lt;h2&gt;
  
  
  What SSE Really Changed
&lt;/h2&gt;

&lt;p&gt;Server-Sent Events didn't introduce a revolutionary new protocol.&lt;/p&gt;

&lt;p&gt;Its impact came from a much simpler idea:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stop asking repeatedly.

Start listening continuously.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That shift helped transform the web from a collection of documents into a platform for real-time experiences.&lt;/p&gt;

&lt;p&gt;Stock prices could update instantly.&lt;/p&gt;

&lt;p&gt;Dashboards could refresh automatically.&lt;/p&gt;

&lt;p&gt;Notifications could arrive the moment events occurred.&lt;/p&gt;

&lt;p&gt;AI systems could stream responses as they were generated.&lt;/p&gt;

&lt;p&gt;The technology itself is relatively simple.&lt;/p&gt;

&lt;p&gt;The effect on user experience is enormous.&lt;/p&gt;

&lt;p&gt;And that is often the hallmark of great system design:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A small architectural change that fundamentally improves how users experience a system.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Evolution Continues
&lt;/h2&gt;

&lt;p&gt;The web's journey toward real-time communication didn't stop with SSE.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request-Response
   ↓
Polling
   ↓
Long Polling
   ↓
Server-Sent Events (SSE)
   ↓
WebSockets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SSE taught the web how to stream information.&lt;/p&gt;

&lt;p&gt;WebSockets would teach the web how to have a conversation.&lt;/p&gt;

&lt;p&gt;And that's where the next chapter begins.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>architecture</category>
      <category>realtimesystems</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Long Polling : The First Time the Web Tried to Feel Alive</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Sat, 25 Jul 2026 17:22:07 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/long-polling-the-first-time-the-web-tried-to-feel-alive-2f67</link>
      <guid>https://dev.to/anik_sikder_313/long-polling-the-first-time-the-web-tried-to-feel-alive-2f67</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/anik_sikder_313/polling-when-simple-starts-sending-millions-of-requests-k17"&gt;previous article&lt;/a&gt;, we explored traditional polling.&lt;/p&gt;

&lt;p&gt;At first glance, polling seemed like a reasonable solution.&lt;/p&gt;

&lt;p&gt;A browser simply asked the server:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Anything new?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If nothing changed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"updates"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser waited a few seconds and asked again.&lt;/p&gt;

&lt;p&gt;Simple.&lt;/p&gt;

&lt;p&gt;Predictable.&lt;/p&gt;

&lt;p&gt;Easy to implement.&lt;/p&gt;

&lt;p&gt;For small systems, it worked perfectly.&lt;/p&gt;

&lt;p&gt;But then users changed.&lt;/p&gt;

&lt;p&gt;And suddenly, polling became a business problem.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Incident Nobody Talks About
&lt;/h2&gt;

&lt;p&gt;Imagine it's 2008.&lt;/p&gt;

&lt;p&gt;You're part of an engineering team building a rapidly growing social platform.&lt;/p&gt;

&lt;p&gt;Your CEO walks into the room and says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Users are complaining that messages feel slow."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The database is healthy.&lt;/p&gt;

&lt;p&gt;The servers are healthy.&lt;/p&gt;

&lt;p&gt;The network is healthy.&lt;/p&gt;

&lt;p&gt;Yet users are unhappy.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because technology was measuring milliseconds.&lt;/p&gt;

&lt;p&gt;Users were measuring feelings.&lt;/p&gt;

&lt;p&gt;To them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Message Sent
       │
       ▼
Nothing Happens
       │
       ▼
3 Seconds Later...
       │
       ▼
Message Appears
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application felt broken.&lt;/p&gt;

&lt;p&gt;Not because it was slow.&lt;/p&gt;

&lt;p&gt;Because it wasn't instant.&lt;/p&gt;

&lt;p&gt;And expectations were changing.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Product Team's Suggestion
&lt;/h2&gt;

&lt;p&gt;The product manager proposes a simple solution.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Let's poll more often."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead of every 10 seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Poll Every 1 Second
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everyone nods.&lt;/p&gt;

&lt;p&gt;Problem solved.&lt;/p&gt;

&lt;p&gt;Or so they think.&lt;/p&gt;

&lt;p&gt;Three weeks later, infrastructure costs spike.&lt;/p&gt;

&lt;p&gt;Monitoring dashboards light up.&lt;/p&gt;

&lt;p&gt;Operations teams start asking questions.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Postmortem
&lt;/h2&gt;

&lt;p&gt;After investigation, engineers discover something surprising.&lt;/p&gt;

&lt;p&gt;The system isn't struggling because users are sending messages.&lt;/p&gt;

&lt;p&gt;The system is struggling because users are asking if there are messages.&lt;/p&gt;

&lt;p&gt;Imagine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;200,000 Users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each user polls every second.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;200,000 Requests / Second
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now imagine only 2% of those requests actually contain new information.&lt;/p&gt;

&lt;p&gt;That means:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;196,000 Requests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;exist solely to hear:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"No updates."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Every second.&lt;/p&gt;

&lt;p&gt;All day.&lt;/p&gt;

&lt;p&gt;Every day.&lt;/p&gt;

&lt;p&gt;The servers are spending most of their time answering questions nobody needed to ask.&lt;/p&gt;




&lt;h2&gt;
  
  
  Looking at the Problem Like an Architect
&lt;/h2&gt;

&lt;p&gt;A junior developer might see:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Too many requests."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A system architect sees:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The communication model is wrong."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The real issue wasn't server performance.&lt;/p&gt;

&lt;p&gt;The issue was this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client
   │
   ▼
Keeps Asking
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even when the server already knows nothing has changed.&lt;/p&gt;

&lt;p&gt;The architecture was forcing unnecessary conversations.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Different Idea
&lt;/h2&gt;

&lt;p&gt;One engineer proposes something unusual.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client:
Anything new?

Server:
No.

Client:
Anything new?

Server:
No.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What if the conversation became:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client:
Tell me when something changes.

Server:
Okay. I'll wait.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's exactly what Long Polling became.&lt;/p&gt;




&lt;h2&gt;
  
  
  Long Polling Explained Like a Recruiter
&lt;/h2&gt;

&lt;p&gt;Imagine you're hiring for a company.&lt;/p&gt;

&lt;p&gt;Traditional polling looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Recruiter:
Any new applicants?

System:
No.

Recruiter:
Any new applicants?

System:
No.

Recruiter:
Any new applicants?

System:
No.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Long Polling changes the workflow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Recruiter:
Call me when somebody applies.

System:
Understood.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hours later:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;New Applicant Submitted
         │
         ▼
Phone Rings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The recruiter isn't constantly checking.&lt;/p&gt;

&lt;p&gt;The system notifies them only when something important happens.&lt;/p&gt;

&lt;p&gt;That is Long Polling.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Actually Happens Under the Hood
&lt;/h2&gt;

&lt;p&gt;Let's say a user opens a chat application.&lt;/p&gt;

&lt;p&gt;The browser sends:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /messages
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Normally the server would immediately respond.&lt;/p&gt;

&lt;p&gt;With Long Polling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request Arrives
       │
       ▼
Server Checks For Updates
       │
       ▼
No Updates Found
       │
       ▼
Keep Connection Open
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the server waits.&lt;/p&gt;

&lt;p&gt;Maybe 5 seconds.&lt;/p&gt;

&lt;p&gt;Maybe 20 seconds.&lt;/p&gt;

&lt;p&gt;Maybe 60 seconds.&lt;/p&gt;

&lt;p&gt;Suddenly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;New Message Arrives
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server immediately responds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Hello!"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser receives the message.&lt;/p&gt;

&lt;p&gt;Then instantly creates another waiting request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request
  │
Wait
  │
Response
  │
Reconnect
  │
Wait Again
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To the user:&lt;/p&gt;

&lt;p&gt;It feels instantaneous.&lt;/p&gt;

&lt;p&gt;To the infrastructure:&lt;/p&gt;

&lt;p&gt;It's still HTTP.&lt;/p&gt;

&lt;p&gt;Just used differently.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Business Leaders Loved It
&lt;/h2&gt;

&lt;p&gt;From a buyer's perspective, Long Polling created something valuable:&lt;/p&gt;

&lt;h3&gt;
  
  
  Faster Customer Support
&lt;/h3&gt;

&lt;p&gt;Without Long Polling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer Sends Message
       │
       ▼
Agent Sees It 10 Seconds Later
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With Long Polling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer Sends Message
       │
       ▼
Agent Sees It Almost Immediately
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Response times improve.&lt;/p&gt;

&lt;p&gt;Customer satisfaction improves.&lt;/p&gt;

&lt;p&gt;Support metrics improve.&lt;/p&gt;

&lt;p&gt;Revenue often improves.&lt;/p&gt;

&lt;p&gt;Nobody buying the software cares about Long Polling.&lt;/p&gt;

&lt;p&gt;They care that customers stop complaining.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Developers Loved It
&lt;/h2&gt;

&lt;p&gt;Because it solved a real problem without requiring a new protocol.&lt;/p&gt;

&lt;p&gt;Developers already had:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP
Load Balancers
Reverse Proxies
Application Servers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No major infrastructure changes were needed.&lt;/p&gt;

&lt;p&gt;Most teams could implement Long Polling with existing technology.&lt;/p&gt;

&lt;p&gt;That made adoption relatively easy.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Operations Teams Hated It
&lt;/h2&gt;

&lt;p&gt;Because Long Polling quietly moved pressure somewhere else.&lt;/p&gt;

&lt;p&gt;Traditional polling creates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Many Requests
Short Connections
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Long Polling creates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Fewer Requests
Long-Lived Connections
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first this sounds better.&lt;/p&gt;

&lt;p&gt;Until your system reaches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;500,000 Active Users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;500,000 Open Connections
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;waiting simultaneously.&lt;/p&gt;

&lt;p&gt;The CPU usage might decrease.&lt;/p&gt;

&lt;p&gt;But memory usage increases.&lt;/p&gt;

&lt;p&gt;Connection tracking increases.&lt;/p&gt;

&lt;p&gt;Load balancer complexity increases.&lt;/p&gt;

&lt;p&gt;Timeout management becomes critical.&lt;/p&gt;

&lt;p&gt;The bottleneck simply moved.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Scaling Wall
&lt;/h2&gt;

&lt;p&gt;Around this point, many companies hit a new challenge.&lt;/p&gt;

&lt;p&gt;Imagine a global chat application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 Million Connected Users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every user has:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;One Waiting Request
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the infrastructure must remember:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Who is connected&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Which request belongs to whom&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How long they've been waiting&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When to timeout&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When to reconnect&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The system starts behaving less like a website.&lt;/p&gt;

&lt;p&gt;And more like a real-time communication platform.&lt;/p&gt;

&lt;p&gt;That distinction becomes important.&lt;/p&gt;

&lt;p&gt;Because HTTP was never designed for this.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Architect's Lesson
&lt;/h2&gt;

&lt;p&gt;Long Polling teaches one of the most important lessons in software architecture.&lt;/p&gt;

&lt;p&gt;The first solution that works is rarely the final solution.&lt;/p&gt;

&lt;p&gt;The evolution looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Polling
    │
    ▼
Too Much Waste
    │
    ▼
Long Polling
    │
    ▼
Too Many Open Connections
    │
    ▼
Search For Something Better
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Long Polling wasn't the destination.&lt;/p&gt;

&lt;p&gt;It was the bridge.&lt;/p&gt;

&lt;p&gt;A brilliant compromise between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;User expectations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Existing browser capabilities&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Available infrastructure&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Engineering constraints&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For nearly a decade, some of the largest systems on the internet relied on that compromise.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Question That Changed Everything
&lt;/h2&gt;

&lt;p&gt;Eventually engineers started asking a different question.&lt;/p&gt;

&lt;p&gt;Not:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How can the client ask more efficiently?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Why is the client asking at all?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What if the connection stayed open permanently?&lt;/p&gt;

&lt;p&gt;What if the server could speak first?&lt;/p&gt;

&lt;p&gt;What if communication flowed both directions?&lt;/p&gt;

&lt;p&gt;That question led to one of the biggest shifts in modern web architecture:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WebSockets.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And that's where our story goes next.&lt;/p&gt;

</description>
      <category>backend</category>
      <category>softwareengineering</category>
      <category>systemdesign</category>
      <category>security</category>
    </item>
    <item>
      <title>Polling: When "Simple" Starts Sending Millions of Requests</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Fri, 24 Jul 2026 15:40:20 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/polling-when-simple-starts-sending-millions-of-requests-k17</link>
      <guid>https://dev.to/anik_sikder_313/polling-when-simple-starts-sending-millions-of-requests-k17</guid>
      <description>&lt;p&gt;Imagine you're building a SaaS platform.&lt;/p&gt;

&lt;p&gt;Nothing fancy.&lt;/p&gt;

&lt;p&gt;Just a notification bell in the top-right corner.&lt;/p&gt;

&lt;p&gt;When someone receives a new message, completes a task, or gets assigned work, the bell should update.&lt;/p&gt;

&lt;p&gt;Seems simple, right?&lt;/p&gt;

&lt;p&gt;A developer might propose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Every 5 seconds:

GET /notifications
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Done.&lt;/p&gt;

&lt;p&gt;Feature shipped.&lt;/p&gt;

&lt;p&gt;Customers happy.&lt;/p&gt;

&lt;p&gt;Everyone goes home.&lt;/p&gt;

&lt;p&gt;For a while.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Architecture Looks Innocent
&lt;/h2&gt;

&lt;p&gt;With 10 users online, the system behaves exactly as expected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10 Users
   ↓
GET /notifications
Every 5 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nobody notices a problem.&lt;/p&gt;

&lt;p&gt;The database barely feels the load.&lt;/p&gt;

&lt;p&gt;The servers are mostly idle.&lt;/p&gt;

&lt;p&gt;The feature appears successful.&lt;/p&gt;

&lt;p&gt;This is where many architectural mistakes begin.&lt;/p&gt;

&lt;p&gt;Not because the solution is wrong.&lt;/p&gt;

&lt;p&gt;But because it works.&lt;/p&gt;




&lt;h2&gt;
  
  
  Success Changes the Equation
&lt;/h2&gt;

&lt;p&gt;Six months later, your product gains traction.&lt;/p&gt;

&lt;p&gt;Now you have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5,000 active users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code hasn't changed.&lt;/p&gt;

&lt;p&gt;The infrastructure hasn't changed.&lt;/p&gt;

&lt;p&gt;The polling interval is still:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Every 5 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the system is now processing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5,000 × 12 requests/minute

= 60,000 requests per minute
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3.6 million requests per hour
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a notification system.&lt;/p&gt;

&lt;p&gt;Not file uploads.&lt;/p&gt;

&lt;p&gt;Not payments.&lt;/p&gt;

&lt;p&gt;Not business-critical operations.&lt;/p&gt;

&lt;p&gt;Just checking whether something changed.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hidden Question
&lt;/h2&gt;

&lt;p&gt;Here's the question experienced engineers ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How many of those requests actually matter?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's assume only 5% of users receive a notification during a given minute.&lt;/p&gt;

&lt;p&gt;That means 95% of requests exist only to discover:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"notifications"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The system is spending CPU, memory, network bandwidth, and database resources simply confirming that nothing happened.&lt;/p&gt;

&lt;p&gt;From a business perspective, that's interesting.&lt;/p&gt;

&lt;p&gt;Because the company isn't paying for useful work.&lt;/p&gt;

&lt;p&gt;It's paying for uncertainty.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Companies Still Choose Polling
&lt;/h2&gt;

&lt;p&gt;At this point, many articles declare:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Polling is bad."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's the wrong conclusion.&lt;/p&gt;

&lt;p&gt;Companies don't buy architectures.&lt;/p&gt;

&lt;p&gt;Companies buy outcomes.&lt;/p&gt;

&lt;p&gt;Polling remains popular because it optimizes for something businesses care deeply about:&lt;/p&gt;

&lt;h3&gt;
  
  
  Speed of Delivery
&lt;/h3&gt;

&lt;p&gt;A startup founder rarely asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Is this the most elegant distributed systems solution?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;They ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Can we launch this feature next week?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Polling is attractive because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Easy to implement&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy to debug&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy to maintain&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Works through almost every network and firewall&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Requires minimal infrastructure&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In other words:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Higher operational cost
↓
Lower development cost
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And early-stage companies often prefer that tradeoff.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Real Architectural Tradeoff
&lt;/h2&gt;

&lt;p&gt;Junior developers often think:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Polling vs WebSockets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Senior engineers think:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Development Cost
vs
Infrastructure Cost
vs
User Experience
vs
Future Scale
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those are completely different conversations.&lt;/p&gt;

&lt;p&gt;Every architecture decision is a business decision wearing a technical disguise.&lt;/p&gt;




&lt;h2&gt;
  
  
  When Polling Becomes Expensive
&lt;/h2&gt;

&lt;p&gt;Imagine your SaaS platform grows to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;100,000 active users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Still polling every 5 seconds.&lt;/p&gt;

&lt;p&gt;Now the system receives:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;20,000 requests every second
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suddenly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;More application servers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Larger database clusters&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Higher cloud bills&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;More monitoring&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;More operational complexity&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The notification feature itself hasn't become more valuable.&lt;/p&gt;

&lt;p&gt;The architecture simply became more expensive.&lt;/p&gt;

&lt;p&gt;This is one of the easiest ways successful products accidentally create technical debt.&lt;/p&gt;

&lt;p&gt;Not through bad code.&lt;/p&gt;

&lt;p&gt;Through successful growth.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Most Important Lesson
&lt;/h2&gt;

&lt;p&gt;Polling is not a communication pattern.&lt;/p&gt;

&lt;p&gt;Polling is an optimization choice.&lt;/p&gt;

&lt;p&gt;You're optimizing for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Simplicity Today
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;while accepting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Higher Costs Tomorrow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sometimes that's exactly the right decision.&lt;/p&gt;

&lt;p&gt;Sometimes it's not.&lt;/p&gt;

&lt;p&gt;The best engineers aren't the ones who know the newest technologies.&lt;/p&gt;

&lt;p&gt;They're the ones who understand the tradeoffs.&lt;/p&gt;

&lt;p&gt;And Polling is one of the simplest examples of that principle.&lt;/p&gt;

</description>
      <category>backend</category>
      <category>systemdesign</category>
      <category>scalability</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Push vs Pull: A Decision About Where Complexity Lives</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Tue, 21 Jul 2026 10:52:04 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/push-vs-pull-a-decision-about-where-complexity-lives-4bhd</link>
      <guid>https://dev.to/anik_sikder_313/push-vs-pull-a-decision-about-where-complexity-lives-4bhd</guid>
      <description>&lt;p&gt;Most engineers think Push is more advanced than Pull.&lt;/p&gt;

&lt;p&gt;It's an easy conclusion to reach.&lt;/p&gt;

&lt;p&gt;After all:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Polling feels old.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebSockets feel modern.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Realtime feels better than waiting.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But some of the largest distributed systems in the world deliberately choose Pull.&lt;/p&gt;

&lt;p&gt;Not because Pull is better.&lt;/p&gt;

&lt;p&gt;Not because their engineers haven't heard of WebSockets.&lt;/p&gt;

&lt;p&gt;Because every distributed system eventually faces a more important question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Who is responsible for discovering change?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And the answer to that question determines where complexity lives.&lt;/p&gt;

&lt;p&gt;At scale, Pull wastes requests.&lt;/p&gt;

&lt;p&gt;Push wastes state.&lt;/p&gt;

&lt;p&gt;Most architectures are simply deciding which waste is cheaper.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Real Problem Isn't Communication
&lt;/h1&gt;

&lt;p&gt;Imagine an order is created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Created
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Several services care about it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Inventory Service&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Analytics Service&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Notification Service&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Billing Service&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The problem isn't generating information.&lt;/p&gt;

&lt;p&gt;The problem is delivering it.&lt;/p&gt;

&lt;p&gt;And there are only two fundamental ways to do that.&lt;/p&gt;




&lt;h2&gt;
  
  
  Pull
&lt;/h2&gt;

&lt;p&gt;Consumers discover changes themselves.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Analytics ----&amp;gt; Order Service
Inventory ----&amp;gt; Order Service
Notification -&amp;gt; Order Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each consumer periodically asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Anything new?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The responsibility belongs to the consumer.&lt;/p&gt;




&lt;h2&gt;
  
  
  Push
&lt;/h2&gt;

&lt;p&gt;The producer distributes changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Service
      |
      +----&amp;gt; Analytics
      |
      +----&amp;gt; Inventory
      |
      +----&amp;gt; Notification
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The responsibility belongs to the producer.&lt;/p&gt;

&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;That's the entire Push vs Pull debate.&lt;/p&gt;

&lt;p&gt;Polling, Long Polling, SSE, and WebSockets are merely different ways of implementing these two ideas.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Pull Refuses to Die
&lt;/h1&gt;

&lt;p&gt;A common misconception among younger engineers is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Push is the future.&lt;/p&gt;

&lt;p&gt;Pull is a legacy workaround.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Reality is less exciting.&lt;/p&gt;

&lt;p&gt;Many highly scalable systems intentionally choose Pull.&lt;/p&gt;




&lt;h2&gt;
  
  
  Kubernetes Is A Great Example
&lt;/h2&gt;

&lt;p&gt;Imagine a Kubernetes cluster containing 10,000 nodes.&lt;/p&gt;

&lt;p&gt;Many engineers expect the control plane to constantly push work to nodes.&lt;/p&gt;

&lt;p&gt;Instead, nodes continuously ask:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Any new Pods for me?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The nodes pull work.&lt;/p&gt;

&lt;p&gt;The control plane doesn't chase them.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because Push concentrates responsibility.&lt;/p&gt;

&lt;p&gt;Consider the alternative:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Control Plane
      |
      +--&amp;gt; Node 1
      +--&amp;gt; Node 2
      +--&amp;gt; Node 3
      ...
      +--&amp;gt; Node 10,000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the control plane must know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Which nodes are alive&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Which nodes are reachable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Which nodes need updates&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Which connections failed&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Complexity accumulates at the center.&lt;/p&gt;

&lt;p&gt;With Pull:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Node 1 ----&amp;gt;
Node 2 ----&amp;gt;
Node 3 ----&amp;gt;
Node N ----&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each node becomes responsible for its own synchronization.&lt;/p&gt;

&lt;p&gt;This is a pattern you'll see repeatedly in distributed systems:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When coordination becomes expensive, systems often shift responsibility to the edges.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Pull tends to distribute complexity.&lt;/p&gt;




&lt;h1&gt;
  
  
  Polling: The Simplest Pull Strategy
&lt;/h1&gt;

&lt;p&gt;Polling is often mocked because it seems inefficient.&lt;/p&gt;

&lt;p&gt;A client repeatedly asks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Anything new?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every few seconds.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /orders/123/status
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most responses look identical:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"COOKING"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"COOKING"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"COOKING"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Eventually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"DELIVERED"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates obvious waste.&lt;/p&gt;

&lt;p&gt;Consider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;100,000 clients
poll every 5 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;20,000 requests/sec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;even when nothing changes.&lt;/p&gt;

&lt;p&gt;Which leads many engineers to conclude:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Polling doesn't scale.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But that's not entirely true.&lt;/p&gt;

&lt;p&gt;Polling scales surprisingly well operationally.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because stateless systems are easier to operate.&lt;/p&gt;

&lt;p&gt;The server receives a request.&lt;/p&gt;

&lt;p&gt;Returns a response.&lt;/p&gt;

&lt;p&gt;Forgets everything.&lt;/p&gt;

&lt;p&gt;No connection state.&lt;/p&gt;

&lt;p&gt;No heartbeats.&lt;/p&gt;

&lt;p&gt;No reconnection logic.&lt;/p&gt;

&lt;p&gt;No presence tracking.&lt;/p&gt;

&lt;p&gt;Sometimes infrastructure simplicity is worth more than network efficiency.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Moment Systems Start Moving Toward Push
&lt;/h1&gt;

&lt;p&gt;The problem with polling isn't that it doesn't work.&lt;/p&gt;

&lt;p&gt;The problem is that most requests are useless.&lt;/p&gt;

&lt;p&gt;A system designer eventually notices:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request
No Change

Request
No Change

Request
No Change

Request
Actual Update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We're spending resources discovering nothing.&lt;/p&gt;

&lt;p&gt;This realization leads to Long Polling.&lt;/p&gt;




&lt;h1&gt;
  
  
  Long Polling: Let Me Know When Something Happens
&lt;/h1&gt;

&lt;p&gt;Instead of asking every few seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Anything new?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The client asks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Tell me when something changes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The request remains open.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client ---------------- Server
           waiting...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When an event appears:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;New Message
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server responds immediately.&lt;/p&gt;

&lt;p&gt;The client opens another request.&lt;/p&gt;

&lt;p&gt;This dramatically reduces wasted requests.&lt;/p&gt;

&lt;p&gt;The responsibility is still largely Pull-based.&lt;/p&gt;

&lt;p&gt;But the behavior begins to resemble Push.&lt;/p&gt;

&lt;p&gt;Long Polling became the bridge between traditional request-response systems and modern realtime systems.&lt;/p&gt;




&lt;h1&gt;
  
  
  SSE: Realtime Without Realtime Infrastructure
&lt;/h1&gt;

&lt;p&gt;Long Polling still has a cost.&lt;/p&gt;

&lt;p&gt;After every event:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection closes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A new connection must be established.&lt;/p&gt;

&lt;p&gt;SSE removes that overhead.&lt;/p&gt;

&lt;p&gt;One connection remains open.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client ------------------------ Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server continuously streams updates.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AAPL = 210
AAPL = 211
AAPL = 212
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No reconnects.&lt;/p&gt;

&lt;p&gt;No repeated requests.&lt;/p&gt;

&lt;p&gt;Just a stream.&lt;/p&gt;

&lt;p&gt;This is why SSE quietly powers dashboards, monitoring systems, reporting platforms, and internal tooling.&lt;/p&gt;

&lt;p&gt;Not because it's flashy.&lt;/p&gt;

&lt;p&gt;Because it's operationally boring.&lt;/p&gt;

&lt;p&gt;And boring systems are often excellent systems.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why WebSockets Change Everything
&lt;/h1&gt;

&lt;p&gt;WebSockets introduce a fundamentally different model.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request
Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client &amp;lt;-----------------&amp;gt; Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both sides can communicate whenever they want.&lt;/p&gt;

&lt;p&gt;This is essential for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Chat systems&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiplayer games&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Collaborative editing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Trading platforms&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The benefit is obvious:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Event Created
↓
Event Delivered
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;almost instantly.&lt;/p&gt;

&lt;p&gt;Latency becomes tiny.&lt;/p&gt;

&lt;p&gt;User experience improves dramatically.&lt;/p&gt;

&lt;p&gt;Which is why founders love realtime.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Cost Nobody Talks About
&lt;/h1&gt;

&lt;p&gt;Most discussions about WebSockets focus on latency.&lt;/p&gt;

&lt;p&gt;Experienced architects worry about something else:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;State.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Polling wastes requests.&lt;/p&gt;

&lt;p&gt;Push systems accumulate state.&lt;/p&gt;

&lt;p&gt;A polling server can forget a client immediately after responding.&lt;/p&gt;

&lt;p&gt;A WebSocket server cannot.&lt;/p&gt;

&lt;p&gt;The server must remember:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User ID
Connection ID
Subscriptions
Heartbeat Status
Presence Information
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And it must remember that information continuously.&lt;/p&gt;

&lt;p&gt;Now imagine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10 million connected users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suddenly you're not managing APIs anymore.&lt;/p&gt;

&lt;p&gt;You're managing connections.&lt;/p&gt;

&lt;p&gt;And connections become infrastructure.&lt;/p&gt;

&lt;p&gt;This is why large realtime companies eventually build:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Connection Gateways&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Presence Services&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fanout Systems&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Realtime Clusters&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Event Brokers&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The complexity didn't disappear.&lt;/p&gt;

&lt;p&gt;It moved.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Business Question Behind Push vs Pull
&lt;/h1&gt;

&lt;p&gt;Engineers often evaluate Push and Pull through a technical lens.&lt;/p&gt;

&lt;p&gt;Founders and CTOs usually care about a different question:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What will this cost us to operate?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Polling often creates more infrastructure waste.&lt;/p&gt;

&lt;p&gt;Push often creates more engineering complexity.&lt;/p&gt;

&lt;p&gt;Polling may consume more requests.&lt;/p&gt;

&lt;p&gt;Realtime systems may require entire teams dedicated to connection management.&lt;/p&gt;

&lt;p&gt;Founders often optimize for user experience.&lt;/p&gt;

&lt;p&gt;CTOs often optimize for operational complexity.&lt;/p&gt;

&lt;p&gt;Architects spend their careers balancing the two.&lt;/p&gt;




&lt;h1&gt;
  
  
  How Systems Usually Evolve
&lt;/h1&gt;

&lt;p&gt;Most systems don't start with WebSockets.&lt;/p&gt;

&lt;p&gt;They grow into them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stage 1
Polling

↓

Stage 2
Long Polling

↓

Stage 3
SSE

↓

Stage 4
WebSockets

↓

Stage 5
WebSockets + Pub/Sub + Fanout Services + Event Infrastructure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This evolution appears repeatedly across the industry.&lt;/p&gt;

&lt;p&gt;Not because engineers love complexity.&lt;/p&gt;

&lt;p&gt;Because scale eventually demands it.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Hidden Tradeoff
&lt;/h1&gt;

&lt;p&gt;Most engineers frame the decision like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Polling vs WebSockets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;System designers frame it differently:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Waste vs State
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Polling wastes requests.&lt;/p&gt;

&lt;p&gt;Push systems accumulate state.&lt;/p&gt;

&lt;p&gt;Pull systems tend to distribute responsibility.&lt;/p&gt;

&lt;p&gt;Push systems tend to concentrate responsibility around delivery and state management.&lt;/p&gt;

&lt;p&gt;Neither side wins.&lt;/p&gt;

&lt;p&gt;Both pay.&lt;/p&gt;

&lt;p&gt;The only question is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which cost is cheaper for your business?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  The Mental Model That Actually Matters
&lt;/h1&gt;

&lt;p&gt;Junior engineers often ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Should we use WebSockets?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Senior engineers ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Where should complexity live?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Should consumers be responsible for discovering change?&lt;/p&gt;

&lt;p&gt;Or should producers be responsible for distributing it?&lt;/p&gt;

&lt;p&gt;Because Push vs Pull is not really a networking discussion.&lt;/p&gt;

&lt;p&gt;It's a complexity allocation discussion.&lt;/p&gt;

&lt;p&gt;And every architecture eventually pays the bill.&lt;/p&gt;

&lt;p&gt;The only question is who pays it.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thought
&lt;/h1&gt;

&lt;p&gt;Every Pull system eventually asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why are we wasting so many requests?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Every Push system eventually asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why are we managing so much state?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The goal of architecture is not to eliminate complexity.&lt;/p&gt;

&lt;p&gt;The goal is to decide where it lives.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>distributedsystems</category>
      <category>backend</category>
      <category>performance</category>
    </item>
    <item>
      <title>Synchronous vs Asynchronous Workloads: Why Modern Systems Cannot Afford To Wait</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Sat, 18 Jul 2026 16:30:00 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/synchronous-vs-asynchronous-workloads-why-modern-systems-cannot-afford-to-wait-7fo</link>
      <guid>https://dev.to/anik_sikder_313/synchronous-vs-asynchronous-workloads-why-modern-systems-cannot-afford-to-wait-7fo</guid>
      <description>&lt;h2&gt;
  
  
  The Illusion of Simplicity
&lt;/h2&gt;

&lt;p&gt;Most software begins with a simple interaction.&lt;/p&gt;

&lt;p&gt;A user clicks a button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User
  ↓
Request
  ↓
Application
  ↓
Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user asks for something.&lt;/p&gt;

&lt;p&gt;The system performs the work.&lt;/p&gt;

&lt;p&gt;The system returns an answer.&lt;/p&gt;

&lt;p&gt;Simple.&lt;/p&gt;

&lt;p&gt;Predictable.&lt;/p&gt;

&lt;p&gt;Intuitive.&lt;/p&gt;

&lt;p&gt;This pattern powers nearly every API on the internet.&lt;/p&gt;

&lt;p&gt;When you log into your bank account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You expect an immediate response.&lt;/p&gt;

&lt;p&gt;When you add an item to your cart:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /cart/items
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You expect confirmation immediately.&lt;/p&gt;

&lt;p&gt;In these situations, waiting makes sense because the user cannot proceed without the answer.&lt;/p&gt;

&lt;p&gt;The interaction itself requires synchronization.&lt;/p&gt;

&lt;p&gt;This is the essence of synchronous communication.&lt;/p&gt;

&lt;p&gt;The client and server move forward together.&lt;/p&gt;

&lt;p&gt;One waits for the other.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Synchronous Really Means
&lt;/h2&gt;

&lt;p&gt;Many developers define synchronous communication as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Request → Wait → Response&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Technically correct.&lt;/p&gt;

&lt;p&gt;But incomplete.&lt;/p&gt;

&lt;p&gt;From a systems perspective, synchronous communication means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The lifetime of the work is coupled to the lifetime of the request.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This distinction is important.&lt;/p&gt;

&lt;p&gt;Consider a checkout request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer
    ↓
Checkout API
    ↓
Payment Service
    ↓
Database
    ↓
Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The work begins when the request arrives.&lt;/p&gt;

&lt;p&gt;The work ends before the response leaves.&lt;/p&gt;

&lt;p&gt;Everything happens inside a single transaction boundary.&lt;/p&gt;

&lt;p&gt;The request owns the work.&lt;/p&gt;

&lt;p&gt;The work owns the response.&lt;/p&gt;

&lt;p&gt;The three are tightly connected.&lt;/p&gt;




&lt;h2&gt;
  
  
  Waiting Is Not Free
&lt;/h2&gt;

&lt;p&gt;One of the most important lessons in distributed systems is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Waiting consumes resources.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While a request is waiting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Memory remains allocated&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Network connections remain open&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Worker processes remain occupied&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Thread pools remain partially blocked&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Load balancers maintain state&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Databases hold locks longer&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At small scale this cost is invisible.&lt;/p&gt;

&lt;p&gt;At large scale it becomes existential.&lt;/p&gt;

&lt;p&gt;Imagine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;100 requests
×
100 milliseconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No problem.&lt;/p&gt;

&lt;p&gt;Now imagine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;100,000 requests
×
30 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suddenly the architecture itself becomes the bottleneck.&lt;/p&gt;

&lt;p&gt;The system is no longer spending resources doing work.&lt;/p&gt;

&lt;p&gt;It is spending resources waiting.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Video Processing Thought Experiment
&lt;/h2&gt;

&lt;p&gt;Imagine you're building YouTube.&lt;/p&gt;

&lt;p&gt;A creator uploads a 4K video.&lt;/p&gt;

&lt;p&gt;The upload completes.&lt;/p&gt;

&lt;p&gt;Now the platform must:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Generate thumbnails

Transcode into multiple resolutions

Run copyright detection

Run moderation checks

Extract metadata

Replicate to storage regions

Update search indexes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The total processing time might be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2 minutes

5 minutes

10 minutes

20 minutes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now ask yourself:&lt;/p&gt;

&lt;p&gt;Should the user wait?&lt;/p&gt;

&lt;p&gt;A synchronous implementation would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User
   ↓
POST /upload
   ↓
20 Minutes Processing
   ↓
200 OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This design immediately creates multiple problems.&lt;/p&gt;




&lt;h2&gt;
  
  
  Problem 1: Humans Hate Waiting
&lt;/h2&gt;

&lt;p&gt;Most users start becoming uncomfortable after a few seconds.&lt;/p&gt;

&lt;p&gt;After several minutes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Loading...
Loading...
Loading...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Many assume the application is broken.&lt;/p&gt;

&lt;p&gt;Even if the system is functioning perfectly.&lt;/p&gt;

&lt;p&gt;Perception becomes reality.&lt;/p&gt;




&lt;h2&gt;
  
  
  Problem 2: Infrastructure Begins To Suffer
&lt;/h2&gt;

&lt;p&gt;Imagine 50,000 creators uploading videos simultaneously.&lt;/p&gt;

&lt;p&gt;If every request remains open for 20 minutes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;50,000 Open Connections

50,000 Active Request Contexts

50,000 Resource Reservations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The infrastructure collapses long before CPU becomes the bottleneck.&lt;/p&gt;

&lt;p&gt;The system spends most of its capacity maintaining waiting clients.&lt;/p&gt;




&lt;h2&gt;
  
  
  Problem 3: Timeouts Become Inevitable
&lt;/h2&gt;

&lt;p&gt;Every layer imposes limits.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser Timeout

Load Balancer Timeout

API Gateway Timeout

Reverse Proxy Timeout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some component eventually gives up.&lt;/p&gt;

&lt;p&gt;The work may still be running.&lt;/p&gt;

&lt;p&gt;The client assumes it failed.&lt;/p&gt;

&lt;p&gt;Now users retry.&lt;/p&gt;

&lt;p&gt;Duplicate work appears.&lt;/p&gt;

&lt;p&gt;System load increases further.&lt;/p&gt;

&lt;p&gt;A reliability problem emerges from what initially looked like a latency problem.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Fundamental Insight
&lt;/h2&gt;

&lt;p&gt;The breakthrough realization was not technological.&lt;/p&gt;

&lt;p&gt;It was conceptual.&lt;/p&gt;

&lt;p&gt;Engineers eventually asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Does the user actually need the work completed?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Or&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Does the user simply need confirmation that the work has started?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These are completely different requirements.&lt;/p&gt;

&lt;p&gt;For video uploads, the user doesn't need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Video fully processed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user needs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;We received your video.
Processing has started.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That insight changed the architecture of modern systems.&lt;/p&gt;




&lt;h2&gt;
  
  
  Decoupling Acceptance From Completion
&lt;/h2&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Accept Request
      ↓
Perform Work
      ↓
Return Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Accept Request
      ↓
Acknowledge Immediately
      ↓
Perform Work Later
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;202 Accepted
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The request ends.&lt;/p&gt;

&lt;p&gt;The work continues.&lt;/p&gt;

&lt;p&gt;The user moves on.&lt;/p&gt;

&lt;p&gt;The system moves on.&lt;/p&gt;

&lt;p&gt;Everyone wins.&lt;/p&gt;




&lt;h2&gt;
  
  
  Enter Queues
&lt;/h2&gt;

&lt;p&gt;The moment work stops happening immediately, a new question appears:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Where does the work wait?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The answer is usually a queue.&lt;/p&gt;

&lt;p&gt;Think of a restaurant.&lt;/p&gt;

&lt;p&gt;Customers place orders faster than chefs can cook.&lt;/p&gt;

&lt;p&gt;The kitchen doesn't fail.&lt;/p&gt;

&lt;p&gt;Orders simply wait.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer
     ↓
Order Queue
     ↓
Kitchen
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Software systems work similarly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;API
   ↓
Queue
   ↓
Workers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The API accepts work.&lt;/p&gt;

&lt;p&gt;Workers perform work.&lt;/p&gt;

&lt;p&gt;The two sides become independent.&lt;/p&gt;

&lt;p&gt;This decoupling is one of the most important scalability techniques ever invented.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Queues Are So Powerful
&lt;/h2&gt;

&lt;p&gt;Queues solve several problems simultaneously.&lt;/p&gt;

&lt;h3&gt;
  
  
  Traffic Spikes
&lt;/h3&gt;

&lt;p&gt;Without a queue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10,000 uploads
        ↓
10,000 immediate processing jobs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Infrastructure explodes.&lt;/p&gt;

&lt;p&gt;With a queue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10,000 uploads
        ↓
Queue
        ↓
500 workers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The workload becomes manageable.&lt;/p&gt;




&lt;h3&gt;
  
  
  Failure Isolation
&lt;/h3&gt;

&lt;p&gt;Suppose a video processor crashes.&lt;/p&gt;

&lt;p&gt;Without a queue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request fails
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a queue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Message remains
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The work can be retried later.&lt;/p&gt;

&lt;p&gt;Durability improves dramatically.&lt;/p&gt;




&lt;h3&gt;
  
  
  Elastic Scaling
&lt;/h3&gt;

&lt;p&gt;When demand increases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Queue Depth Increases
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add more workers.&lt;/p&gt;

&lt;p&gt;When demand decreases:&lt;/p&gt;

&lt;p&gt;Remove workers.&lt;/p&gt;

&lt;p&gt;This elasticity is fundamental to cloud-native systems.&lt;/p&gt;




&lt;h2&gt;
  
  
  Background Jobs: Moving Work Off The Critical Path
&lt;/h2&gt;

&lt;p&gt;A useful systems principle is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Keep the request path as small as possible.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The critical path is everything that must happen before a response is returned.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Bad design:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Registration
       ↓
Create User
Send Email
Generate Avatar
Sync CRM
Update Analytics
Create Recommendations
       ↓
Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Good design:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Registration
       ↓
Create User
       ↓
Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything else becomes background work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Send Email

Update Analytics

Generate Avatar

Create Recommendations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response becomes dramatically faster.&lt;/p&gt;

&lt;p&gt;Reliability improves.&lt;/p&gt;

&lt;p&gt;User experience improves.&lt;/p&gt;

&lt;p&gt;System throughput improves.&lt;/p&gt;




&lt;h2&gt;
  
  
  Event-Driven Systems: The Next Evolution
&lt;/h2&gt;

&lt;p&gt;As organizations grow, multiple services become interested in the same event.&lt;/p&gt;

&lt;p&gt;Consider an e-commerce platform.&lt;/p&gt;

&lt;p&gt;An order is placed.&lt;/p&gt;

&lt;p&gt;Who cares?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Inventory Service

Payment Service

Shipping Service

Analytics Service

Email Service

Fraud Detection Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Potentially dozens of consumers.&lt;/p&gt;

&lt;p&gt;A synchronous design might create this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Service
      ↓
Inventory
      ↓
Email
      ↓
Analytics
      ↓
Shipping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every dependency increases latency.&lt;/p&gt;

&lt;p&gt;Every dependency increases failure risk.&lt;/p&gt;

&lt;p&gt;Every dependency increases coupling.&lt;/p&gt;

&lt;p&gt;Instead, modern systems often publish an event.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Created
       ↓
Event Broker
       ↓
Many Consumers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The producer no longer needs to know who is listening.&lt;/p&gt;

&lt;p&gt;This is the foundation of event-driven architecture.&lt;/p&gt;




&lt;h2&gt;
  
  
  Does Asynchronous Mean Better?
&lt;/h2&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;This is where many engineers make a mistake.&lt;/p&gt;

&lt;p&gt;Asynchronous systems introduce new challenges:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Eventual Consistency

Duplicate Messages

Out-of-Order Events

Retry Logic

Observability Complexity

Distributed Debugging
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You exchange waiting problems for coordination problems.&lt;/p&gt;

&lt;p&gt;The trade-off is often worthwhile.&lt;/p&gt;

&lt;p&gt;But it is never free.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Real Lesson
&lt;/h2&gt;

&lt;p&gt;The distinction between synchronous and asynchronous workloads is not about APIs, queues, or message brokers.&lt;/p&gt;

&lt;p&gt;It is about understanding the cost of waiting.&lt;/p&gt;

&lt;p&gt;System design becomes much clearer when you start asking a different question.&lt;/p&gt;

&lt;p&gt;Not:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Can this work be asynchronous?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Does anyone truly need to wait for this work to finish?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The most scalable systems in the world are often built around a simple idea:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Acknowledge immediately.&lt;/p&gt;

&lt;p&gt;Process independently.&lt;/p&gt;

&lt;p&gt;Coordinate eventually.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That single shift in thinking is responsible for much of modern distributed architecture, from YouTube's video pipeline, to Stripe's payment processing, to Amazon's order fulfillment systems.&lt;/p&gt;

&lt;p&gt;And once you begin seeing systems through that lens, you'll notice that many of the world's largest platforms are really just sophisticated mechanisms for avoiding unnecessary waiting.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>api</category>
      <category>backend</category>
      <category>distributedsystems</category>
    </item>
    <item>
      <title>Request-Response: The Foundation of Modern APIs</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Mon, 13 Jul 2026 18:05:49 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/request-response-the-foundation-of-modern-apis-4bci</link>
      <guid>https://dev.to/anik_sikder_313/request-response-the-foundation-of-modern-apis-4bci</guid>
      <description>&lt;p&gt;Most developers use Request-Response every day.&lt;/p&gt;

&lt;p&gt;Few stop to think about what actually happens after clicking a button.&lt;/p&gt;

&lt;p&gt;You open an app.&lt;/p&gt;

&lt;p&gt;You tap &lt;strong&gt;"Login"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A response appears almost instantly.&lt;/p&gt;

&lt;p&gt;Simple, right?&lt;/p&gt;

&lt;p&gt;Not exactly.&lt;/p&gt;

&lt;p&gt;Behind that seemingly simple interaction lies one of the most important communication patterns in software engineering:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Request-Response.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whether you're using ChatGPT, ordering food through Uber Eats, checking your bank balance, or watching Netflix, countless Request-Response interactions occur every second.&lt;/p&gt;

&lt;p&gt;Understanding this pattern is one of the first steps toward understanding modern backend engineering.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Request-Response?
&lt;/h2&gt;

&lt;p&gt;At its core, Request-Response is a conversation between two systems.&lt;/p&gt;

&lt;p&gt;One system asks for something.&lt;/p&gt;

&lt;p&gt;Another system answers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client                    Server
   |                         |
   |------ Request ---------&amp;gt;|
   |                         |
   |&amp;lt;----- Response ---------|
   |                         |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The client initiates communication.&lt;/p&gt;

&lt;p&gt;The server processes the request and returns a response.&lt;/p&gt;

&lt;p&gt;This interaction is typically short-lived and synchronous.&lt;/p&gt;

&lt;p&gt;The client sends a request and waits for an answer.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Real-World Analogy
&lt;/h2&gt;

&lt;p&gt;Imagine you're sitting in a restaurant.&lt;/p&gt;

&lt;p&gt;You call the waiter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer -&amp;gt; "I'd like a burger."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The waiter takes your order to the kitchen.&lt;/p&gt;

&lt;p&gt;The kitchen prepares the meal.&lt;/p&gt;

&lt;p&gt;The waiter returns with your food.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Kitchen -&amp;gt; "Here's your burger."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's Request-Response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer = Client
Waiter = Network
Kitchen = Server
Burger = Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most web applications operate using exactly this pattern.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Journey of a Request
&lt;/h2&gt;

&lt;p&gt;Consider a simple login request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It may look simple from the browser's perspective.&lt;/p&gt;

&lt;p&gt;But internally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser
   |
Load Balancer
   |
API Gateway
   |
Authentication Service
   |
Database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response must travel back through the same chain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Database
   |
Authentication Service
   |
API Gateway
   |
Load Balancer
   |
Browser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every step introduces latency, failure possibilities, and complexity.&lt;/p&gt;




&lt;h1&gt;
  
  
  Latency: The Hidden Cost of Distance
&lt;/h1&gt;

&lt;p&gt;Latency is the time required for a request to travel through the system and return a response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request Sent ---------------------&amp;gt;

&amp;lt;-------------------- Response Received
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Users don't care about architecture diagrams.&lt;/p&gt;

&lt;p&gt;They care about speed.&lt;/p&gt;

&lt;p&gt;When someone clicks a button, they expect a response immediately.&lt;/p&gt;

&lt;p&gt;Even small delays are noticeable.&lt;/p&gt;

&lt;p&gt;Typical user perception:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Response Time&lt;/th&gt;
&lt;th&gt;User Experience&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0–100 ms&lt;/td&gt;
&lt;td&gt;Instant&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;100–300 ms&lt;/td&gt;
&lt;td&gt;Fast&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;300–1000 ms&lt;/td&gt;
&lt;td&gt;Noticeable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1–3 sec&lt;/td&gt;
&lt;td&gt;Slow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3+ sec&lt;/td&gt;
&lt;td&gt;Frustrating&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;At scale, reducing latency becomes a competitive advantage.&lt;/p&gt;

&lt;p&gt;This is one reason companies invest heavily in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;CDNs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Caching&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Edge Computing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Database Optimization&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Load Balancing&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Timeouts: Waiting Forever Is Not an Option
&lt;/h1&gt;

&lt;p&gt;Imagine calling a restaurant and nobody answers.&lt;/p&gt;

&lt;p&gt;How long should you wait?&lt;/p&gt;

&lt;p&gt;Five seconds?&lt;/p&gt;

&lt;p&gt;Five minutes?&lt;/p&gt;

&lt;p&gt;An hour?&lt;/p&gt;

&lt;p&gt;Software faces the same problem.&lt;/p&gt;

&lt;p&gt;A timeout defines the maximum amount of time a system is willing to wait for a response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client ---- Request ----&amp;gt;
                ...
                ...
                ...
Timeout Reached
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without timeouts, systems can become stuck waiting forever.&lt;/p&gt;

&lt;p&gt;This leads to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Hanging requests&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Resource exhaustion&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Poor user experience&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every production-grade system uses timeouts.&lt;/p&gt;




&lt;h1&gt;
  
  
  Retries: What If the Request Fails?
&lt;/h1&gt;

&lt;p&gt;Networks are imperfect.&lt;/p&gt;

&lt;p&gt;Packets get lost.&lt;/p&gt;

&lt;p&gt;Servers restart.&lt;/p&gt;

&lt;p&gt;Databases become temporarily unavailable.&lt;/p&gt;

&lt;p&gt;A single failure doesn't necessarily mean the operation should fail.&lt;/p&gt;

&lt;p&gt;Instead, many systems retry.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attempt #1 -&amp;gt; Failed

Attempt #2 -&amp;gt; Failed

Attempt #3 -&amp;gt; Success
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Retries improve reliability.&lt;/p&gt;

&lt;p&gt;But they also introduce a dangerous problem.&lt;/p&gt;

&lt;p&gt;What if the original request actually succeeded?&lt;/p&gt;




&lt;h1&gt;
  
  
  Idempotency: Preventing Duplicate Operations
&lt;/h1&gt;

&lt;p&gt;Imagine clicking:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Pay Now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The payment succeeds.&lt;/p&gt;

&lt;p&gt;But the response never reaches your browser.&lt;/p&gt;

&lt;p&gt;Your application thinks the request failed.&lt;/p&gt;

&lt;p&gt;It retries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Charge Card
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again.&lt;/p&gt;

&lt;p&gt;Without protection, the customer could be charged twice.&lt;/p&gt;

&lt;p&gt;This is why payment systems use idempotency.&lt;/p&gt;

&lt;p&gt;An idempotent operation produces the same result even if executed multiple times.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request ID: abc123
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the same request arrives again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request ID: abc123
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server recognizes it and returns the previous result instead of processing the payment again.&lt;/p&gt;

&lt;p&gt;This concept is critical in systems like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stripe&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PayPal&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Banking Platforms&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Order Processing Systems&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Fan-Out: One Request Can Become Many
&lt;/h1&gt;

&lt;p&gt;A request rarely stays simple for long.&lt;/p&gt;

&lt;p&gt;Imagine opening a product page.&lt;/p&gt;

&lt;p&gt;The backend may need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Product Service
Review Service
Inventory Service
Pricing Service
Recommendation Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One incoming request becomes many downstream requests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 Product
                /
Client ---- API Gateway
                \
                 Reviews

                 Inventory

                 Pricing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This pattern is called Fan-Out.&lt;/p&gt;

&lt;p&gt;Fan-Out increases functionality.&lt;/p&gt;

&lt;p&gt;But it also increases risk.&lt;/p&gt;

&lt;p&gt;If one dependency becomes slow, the entire response can become slow.&lt;/p&gt;




&lt;h1&gt;
  
  
  Cascading Failures
&lt;/h1&gt;

&lt;p&gt;Now imagine the Review Service becomes overloaded.&lt;/p&gt;

&lt;p&gt;Requests begin timing out.&lt;/p&gt;

&lt;p&gt;The Product Service waits.&lt;/p&gt;

&lt;p&gt;Threads become blocked.&lt;/p&gt;

&lt;p&gt;Connection pools fill up.&lt;/p&gt;

&lt;p&gt;More requests pile up.&lt;/p&gt;

&lt;p&gt;Soon:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Review Service Failure
        |
        v
Product Service Slow
        |
        v
API Gateway Slow
        |
        v
Entire Application Slow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A small issue spreads throughout the system.&lt;/p&gt;

&lt;p&gt;This is called a Cascading Failure.&lt;/p&gt;

&lt;p&gt;Many major outages start exactly this way.&lt;/p&gt;

&lt;p&gt;A single dependency struggles.&lt;/p&gt;

&lt;p&gt;Everything connected to it suffers.&lt;/p&gt;




&lt;h1&gt;
  
  
  Observability: Seeing What the System Sees
&lt;/h1&gt;

&lt;p&gt;When users complain:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The app feels slow."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Where exactly is the problem?&lt;/p&gt;

&lt;p&gt;The database?&lt;/p&gt;

&lt;p&gt;The cache?&lt;/p&gt;

&lt;p&gt;The network?&lt;/p&gt;

&lt;p&gt;The payment service?&lt;/p&gt;

&lt;p&gt;Without visibility, debugging becomes guesswork.&lt;/p&gt;

&lt;p&gt;Modern systems rely on observability.&lt;/p&gt;

&lt;p&gt;Three pillars are commonly used:&lt;/p&gt;

&lt;h3&gt;
  
  
  Logs
&lt;/h3&gt;

&lt;p&gt;Individual events.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User logged in
Payment created
Order shipped
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Metrics
&lt;/h3&gt;

&lt;p&gt;System health measurements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CPU Usage
Memory Usage
Request Rate
Error Rate
Latency
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Traces
&lt;/h3&gt;

&lt;p&gt;The complete journey of a request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client
  -&amp;gt; Gateway
     -&amp;gt; Auth Service
        -&amp;gt; Database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tracing reveals where time is spent.&lt;/p&gt;

&lt;p&gt;At scale, observability becomes essential.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Request-Response Eventually Becomes a Bottleneck
&lt;/h1&gt;

&lt;p&gt;Request-Response is simple.&lt;/p&gt;

&lt;p&gt;That's its greatest strength.&lt;/p&gt;

&lt;p&gt;But it's also its limitation.&lt;/p&gt;

&lt;p&gt;The client must wait.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request ---&amp;gt;

&amp;lt;--- Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No response means no progress.&lt;/p&gt;

&lt;p&gt;As systems grow, engineers begin exploring alternatives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Polling&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Long Polling&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Server-Sent Events (SSE)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebSockets&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pub/Sub&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Event-Driven Architectures&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These patterns exist because traditional Request-Response is not always enough.&lt;/p&gt;

&lt;p&gt;But every one of them builds upon the foundation established by Request-Response.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Request-Response appears deceptively simple.&lt;/p&gt;

&lt;p&gt;A client asks.&lt;/p&gt;

&lt;p&gt;A server answers.&lt;/p&gt;

&lt;p&gt;Yet hidden beneath that simplicity are some of the most important challenges in software engineering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Latency&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Timeouts&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Retries&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Idempotency&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fan-Out&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cascading Failures&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Observability&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding these concepts is what separates someone who can build APIs from someone who can design reliable systems.&lt;/p&gt;

&lt;p&gt;Before learning WebSockets, Event Streaming, or Distributed Systems, it's worth mastering the communication pattern that powers nearly every application on the internet:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Request-Response.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>backend</category>
      <category>systemdesign</category>
      <category>distributedsystems</category>
    </item>
    <item>
      <title>HTTP/3: Why the Web Finally Moved Beyond TCP</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Fri, 10 Jul 2026 17:29:42 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/http3-why-the-web-finally-moved-beyond-tcp-3hee</link>
      <guid>https://dev.to/anik_sikder_313/http3-why-the-web-finally-moved-beyond-tcp-3hee</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/anik_sikder_313/http2-the-protocol-that-stopped-the-connection-explosion-4123"&gt;previous article&lt;/a&gt;, we explored how HTTP/2 transformed web communication.&lt;/p&gt;

&lt;p&gt;Instead of opening multiple TCP connections, HTTP/2 introduced multiplexing, allowing many streams to share a single connection.&lt;/p&gt;

&lt;p&gt;This was a major breakthrough.&lt;/p&gt;

&lt;p&gt;Websites loaded faster.&lt;/p&gt;

&lt;p&gt;Connections became more efficient.&lt;/p&gt;

&lt;p&gt;Servers handled resources more intelligently.&lt;/p&gt;

&lt;p&gt;For a while, it seemed like the web's communication problems had finally been solved.&lt;/p&gt;

&lt;p&gt;But engineers soon discovered an uncomfortable truth:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;HTTP/2 solved many of HTTP's problems.&lt;/p&gt;

&lt;p&gt;It did not solve all of TCP's problems.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And because HTTP/2 still relied on TCP, some bottlenecks remained.&lt;/p&gt;

&lt;p&gt;To understand those bottlenecks, imagine you're watching a Netflix movie on your phone.&lt;/p&gt;

&lt;p&gt;You're connected to your home Wi-Fi.&lt;/p&gt;

&lt;p&gt;Everything is smooth.&lt;/p&gt;

&lt;p&gt;Then you leave your house.&lt;/p&gt;

&lt;p&gt;Your phone switches from:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Wi-Fi
↓
5G
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a brief moment, the video freezes.&lt;/p&gt;

&lt;p&gt;A loading spinner appears.&lt;/p&gt;

&lt;p&gt;A few seconds later, playback continues.&lt;/p&gt;

&lt;p&gt;Most users blame the network.&lt;/p&gt;

&lt;p&gt;But engineers ask a different question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why did the connection have to struggle in the first place?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Questions like this eventually led to one of the biggest protocol changes in the history of the web:&lt;/p&gt;

&lt;p&gt;HTTP/3.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hidden Success of HTTP/2
&lt;/h2&gt;

&lt;p&gt;When HTTP/2 arrived, it solved a huge problem.&lt;/p&gt;

&lt;p&gt;Instead of opening many TCP connections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser
 ├── TCP 1
 ├── TCP 2
 ├── TCP 3
 ├── TCP 4
 ├── TCP 5
 └── TCP 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;HTTP/2 introduced multiplexing.&lt;/p&gt;

&lt;p&gt;Now everything could travel through one connection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;One TCP Connection
│
├── HTML
├── CSS
├── JavaScript
├── Images
└── Fonts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Less overhead.&lt;/p&gt;

&lt;p&gt;Better efficiency.&lt;/p&gt;

&lt;p&gt;Faster websites.&lt;/p&gt;

&lt;p&gt;For a while, it looked like the problem was solved.&lt;/p&gt;

&lt;p&gt;Then reality struck.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem Nobody Could See
&lt;/h2&gt;

&lt;p&gt;Imagine a highway with five lanes.&lt;/p&gt;

&lt;p&gt;Cars are moving perfectly.&lt;/p&gt;

&lt;p&gt;Suddenly a truck crashes in Lane 2.&lt;/p&gt;

&lt;p&gt;What should happen?&lt;/p&gt;

&lt;p&gt;Common sense says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Lane 2 slows down.&lt;/p&gt;

&lt;p&gt;Lanes 1, 3, 4, and 5 continue moving.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But TCP behaves differently.&lt;/p&gt;

&lt;p&gt;TCP says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Nobody moves until the missing vehicle is accounted for.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Everything waits.&lt;/p&gt;

&lt;p&gt;Even traffic that wasn't affected.&lt;/p&gt;

&lt;p&gt;This is essentially what happens when packet loss occurs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding Packet Loss
&lt;/h2&gt;

&lt;p&gt;Data sent across the internet is divided into packets.&lt;/p&gt;

&lt;p&gt;Imagine sending:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Packet 1
Packet 2
Packet 3
Packet 4
Packet 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now suppose Packet 3 disappears.&lt;/p&gt;

&lt;p&gt;Maybe a router drops it.&lt;/p&gt;

&lt;p&gt;Maybe Wi-Fi interference occurs.&lt;/p&gt;

&lt;p&gt;Maybe a mobile network briefly weakens.&lt;/p&gt;

&lt;p&gt;The receiver gets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Packet 1 ✅
Packet 2 ✅
Packet 3 ❌
Packet 4 ✅
Packet 5 ✅
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Humans would probably say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Great.&lt;/p&gt;

&lt;p&gt;We already have 1, 2, 4, and 5.&lt;/p&gt;

&lt;p&gt;Let's continue.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;TCP disagrees.&lt;/p&gt;




&lt;h2&gt;
  
  
  TCP's Obsession With Order
&lt;/h2&gt;

&lt;p&gt;TCP was designed decades ago.&lt;/p&gt;

&lt;p&gt;Its primary mission was reliability.&lt;/p&gt;

&lt;p&gt;If data is sent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1
2
3
4
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TCP guarantees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1
2
3
4
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No missing pieces.&lt;/p&gt;

&lt;p&gt;No reordering.&lt;/p&gt;

&lt;p&gt;No shortcuts.&lt;/p&gt;

&lt;p&gt;This reliability is amazing for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Banking&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Email&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;File Downloads&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Database Replication&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But for modern web applications, it creates a hidden cost.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Waiting Game
&lt;/h2&gt;

&lt;p&gt;Imagine five HTTP/2 streams:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connection
│
├── Stream A → HTML
├── Stream B → CSS
├── Stream C → JavaScript
├── Stream D → Images
└── Stream E → Fonts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now one packet carrying image data gets lost.&lt;/p&gt;

&lt;p&gt;Logically, only the image should be affected.&lt;/p&gt;

&lt;p&gt;But because all streams share one TCP connection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML        ⏳ Waiting
CSS         ⏳ Waiting
JavaScript  ⏳ Waiting
Images      ⏳ Waiting
Fonts       ⏳ Waiting
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything slows down.&lt;/p&gt;

&lt;p&gt;Even resources that arrived successfully.&lt;/p&gt;

&lt;p&gt;This is called:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TCP Head-of-Line Blocking.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And it became one of the biggest remaining performance problems on the modern web.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Mobile Networks Made Things Worse
&lt;/h2&gt;

&lt;p&gt;Back in the early 2000s:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Desktop computers dominated&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wired connections were common&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Today:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Smartphones dominate traffic&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Users move constantly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Networks change frequently&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A user may switch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Home Wi-Fi
      ↓
Coffee Shop Wi-Fi
      ↓
4G
      ↓
5G
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Packet loss is normal.&lt;/p&gt;

&lt;p&gt;Temporary interruptions are normal.&lt;/p&gt;

&lt;p&gt;Modern protocols must assume imperfect networks.&lt;/p&gt;

&lt;p&gt;TCP was designed for a different era.&lt;/p&gt;




&lt;h2&gt;
  
  
  Engineers Asked a Radical Question
&lt;/h2&gt;

&lt;p&gt;For decades the stack looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP
 ↓
TCP
 ↓
IP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nobody questioned it.&lt;/p&gt;

&lt;p&gt;Using TCP felt as natural as using electricity.&lt;/p&gt;

&lt;p&gt;Then engineers asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What if HTTP doesn't need TCP?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That question changed everything.&lt;/p&gt;




&lt;h2&gt;
  
  
  Meet QUIC
&lt;/h2&gt;

&lt;p&gt;Google engineers began experimenting with a new transport protocol called QUIC.&lt;/p&gt;

&lt;p&gt;Instead of building on TCP:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/2
   ↓
 TCP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They built on UDP:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/3
   ↓
 QUIC
   ↓
 UDP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first, this sounds crazy.&lt;/p&gt;

&lt;p&gt;UDP is famous for being unreliable.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Pizza Delivery Analogy
&lt;/h2&gt;

&lt;p&gt;Think of TCP as a delivery company.&lt;/p&gt;

&lt;p&gt;Every pizza must arrive.&lt;/p&gt;

&lt;p&gt;Every pizza must arrive in order.&lt;/p&gt;

&lt;p&gt;If Pizza #3 is delayed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Pizza 4 waits
Pizza 5 waits
Pizza 6 waits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Maximum reliability.&lt;/p&gt;

&lt;p&gt;But sometimes unnecessary waiting.&lt;/p&gt;

&lt;p&gt;UDP works differently.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Send Pizza
     ↓
Hope It Arrives
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Much faster.&lt;/p&gt;

&lt;p&gt;Much simpler.&lt;/p&gt;

&lt;p&gt;But not reliable enough for the web.&lt;/p&gt;

&lt;p&gt;QUIC combines the best of both worlds.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Genius of QUIC
&lt;/h2&gt;

&lt;p&gt;QUIC provides:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UDP Speed
      +
TCP Reliability
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But it adds one critical improvement.&lt;/p&gt;

&lt;p&gt;Streams become independent.&lt;/p&gt;

&lt;p&gt;Imagine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stream A
Stream B
Stream C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If Stream A loses a packet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stream A waits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stream B continues
Stream C continues
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the breakthrough.&lt;/p&gt;

&lt;p&gt;One problem no longer freezes everything.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Matters
&lt;/h2&gt;

&lt;p&gt;Think about modern applications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;YouTube&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Netflix&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ChatGPT&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Discord&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Google Docs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Figma&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These applications constantly exchange data.&lt;/p&gt;

&lt;p&gt;Small delays affect user experience.&lt;/p&gt;

&lt;p&gt;Reducing unnecessary waiting directly improves responsiveness.&lt;/p&gt;

&lt;p&gt;HTTP/3 was designed for exactly this world.&lt;/p&gt;




&lt;h2&gt;
  
  
  Another Hidden Superpower: Faster Connections
&lt;/h2&gt;

&lt;p&gt;Traditional HTTPS connections require several steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TCP Handshake
      ↓
TLS Handshake
      ↓
Data Transfer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every step adds latency.&lt;/p&gt;

&lt;p&gt;QUIC combines and optimizes much of this process.&lt;/p&gt;

&lt;p&gt;In some situations, returning users can send data immediately.&lt;/p&gt;

&lt;p&gt;This is called:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;0-RTT (Zero Round Trip Time)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Less waiting.&lt;/p&gt;

&lt;p&gt;Faster interactions.&lt;/p&gt;

&lt;p&gt;Happier users.&lt;/p&gt;




&lt;h2&gt;
  
  
  Connection Migration: The Mobile Superpower
&lt;/h2&gt;

&lt;p&gt;Remember the Netflix example?&lt;/p&gt;

&lt;p&gt;With TCP, changing networks often means starting over.&lt;/p&gt;

&lt;p&gt;With QUIC:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Wi-Fi
   ↓
5G
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The connection can survive.&lt;/p&gt;

&lt;p&gt;The session continues.&lt;/p&gt;

&lt;p&gt;The user experiences fewer interruptions.&lt;/p&gt;

&lt;p&gt;This is one reason HTTP/3 performs so well on mobile devices.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Big Picture
&lt;/h2&gt;

&lt;p&gt;Every major HTTP version solved the biggest bottleneck of its era.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1
↓
Too Many Requests

HTTP/2
↓
Connection Inefficiency

HTTP/3
↓
Transport-Level Blocking
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The story of HTTP is really the story of engineers continuously removing obstacles between users and information.&lt;/p&gt;




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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;HTTP/2 solved many HTTP/1.1 inefficiencies through multiplexing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TCP-level Head-of-Line Blocking still remained.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Packet loss on one stream could affect unrelated streams.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modern mobile networks made this limitation more noticeable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;QUIC was built on UDP to provide a more flexible transport layer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTTP/3 uses QUIC instead of TCP.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Independent streams reduce unnecessary waiting.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Features like 0-RTT and Connection Migration improve real-world performance.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  One-Sentence Summary
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;HTTP/2 made one connection smarter; HTTP/3 made sure one lost packet could no longer slow down the entire conversation.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>http</category>
      <category>web</category>
      <category>performance</category>
      <category>backend</category>
    </item>
    <item>
      <title>HTTP/2: The Protocol That Stopped the Connection Explosion</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Sun, 05 Jul 2026 16:30:00 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/http2-the-protocol-that-stopped-the-connection-explosion-4123</link>
      <guid>https://dev.to/anik_sikder_313/http2-the-protocol-that-stopped-the-connection-explosion-4123</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/anik_sikder_313/why-http11-eventually-became-a-bottleneck-5657"&gt;previous article&lt;/a&gt;, we explored why HTTP/1.1 eventually became a bottleneck.&lt;/p&gt;

&lt;p&gt;The web had evolved from a collection of simple documents into a platform for complex applications.&lt;/p&gt;

&lt;p&gt;Browsers were no longer requesting a handful of files.&lt;/p&gt;

&lt;p&gt;They were requesting hundreds.&lt;/p&gt;

&lt;p&gt;To cope with these growing demands, browser vendors adopted a workaround:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser
 ├── TCP Connection 1
 ├── TCP Connection 2
 ├── TCP Connection 3
 ├── TCP Connection 4
 ├── TCP Connection 5
 └── TCP Connection 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The strategy worked.&lt;/p&gt;

&lt;p&gt;Pages loaded faster.&lt;/p&gt;

&lt;p&gt;Users were happier.&lt;/p&gt;

&lt;p&gt;But underneath the surface, a new problem was emerging.&lt;/p&gt;

&lt;p&gt;The web was becoming dependent on opening more and more connections just to maintain acceptable performance.&lt;/p&gt;

&lt;p&gt;Engineers realized something important:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The problem wasn't the network. The problem was how HTTP used the network.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;HTTP/2 was created to rethink that relationship.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Fundamental Shift
&lt;/h2&gt;

&lt;p&gt;HTTP/1.1 was built around a relatively simple assumption:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request
↓
Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Repeat this process enough times and eventually the page loads.&lt;/p&gt;

&lt;p&gt;HTTP/2 challenged that model.&lt;/p&gt;

&lt;p&gt;Instead of asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How can we create more connections?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How can we make a single connection dramatically more efficient?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That single idea shaped the entire protocol.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why More Connections Were Never the Real Solution
&lt;/h2&gt;

&lt;p&gt;Imagine managing a warehouse.&lt;/p&gt;

&lt;p&gt;You receive 1,000 orders per hour.&lt;/p&gt;

&lt;p&gt;One approach is to hire more managers.&lt;/p&gt;

&lt;p&gt;Another approach is to improve the workflow.&lt;/p&gt;

&lt;p&gt;HTTP/1.1 effectively chose the first option.&lt;/p&gt;

&lt;p&gt;More traffic?&lt;/p&gt;

&lt;p&gt;Open more TCP connections.&lt;/p&gt;

&lt;p&gt;Need more resources?&lt;/p&gt;

&lt;p&gt;Open even more connections.&lt;/p&gt;

&lt;p&gt;The result was increasing overhead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;More TCP handshakes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;More memory allocation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;More connection state tracking&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;More CPU usage&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;More congestion on busy networks&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Performance improved, but efficiency suffered.&lt;/p&gt;

&lt;p&gt;HTTP/2 aimed to solve the workflow problem instead.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Birth of Multiplexing
&lt;/h2&gt;

&lt;p&gt;The most important innovation in HTTP/2 is multiplexing.&lt;/p&gt;

&lt;p&gt;To understand why, imagine ordering five items from a warehouse:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. HTML
2. CSS
3. JavaScript
4. Product Images
5. Fonts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In HTTP/1.1, resources often competed with one another.&lt;/p&gt;

&lt;p&gt;In HTTP/2, requests become independent streams.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TCP Connection
│
├── Stream 1 → HTML
├── Stream 2 → CSS
├── Stream 3 → JavaScript
├── Stream 4 → Images
└── Stream 5 → Fonts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All streams share the same connection.&lt;/p&gt;

&lt;p&gt;Instead of waiting for one resource to finish before another can progress, data from multiple streams can be interleaved.&lt;/p&gt;

&lt;p&gt;This means the server can send:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML Chunk
CSS Chunk
Image Chunk
JavaScript Chunk
HTML Chunk
Font Chunk
Image Chunk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser reassembles everything correctly.&lt;/p&gt;

&lt;p&gt;This seemingly simple change transformed web performance.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Actually Happens Under the Hood?
&lt;/h2&gt;

&lt;p&gt;Multiplexing is often explained as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Multiple requests at the same time.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While technically true, it misses the interesting part.&lt;/p&gt;

&lt;p&gt;HTTP/2 introduces a concept called frames.&lt;/p&gt;

&lt;p&gt;Every request and response is broken into smaller units called frames.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request
    ↓
 Frames
    ↓
 Stream
    ↓
 Connection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think of a large book being split into hundreds of pages.&lt;/p&gt;

&lt;p&gt;Instead of delivering one complete book at a time, pages from many books can travel together.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Frame A1
Frame B1
Frame C1
Frame A2
Frame B2
Frame C2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser knows which frame belongs to which stream.&lt;/p&gt;

&lt;p&gt;This allows continuous utilization of the connection.&lt;/p&gt;

&lt;p&gt;Idle time drops dramatically.&lt;/p&gt;

&lt;p&gt;Bandwidth utilization improves.&lt;/p&gt;




&lt;h2&gt;
  
  
  Binary Framing: The Invisible Revolution
&lt;/h2&gt;

&lt;p&gt;One of the biggest architectural changes in HTTP/2 is something users never see.&lt;/p&gt;

&lt;p&gt;HTTP/1.1 is text-based.&lt;/p&gt;

&lt;p&gt;A request looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nf"&gt;GET&lt;/span&gt; &lt;span class="nn"&gt;/products&lt;/span&gt; &lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;example.com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Humans can read it.&lt;/p&gt;

&lt;p&gt;Computers can read it too.&lt;/p&gt;

&lt;p&gt;But computers don't naturally think in text.&lt;/p&gt;

&lt;p&gt;They think in binary.&lt;/p&gt;

&lt;p&gt;HTTP/2 introduces a binary framing layer.&lt;/p&gt;

&lt;p&gt;Instead of transmitting textual messages directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP Message
        ↓
Binary Frames
        ↓
TCP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Faster parsing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;More predictable processing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduced protocol complexity&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Better performance under heavy traffic&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The protocol becomes easier for machines to handle efficiently.&lt;/p&gt;




&lt;h2&gt;
  
  
  Header Compression: Solving a Hidden Cost
&lt;/h2&gt;

&lt;p&gt;As websites grew, headers became surprisingly large.&lt;/p&gt;

&lt;p&gt;Consider a modern request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;Cookie: ...
Authorization: ...
User-Agent: ...
Accept-Language: ...
Cache-Control: ...
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Many of these values repeat across requests.&lt;/p&gt;

&lt;p&gt;In HTTP/1.1, they are often transmitted repeatedly.&lt;/p&gt;

&lt;p&gt;This creates waste.&lt;/p&gt;

&lt;p&gt;HTTP/2 introduces HPACK.&lt;/p&gt;

&lt;p&gt;HPACK maintains a dynamic table of previously transmitted header values.&lt;/p&gt;

&lt;p&gt;Instead of sending:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Authorization: Bearer abc123...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again and again, the client can reference a previously stored value.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Header Table

#1 Authorization
#2 Cookie
#3 User-Agent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Future requests simply reference the index.&lt;/p&gt;

&lt;p&gt;Less data travels over the network.&lt;/p&gt;

&lt;p&gt;Latency decreases.&lt;/p&gt;

&lt;p&gt;Bandwidth usage improves.&lt;/p&gt;




&lt;h2&gt;
  
  
  Prioritization: Not All Resources Are Equal
&lt;/h2&gt;

&lt;p&gt;Imagine loading an e-commerce homepage.&lt;/p&gt;

&lt;p&gt;Which resource matters first?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hero Image
Product Grid
Analytics Script
Tracking Pixel
Chat Widget
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clearly not everything has equal importance.&lt;/p&gt;

&lt;p&gt;HTTP/2 allows streams to carry priority information.&lt;/p&gt;

&lt;p&gt;The browser can effectively say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Render the visible page first.&lt;/p&gt;

&lt;p&gt;Fetch less important resources later.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This improves perceived performance.&lt;/p&gt;

&lt;p&gt;Users see content sooner.&lt;/p&gt;




&lt;h2&gt;
  
  
  Did HTTP/2 Eliminate Head-of-Line Blocking?
&lt;/h2&gt;

&lt;p&gt;This is where things become interesting.&lt;/p&gt;

&lt;p&gt;Many developers assume HTTP/2 completely solved Head-of-Line Blocking.&lt;/p&gt;

&lt;p&gt;It didn't.&lt;/p&gt;

&lt;p&gt;It solved one version of it.&lt;/p&gt;

&lt;p&gt;HTTP-level blocking was dramatically reduced through multiplexing.&lt;/p&gt;

&lt;p&gt;However, HTTP/2 still runs on TCP.&lt;/p&gt;

&lt;p&gt;TCP guarantees ordered delivery.&lt;/p&gt;

&lt;p&gt;Consider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Packet 1
Packet 2
Packet 3
Packet 4
Packet 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If Packet 3 is lost:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Packet 4 waits
Packet 5 waits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even if those packets belong to different streams.&lt;/p&gt;

&lt;p&gt;The operating system cannot deliver later packets until the missing packet arrives.&lt;/p&gt;

&lt;p&gt;This creates TCP-level Head-of-Line Blocking.&lt;/p&gt;

&lt;p&gt;HTTP/2 improved the application layer.&lt;/p&gt;

&lt;p&gt;But the transport layer still had limitations.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real-World Impact
&lt;/h2&gt;

&lt;p&gt;HTTP/2 fundamentally changed how modern websites are delivered.&lt;/p&gt;

&lt;p&gt;Benefits included:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fewer TCP connections&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lower network overhead&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Better bandwidth utilization&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Faster page rendering&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improved mobile performance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduced server resource consumption&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For large-scale applications serving millions of users, these improvements were substantial.&lt;/p&gt;

&lt;p&gt;HTTP/2 became one of the most important protocol upgrades in the history of the web.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Remaining Problem
&lt;/h2&gt;

&lt;p&gt;HTTP/2 solved many issues that plagued HTTP/1.1.&lt;/p&gt;

&lt;p&gt;But one major bottleneck survived.&lt;/p&gt;

&lt;p&gt;TCP itself.&lt;/p&gt;

&lt;p&gt;As mobile usage exploded and network conditions became less predictable, packet loss became increasingly expensive.&lt;/p&gt;

&lt;p&gt;Engineers began asking a new question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What if the transport layer itself needed to change?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That question eventually led to QUIC.&lt;/p&gt;

&lt;p&gt;And QUIC became the foundation of HTTP/3.&lt;/p&gt;




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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;HTTP/2 was designed to eliminate the inefficiencies of HTTP/1.1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiplexing allowed multiple streams to share a single connection.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Binary framing made communication more machine-efficient.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HPACK reduced repetitive header transmission.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stream prioritization improved perceived page performance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTTP-level Head-of-Line Blocking was largely solved.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TCP-level Head-of-Line Blocking remained.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;That remaining limitation ultimately inspired HTTP/3.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  One-Sentence Summary
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;HTTP/1.1 scaled by opening more connections; HTTP/2 scaled by making a single connection smarter.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>http</category>
      <category>systemdesign</category>
      <category>networking</category>
      <category>performance</category>
    </item>
    <item>
      <title>Why HTTP/1.1 Eventually Became a Bottleneck</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Wed, 01 Jul 2026 17:13:07 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/why-http11-eventually-became-a-bottleneck-5657</link>
      <guid>https://dev.to/anik_sikder_313/why-http11-eventually-became-a-bottleneck-5657</guid>
      <description>&lt;p&gt;To understand HTTP/2 and HTTP/3, we first need to understand the problem they were designed to solve.&lt;/p&gt;

&lt;p&gt;Many developers think protocol upgrades happen because engineers want newer technology.&lt;/p&gt;

&lt;p&gt;In reality, protocols evolve because existing systems hit limits.&lt;/p&gt;

&lt;p&gt;HTTP/2 and HTTP/3 were not created because HTTP/1.1 was broken.&lt;/p&gt;

&lt;p&gt;They were created because the modern web outgrew it.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Web HTTP/1.1 Was Designed For
&lt;/h2&gt;

&lt;p&gt;Imagine it's 2005.&lt;/p&gt;

&lt;p&gt;You open a typical website.&lt;/p&gt;

&lt;p&gt;The browser requests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;index.html
style.css
logo.png
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;A handful of files.&lt;/p&gt;

&lt;p&gt;The total page size might be a few hundred kilobytes.&lt;/p&gt;

&lt;p&gt;For this type of website, HTTP/1.1 performs reasonably well.&lt;/p&gt;

&lt;p&gt;Now fast-forward to today.&lt;/p&gt;

&lt;p&gt;Open a modern e-commerce platform, social network, or SaaS application.&lt;/p&gt;

&lt;p&gt;Your browser may request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML
CSS
JavaScript Bundles
Fonts
Icons
Product Images
Videos
Analytics Scripts
Tracking Pixels
API Requests
Recommendation Engines
Chat Widgets
Third-Party Integrations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of three requests, there may be hundreds.&lt;/p&gt;

&lt;p&gt;A modern webpage is often closer to an application than a document.&lt;/p&gt;

&lt;p&gt;The internet changed dramatically.&lt;/p&gt;

&lt;p&gt;HTTP/1.1 largely remained the same.&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding the Real Problem
&lt;/h2&gt;

&lt;p&gt;At first glance, downloading 100 files doesn't sound difficult.&lt;/p&gt;

&lt;p&gt;The challenge isn't the files themselves.&lt;/p&gt;

&lt;p&gt;The challenge is coordination.&lt;/p&gt;

&lt;p&gt;Imagine a warehouse receiving hundreds of orders.&lt;/p&gt;

&lt;p&gt;If workers can only process one order at a time, a queue quickly forms.&lt;/p&gt;

&lt;p&gt;The same idea applies to network communication.&lt;/p&gt;

&lt;p&gt;The browser wants many resources.&lt;/p&gt;

&lt;p&gt;The server has many resources.&lt;/p&gt;

&lt;p&gt;The protocol determines how efficiently they can communicate.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Single-Lane Highway Problem
&lt;/h2&gt;

&lt;p&gt;Think of a highway with only one lane.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;🚗 HTML
   ↓
🚗 CSS
   ↓
🚚 Large Image
   ↓
🚗 JavaScript
   ↓
🚗 Font File
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything must travel through the same lane.&lt;/p&gt;

&lt;p&gt;If a large truck blocks traffic, smaller vehicles behind it cannot pass.&lt;/p&gt;

&lt;p&gt;This is exactly what happens when network requests become serialized.&lt;/p&gt;

&lt;p&gt;One slow response can delay many others.&lt;/p&gt;

&lt;p&gt;The result is unnecessary waiting.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Restaurant Analogy
&lt;/h2&gt;

&lt;p&gt;Imagine a restaurant with only one waiter.&lt;/p&gt;

&lt;p&gt;A customer places an order.&lt;/p&gt;

&lt;p&gt;The waiter walks to the kitchen.&lt;/p&gt;

&lt;p&gt;The waiter waits.&lt;/p&gt;

&lt;p&gt;The food is prepared.&lt;/p&gt;

&lt;p&gt;The waiter returns.&lt;/p&gt;

&lt;p&gt;Only then can the next customer be served.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer 1
    ↓
 Waiter
    ↓
 Kitchen

Customer 2 waits...

Customer 3 waits...

Customer 4 waits...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As the restaurant grows busier, waiting time increases.&lt;/p&gt;

&lt;p&gt;The problem is not the customers.&lt;/p&gt;

&lt;p&gt;The problem is the process.&lt;/p&gt;

&lt;p&gt;HTTP/1.1 faced a similar challenge as web applications became more complex.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Head-of-Line Blocking?
&lt;/h2&gt;

&lt;p&gt;Suppose the browser requests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. HTML
2. CSS
3. app.js
4. hero-image.jpg
5. font.woff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now imagine the image is several megabytes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML             ✅ Complete
CSS              ✅ Complete
hero-image.jpg   ⏳ Slow
app.js           ❌ Waiting
font.woff        ❌ Waiting
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The image becomes the bottleneck.&lt;/p&gt;

&lt;p&gt;Resources behind it must wait.&lt;/p&gt;

&lt;p&gt;This phenomenon is called Head-of-Line Blocking.&lt;/p&gt;

&lt;p&gt;A single slow transfer can reduce the performance of everything behind it.&lt;/p&gt;

&lt;p&gt;Think of it like a traffic accident blocking an entire lane of vehicles.&lt;/p&gt;

&lt;p&gt;The vehicles themselves are not the problem.&lt;/p&gt;

&lt;p&gt;The blockage is.&lt;/p&gt;




&lt;h2&gt;
  
  
  Browser Engineers Fought Back
&lt;/h2&gt;

&lt;p&gt;Browser vendors quickly realized that relying on a single connection was inefficient.&lt;/p&gt;

&lt;p&gt;Instead of waiting for one connection to finish, browsers started opening multiple TCP connections.&lt;/p&gt;

&lt;p&gt;A simplified example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser
 ├── TCP Connection 1
 ├── TCP Connection 2
 ├── TCP Connection 3
 ├── TCP Connection 4
 ├── TCP Connection 5
 └── TCP Connection 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now multiple files could be downloaded simultaneously.&lt;/p&gt;

&lt;p&gt;This significantly improved perceived performance.&lt;/p&gt;

&lt;p&gt;For many years, browsers commonly opened around six parallel connections per domain.&lt;/p&gt;

&lt;p&gt;At first, this seemed like the perfect solution.&lt;/p&gt;

&lt;p&gt;But it introduced new costs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why More Connections Create More Overhead
&lt;/h2&gt;

&lt;p&gt;Every TCP connection is not free.&lt;/p&gt;

&lt;p&gt;Before any useful data can be transferred, a connection must be established.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client
   ↓
 SYN
   ↓
 SYN-ACK
   ↓
 ACK
   ↓
 Connection Ready
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only after the TCP handshake can data begin flowing.&lt;/p&gt;

&lt;p&gt;If six connections are opened:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6 Handshakes
6 Connection States
6 Buffers
6 Resource Allocations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser spends more effort.&lt;/p&gt;

&lt;p&gt;The server spends more effort.&lt;/p&gt;

&lt;p&gt;The network carries more overhead.&lt;/p&gt;

&lt;p&gt;What started as a workaround eventually became part of the problem.&lt;/p&gt;

&lt;p&gt;Engineers realized they were compensating for protocol limitations rather than eliminating them.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Turning Point
&lt;/h2&gt;

&lt;p&gt;By the early 2010s, the web had become dramatically different from the web HTTP/1.1 was originally designed for.&lt;/p&gt;

&lt;p&gt;Developers were building:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gmail-like applications&lt;/li&gt;
&lt;li&gt;Facebook-style feeds&lt;/li&gt;
&lt;li&gt;Streaming platforms&lt;/li&gt;
&lt;li&gt;Real-time dashboards&lt;/li&gt;
&lt;li&gt;Large e-commerce systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The industry needed a way to efficiently transfer many resources without opening dozens of connections.&lt;/p&gt;

&lt;p&gt;The goal became clear:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Instead of using many TCP connections inefficiently, use one connection intelligently.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That idea became the foundation of HTTP/2.&lt;/p&gt;




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

&lt;ul&gt;
&lt;li&gt;HTTP/1.1 was designed for a much simpler web.&lt;/li&gt;
&lt;li&gt;Modern applications require far more network requests than early websites.&lt;/li&gt;
&lt;li&gt;Head-of-Line Blocking can cause slow resources to delay others.&lt;/li&gt;
&lt;li&gt;Browsers worked around this limitation by opening multiple TCP connections.&lt;/li&gt;
&lt;li&gt;Multiple connections improved performance but increased overhead.&lt;/li&gt;
&lt;li&gt;The web eventually reached a point where workarounds were no longer enough.&lt;/li&gt;
&lt;li&gt;HTTP/2 was created to solve these architectural limitations more efficiently.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>backend</category>
      <category>http</category>
      <category>systemdesign</category>
      <category>webdev</category>
    </item>
    <item>
      <title>👨‍🍳 Part 4: Coroutines Waiters Who Listen</title>
      <dc:creator>Anik Sikder</dc:creator>
      <pubDate>Thu, 30 Oct 2025 15:00:00 +0000</pubDate>
      <link>https://dev.to/anik_sikder_313/part-4-coroutines-waiters-who-listen-4k61</link>
      <guid>https://dev.to/anik_sikder_313/part-4-coroutines-waiters-who-listen-4k61</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/anik_sikder_313/part-3-advanced-iteration-tricks-2d6k"&gt;last episode&lt;/a&gt;, our restaurant became a smooth-running machine with &lt;strong&gt;sous-chefs, conveyor belts, and kitchen gadgets&lt;/strong&gt; all powered by &lt;strong&gt;lazy pipelines&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But what if our waiters could not only &lt;em&gt;serve dishes&lt;/em&gt; but also &lt;em&gt;take your order while serving&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;Welcome to the world of &lt;strong&gt;coroutines&lt;/strong&gt; where generators become &lt;em&gt;two-way communication channels&lt;/em&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 1. From Generators → Coroutines
&lt;/h2&gt;

&lt;p&gt;So far, our waiters (generators) could &lt;em&gt;only send food out&lt;/em&gt; using &lt;code&gt;yield&lt;/code&gt;.&lt;br&gt;
Now we’ll make them &lt;em&gt;listen&lt;/em&gt; too by using &lt;code&gt;.send()&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  🍽️ Normal generator (one-way)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;waiter&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Serving dish 1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Serving dish 2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;waiter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Serving dish 1
Serving dish 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The waiter talks, we listen.&lt;br&gt;
But what if we want to &lt;em&gt;talk back&lt;/em&gt;?&lt;/p&gt;


&lt;h2&gt;
  
  
  🎤 2. Enter &lt;code&gt;.send()&lt;/code&gt; → Talking to Waiters
&lt;/h2&gt;

&lt;p&gt;With &lt;code&gt;.send()&lt;/code&gt;, you can &lt;strong&gt;send data into&lt;/strong&gt; a running generator.&lt;br&gt;
Let’s make the waiter respond to your requests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;interactive_waiter&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;👨‍🍳 Ready to take your order.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;dish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What would you like?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;🍲 Serving &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;dish&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;interactive_waiter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;          &lt;span class="c1"&gt;# start the waiter
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pasta&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  &lt;span class="c1"&gt;# send order
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;steak&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;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;👨‍🍳 Ready to take your order.
What would you like?
🍲 Serving pasta...
What would you like?
🍲 Serving steak...
What would you like?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✨ &lt;code&gt;next()&lt;/code&gt; starts the generator up to the first &lt;code&gt;yield&lt;/code&gt;.&lt;br&gt;
✨ &lt;code&gt;send()&lt;/code&gt; sends a value into the paused generator.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Think of &lt;code&gt;.send()&lt;/code&gt; as the &lt;em&gt;customer talking back&lt;/em&gt; to the waiter mid-meal.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  🧾 3. Real-World Mini Project: Live Event Processor
&lt;/h2&gt;

&lt;p&gt;Imagine we’re building a live analytics system that reacts to new events as they stream in.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;event_collector&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Total so far: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;GeneratorExit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Final total: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="si"&gt;}&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;p&gt;Now we can &lt;strong&gt;feed it events dynamically&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;collector&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;event_collector&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;collector&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;        &lt;span class="c1"&gt;# start
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;collector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;collector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;collector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;collector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;             &lt;span class="c1"&gt;# stop waiter
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Total so far: 0
Total so far: 10
Total so far: 15
Total so far: 35
Final total: 35
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 &lt;code&gt;.close()&lt;/code&gt; politely tells the waiter “You can go home now.”&lt;br&gt;
👉 &lt;code&gt;.throw()&lt;/code&gt; (optional) lets you raise an exception inside the generator.&lt;/p&gt;


&lt;h2&gt;
  
  
  🧨 4. &lt;code&gt;.throw()&lt;/code&gt; → Throw Problems at the Waiter
&lt;/h2&gt;

&lt;p&gt;Sometimes, the kitchen runs into trouble 🍳💥.&lt;br&gt;
You can &lt;strong&gt;throw exceptions into a coroutine&lt;/strong&gt; to simulate errors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;chef&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;dish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;yield&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Cooking &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;dish&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;🔥 Wrong ingredient!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;chef&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pasta&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;throw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# injects error
&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;salad&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;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Cooking pasta
🔥 Wrong ingredient!
Cooking salad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 &lt;code&gt;throw()&lt;/code&gt; sends an exception inside the generator, where you can handle it gracefully.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 5. Coroutine Pipelines → Reactive Conveyor Belts
&lt;/h2&gt;

&lt;p&gt;Now let’s combine our powers from earlier &lt;strong&gt;delegation + coroutines&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We’ll build a &lt;em&gt;live restaurant pipeline&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Orders stream in.&lt;/li&gt;
&lt;li&gt;One coroutine filters vegetarian dishes.&lt;/li&gt;
&lt;li&gt;Another coroutine logs them.
&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;def&lt;/span&gt; &lt;span class="nf"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;yield&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;🧾 Logged: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;vegetarian_filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;dish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;yield&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;🥩&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;dish&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dish&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;veg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;vegetarian_filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;veg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Send live dishes
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;dish&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;🥗 salad&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;🍝 pasta&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;🥩 steak&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;🍰 cake&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
    &lt;span class="n"&gt;veg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dish&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;🧾 Logged: 🥗 salad
🧾 Logged: 🍝 pasta
🧾 Logged: 🍰 cake
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;This is a &lt;em&gt;real coroutine pipeline&lt;/em&gt;: data flows in, stage by stage, with each coroutine doing one job and passing it onward.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  ⚙️ 6. Async/Await → Waiters in Parallel (Modern Coroutines)
&lt;/h2&gt;

&lt;p&gt;Python 3.5+ gave us &lt;strong&gt;asyncio&lt;/strong&gt;, where coroutines can multitask&lt;br&gt;
many waiters serving at once, without blocking each other!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;waiter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; started taking orders...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; finished!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;gather&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nf"&gt;waiter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;👨‍🍳 Chef 1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nf"&gt;waiter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;👩‍🍳 Chef 2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;👨‍🍳 Chef 1 started taking orders...
👩‍🍳 Chef 2 started taking orders...
👨‍🍳 Chef 1 finished!
👩‍🍳 Chef 2 finished!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Multiple waiters (async coroutines) handle customers simultaneously no blocking, no chaos.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🎨 ASCII Mental Model
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Customer
    ↓
 [ interactive coroutine ]
    ↓
 [ filter coroutine ]
    ↓
 [ logger coroutine ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each waiter not only &lt;em&gt;serves dishes&lt;/em&gt; but &lt;em&gt;talks, reacts, and coordinates&lt;/em&gt; in real time.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎬 Wrap-Up: The Grand Kitchen Finale
&lt;/h2&gt;

&lt;p&gt;Over the 4 parts, we’ve built a complete mental model of Python iteration from solo waiters to a full restaurant orchestra:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Analogy&lt;/th&gt;
&lt;th&gt;Key Idea&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Iterables &amp;amp; Generators&lt;/td&gt;
&lt;td&gt;Buffet &amp;amp; Waiter&lt;/td&gt;
&lt;td&gt;Lazy one-way serving&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;itertools&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Kitchen Gadgets&lt;/td&gt;
&lt;td&gt;Tools for smart iteration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;3&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Delegation&lt;/td&gt;
&lt;td&gt;Sous-Chefs &amp;amp; Pipelines&lt;/td&gt;
&lt;td&gt;Composable generator chains&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;4&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Coroutines&lt;/td&gt;
&lt;td&gt;Interactive Waiters&lt;/td&gt;
&lt;td&gt;Two-way, reactive pipelines&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;🎉 Final Takeaway:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Iterators feed data, generators process data, and coroutines interact with data.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Python’s iteration model isn’t just about looping&lt;br&gt;
it’s a &lt;strong&gt;design pattern for scalable, memory-friendly, and interactive data flow.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>dsa</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
