<script data-pm-proxy="intercept"></script><?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[The Blueprint Dynasty]]></title><description><![CDATA[Most engineers build features. Elite engineers build systems that outlast companies. Deep technical breakdowns of scalable architectures, production resilience, and the frameworks that make you indispensable. Not for beginners. For dynasty builders.]]></description><link>https://saifhatem.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!JJ03!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492ed2db-36a4-4f3e-9809-7e11518a0c24_736x736.png</url><title>The Blueprint Dynasty</title><link>https://saifhatem.substack.com</link></image><generator>Substack</generator><lastBuildDate>Fri, 04 Sep 2026 13:36:05 GMT</lastBuildDate><atom:link href="/__u/saifhatem.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Saif Hatem]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[saifhatem@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[saifhatem@substack.com]]></itunes:email><itunes:name><![CDATA[Saif Hatem]]></itunes:name></itunes:owner><itunes:author><![CDATA[Saif Hatem]]></itunes:author><googleplay:owner><![CDATA[saifhatem@substack.com]]></googleplay:owner><googleplay:email><![CDATA[saifhatem@substack.com]]></googleplay:email><googleplay:author><![CDATA[Saif Hatem]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Network Latency, Bandwidth & Jitter: Why 100Gbps Isn't Always Fast]]></title><description><![CDATA[We have 100Gbps bandwidth. But our service times out at 1Gbps load. Why? What's the difference between bandwidth and throughput?]]></description><link>https://saifhatem.substack.com/p/network-latency-bandwidth-and-jitter</link><guid isPermaLink="false">https://saifhatem.substack.com/p/network-latency-bandwidth-and-jitter</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Fri, 28 Aug 2026 23:11:50 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!BxX1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>&#8220;The network is slow&#8221; is not an engineering diagnosis.</p><p>Before upgrading your network interface cards (NICs) to 100Gbps or adding more bandwidth to your cloud VPC, you must identify exactly which network metric is failing.</p><p>High pipe capacity does not fix propagation delays or packet-level chaos.</p><h3>The Four Quantities: Four Different Fires</h3><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;06a81774-20ad-4ae0-95e3-d2205f746d20&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">Bandwidth (Theoretical Capacity)
   &#9474;
   &#9660;
Throughput (Achieved Wire Rate)
   &#9474;
   &#9660;
Goodput (Application-Useful Payload)
   &#9474;
   &#9660;
Latency &amp; Jitter (Propagation &amp; Packet Arrival Variance)</code></pre></div><h3>1. Bandwidth: The Theoretical Ceiling</h3><p>Bandwidth is the maximum number of bits per second a physical or logical path could carry under ideal, saturated conditions.</p><ul><li><p><strong>What It Measures:</strong> The advertised width of the bottleneck link along the communication path.</p></li><li><p><strong>The Common Fallacy:</strong> Bandwidth does <strong>not</strong> dictate how fast an individual bit travels across the wire (propagation speed is bounded by the speed of light in fiber, roughly 200,000 km/s). It only dictates how many bits you can pump into the pipe simultaneously.</p></li></ul><h3>2. Throughput: The Reality on the Wire</h3><p>Throughput is the actual rate of raw bits (or operations) successfully completed over the network in a given time window.</p><ul><li><p><strong>Throughput is always <span>&lt;=</span> Bandwidth:</strong> While your link might advertise 10Gbps bandwidth, real-world throughput is often far lower due to TCP window sizing, congestion control, and packet drops.</p></li></ul><h3>3. Goodput: What Your Application Actually Consumes</h3><p>Goodput is the rate of application-useful bytes delivered per second, strictly excluding protocol overhead.</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Goodput} = \\text{Throughput} - (\\text{Protocol Headers} + \\text{Retransmissions} + \\text{TCP ACKs})&quot;,&quot;id&quot;:&quot;ILLSWCCQPU&quot;}" data-component-name="LatexBlockToDOM"></div><ul><li><p><strong>Why the Split Matters:</strong> If network packet loss causes heavy TCP retransmissions, your wire <strong>throughput</strong> might remain high while your application <strong>goodput</strong> collapses to near zero.</p></li></ul><h3>4. Latency vs. Response Time: The Critical Distinction</h3><p>Engineers often treat latency and response time as synonyms. They are not:</p><ul><li><p><strong>One-Way Latency:</strong> The exact time it takes for a packet to travel from source transmission to destination reception.</p></li><li><p><strong>Round-Trip Time (RTT):</strong> The time taken for a data packet to travel from source to destination and return an acknowledgment. In distributed systems interviews, engineers saying &#8220;latency&#8221; for an RPC(Remote Procedure Call) almost always mean RTT(Round Trip Time).</p></li><li><p><strong>Response Time:</strong> The total end-to-end duration the client experiences:</p><p></p></li></ul><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Response Time} = \\text{Client Serialization} + \\text{Network RTT} + \\text{Server Queueing} + \\text{Execution Time}&quot;,&quot;id&quot;:&quot;SXCENNUSLH&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>As you can see, response time is composed of not only the RTT, but both client and server processing events, hence response time is usually greater than latency.</p><p><em>Analogy Example:</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!yAhY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7c3d0d-2665-480f-b35c-4d6922fad2ed_826x507.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!yAhY!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7c3d0d-2665-480f-b35c-4d6922fad2ed_826x507.png 424w, /__u/substackcdn.com/image/fetch/$s_!yAhY!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7c3d0d-2665-480f-b35c-4d6922fad2ed_826x507.png 848w, /__u/substackcdn.com/image/fetch/$s_!yAhY!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7c3d0d-2665-480f-b35c-4d6922fad2ed_826x507.png 1272w, /__u/substackcdn.com/image/fetch/$s_!yAhY!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7c3d0d-2665-480f-b35c-4d6922fad2ed_826x507.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!yAhY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7c3d0d-2665-480f-b35c-4d6922fad2ed_826x507.png" width="826" height="507" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/da7c3d0d-2665-480f-b35c-4d6922fad2ed_826x507.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:507,&quot;width&quot;:826,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Latency, Bandwidth, Throughput and Response Time | by Sandeep Tiwari |  Medium&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Latency, Bandwidth, Throughput and Response Time | by Sandeep Tiwari |  Medium" title="Latency, Bandwidth, Throughput and Response Time | by Sandeep Tiwari |  Medium" srcset="/__u/substackcdn.com/image/fetch/$s_!yAhY!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7c3d0d-2665-480f-b35c-4d6922fad2ed_826x507.png 424w, /__u/substackcdn.com/image/fetch/$s_!yAhY!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7c3d0d-2665-480f-b35c-4d6922fad2ed_826x507.png 848w, /__u/substackcdn.com/image/fetch/$s_!yAhY!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7c3d0d-2665-480f-b35c-4d6922fad2ed_826x507.png 1272w, /__u/substackcdn.com/image/fetch/$s_!yAhY!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7c3d0d-2665-480f-b35c-4d6922fad2ed_826x507.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>In the analogy of a pipe feeding water to a bucket, as shown in the image above, the bandwidth is the width of the pipe, the throughput is the rate of water flowing, the latency is the time taken from the moment it is in the pipe itself till it reaches the end. The response time is the latency plus previous processing, as depicted via the orange sqaure.</p><h3>5. Jitter: Where Timeout Budgets Die</h3><p>Jitter is the unpredictable statistical variation in packet arrival times over a network connection.</p><ul><li><p><strong>Tail Variance Over Means:</strong> A connection with an average latency of 20ms and <span>+-2 ms</span> jitter is stable. A connection with an average latency of 20ms and sporadic spikes to 300ms creates catastrophic tail latency.</p></li><li><p><strong>Operational Impact:</strong> Jitter triggers Head-of-Line (HOL) blocking in TCP streams, disrupts real-time streaming/voice protocols, and blows past static client timeout budgets.</p></li></ul><blockquote><p><strong><span>Head-of-Line (HOL) Blocking</span></strong><span> is a performance bottleneck where a single delayed or dropped packet at the front of a queue stalls every packet behind it, even if those trailing packets are completely ready to be processed or belong to unrelated streams.</span></p><ul><li><p><strong><span>In TCP:</span></strong><span> Because TCP guarantees in-order byte delivery, if packet 1 is lost in transit, the receiver&#8217;s operating system cannot hand packets 2, 3, or 4 to the application until packet 1 is retransmitted and acknowledged.</span></p></li></ul></blockquote><p></p><h1>What People Mix Up in Network Architecture</h1><p>Misdiagnosing network bottlenecks usually comes from conflating distinct physical and statistical realities. Here are the most common misconceptions engineers hit when designing and debugging distributed systems:</p><h3>1. Bandwidth is Not Propagation Speed</h3><p>A common mental trap is assuming a wider pipe moves an individual byte faster.</p><p>Bandwidth dictates <strong>capacity</strong>, not speed. The propagation speed of light in fiber optic cables is a hard physical constant (roughly 200,000 km/s).</p><ul><li><p>A TCP 3-way handshake between New York and London takes roughly <strong>56ms of fiber RTT</strong> on a 100Gbps connection, and it takes the exact same 56ms on a 10Mbps connection.</p></li><li><p>Upgrading bandwidth does not reduce baseline packet flight time; it only allows you to put more packets on the wire simultaneously.</p></li></ul><h3>2. Throughput and Latency are Orthogonal Axes</h3><p>Engineers often assume that low latency automatically means high throughput, or that high throughput means low latency. In reality, <strong>latency</strong> (how long one packet takes to travel) and <strong>throughput</strong> (how much volume passes through per second) operate on completely independent axes.</p><p>Think of it like a freight train versus a Formula 1 car:</p><ul><li><p><strong>High Throughput + High Latency (The Freight Train):</strong> A massive cargo train carries 10,000 tons of goods at once, but takes 12 hours to reach its destination. In networking, this is a bulk database backup streaming over a 10Gbps intercontinental link: you are moving gigabytes per second (high throughput), but every single packet takes 150ms to cross the ocean (high latency).</p></li><li><p><strong>Low Throughput + Low Latency (The Formula 1 Car):</strong> A race car travels at extreme speed, but can only carry a single driver. In networking, this is an algorithmic trading tick or a Redis cache ping over a local datacenter link: the message arrives in 200 microseconds (low latency), but consumes barely 64 bytes of bandwidth (low throughput).</p></li></ul><blockquote><p><strong>The Design Takeaway:</strong> If your system is bottlenecked by latency (e.g., waiting on 10 sequential synchronous database calls), increasing your network bandwidth from 1Gbps to 100Gbps will achieve <strong>0% performance improvement</strong>. You need fewer round trips, connection multiplexing, or geographic proximity, not a wider pipe.</p></blockquote><p></p><h3>3. ICMP Ping vs. Application p99 Latency</h3><p>Running a simple <code>ping</code> command in your terminal only tests the absolute best-case network path. It tells you almost nothing about what real users or microservices experience in production.</p><h3>The Two Different Realities</h3><ul><li><p><strong>ICMP (Internet Control Message Protocol) Ping (Best-Case Network Baseline):</strong></p><ul><li><p>Operates at the raw IP/OS kernel level without touching application code.</p></li><li><p>Sends lightweight (usually 32 to 64-byte) echo requests that the receiving kernel immediately bounces back.</p></li><li><p>Measures only physical transmission and switching delay under baseline conditions.</p></li><li><p>Ignores TCP handshakes, TLS handshakes, socket queueing, connection limits, and application logic.</p></li></ul></li><li><p><strong>Application p99 Latency (Real-World Tail Latency):</strong></p><ul><li><p>Measures the end-to-end time for a full application-level transaction (e.g., an HTTP API call or gRPC request).</p></li><li><p>Represents the 99th percentile: 99% of requests are faster than this number, and the slowest 1% are at or above it.</p></li><li><p>Includes every production reality that <code>ping</code> ignores:</p><ul><li><p><strong>OS &amp; Transport Delays:</strong> TCP connection establishment, TLS crypto negotiation, packet retransmissions, and full socket buffer stalls.</p></li><li><p><strong>Queueing Delays:</strong> Incoming request queues in the web server or reverse proxy when worker threads are busy.</p></li><li><p><strong>Runtime Overhead:</strong> Garbage Collection (GC) pauses (e.g., in Java or Go), thread context switching, and lock contention.</p></li><li><p><strong>Downstream Dependencies:</strong> Database query execution, disk I/O waits, and third-party API calls.</p></li></ul></li></ul></li></ul><h3>Why Averages Lie</h3><p>If 99 requests complete in 5ms and 1 request hits a GC pause or database lock and takes 2,000ms:</p><ul><li><p><strong>Arithmetic Mean (Average):</strong> Looks deceptively fast at <strong>24.95ms</strong>.</p></li><li><p><strong>p99 Latency:</strong> Correctly alerts you that your tail requests take a painful <strong>2,000ms (2 seconds)</strong>.</p></li></ul><p>Plaintext</p><pre><code><code>ICMP Ping:               Kernel-to-Kernel Echo (Lightweight byte bounce)
                         [ Network Only ]

Application p99:         Client Request &#9472;&#9472;&#9658; TLS/TCP Handshake 
                                        &#9472;&#9472;&#9658; Proxy Queue 
                                        &#9472;&#9472;&#9658; GC Pause / Lock Contention 
                                        &#9472;&#9472;&#9658; Database Query 
                                        &#9472;&#9472;&#9658; Client Response
</code></code></pre><blockquote><p><strong>The Production Rule:</strong> If network engineers report that <em>&#8220;ping looks fine at 2ms,&#8221;</em> but users are complaining that the application is slow, the bottleneck is living in queueing, serialization, or runtime tail latency. Measure tail distributions (p95, p99, p99.9) across the full application stack, not just ICMP pings.</p></blockquote><h3>4. Terminology Boundaries: Delay vs. Bitrate</h3><ul><li><p><strong>Delay vs. Latency:</strong> In networking contexts, these refer to the exact same physical quantity (the time required for bits to transit from A to B).</p></li><li><p><strong>Bitrate vs. Bandwidth:</strong> Bandwidth is the <strong>theoretical capacity cap</strong> of the underlying link. Bitrate is the <strong>actual rate of bits being actively transmitted</strong> by a specific stream or application at that moment.</p></li></ul><h3>5. High Utilization is Not &#8220;Healthy Capacity&#8221;</h3><p>Running infrastructure near 100% capacity is an operational failure mode, not cost efficiency:</p><ul><li><p><strong>Non-Linear Queueing Delays:</strong> As a network link, router buffer, or CPU approaches full utilization, queueing delay does not scale linearly: it grows asymptotically toward infinity. Squeezing the last 10% of capacity creates exponential latency spikes for the entire system.</p></li><li><p><strong>The 0% CPU Ghost Outage:</strong> A completely stalled service often looks deceptively healthy on dashboards. When thousands of application worker threads block synchronously on unresponsive downstream sockets, the CPU sits idle at near 0% and the NIC is completely quiet, while every incoming user request times out.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!UO9T!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!UO9T!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!UO9T!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!UO9T!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!UO9T!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!UO9T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1073298,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/213205150?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!UO9T!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!UO9T!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!UO9T!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!UO9T!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F211b4bcd-0dc1-445c-ab9a-04de9f6006d3_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h1>Where a Packet Actually Spends Its Time</h1><p>When an application sends a packet across the network, one-way latency is never a single unified delay. It is the mathematical sum of four distinct physical delays across every router hop along the path:<br></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Total Latency} = D_{\\text{propagation}} + D_{\\text{transmission}} + D_{\\text{queuing}} + D_{\\text{processing}}&quot;,&quot;id&quot;:&quot;DNWLNTHETR&quot;}" data-component-name="LatexBlockToDOM"></div><p>To diagnose latency issues or optimize distributed systems, you have to break down where your milliseconds are actually being consumed.</p><h3>1. Propagation Delay (<span>D_propagation</span>): The Physical Distance</h3><p>Propagation delay is the time it takes for a signal to physically travel through the transmission medium (fiber optic glass, copper wire, or air).</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;D_{\\text{propagation}} = \\frac{\\text{Distance}}{\\text{Signal Speed in Medium}}&quot;,&quot;id&quot;:&quot;DXPJDYGFUE&quot;}" data-component-name="LatexBlockToDOM"></div><ul><li><p>The Fiber Rule of Thumb: Light travels at roughly 300,000 km/s in a vacuum (c), but inside fiber optic glass (refractive index n &#8776; 1.5), it slows down to approximately 200,000 km/s (2/3 c).</p></li><li><p>The Math: This translates to roughly 5 microseconds per kilometer of one-way travel (or 1 ms per 100 km of round-trip distance).</p></li><li><p>Real-World RTT Baselines (Fiber Great-Circle):</p><ul><li><p>New York to San Francisco: 42 ms RTT</p></li><li><p>New York to London: 56 ms RTT</p></li><li><p>New York to Sydney: 160 ms theoretical minimum, typically 200 to 300 ms over real-world terrestrial and undersea cable routes.</p></li></ul></li></ul><blockquote><p><strong>The Hard Law</strong>: You cannot engineer your way out of propagation delay with software or faster network interface cards. If your client is in Sydney and your database is in New York, you pay a mandatory 200 ms penalty per round trip regardless of your link speed.</p></blockquote><h3>2. Transmission Delay: Pumping Bits onto the Wire</h3><p>Transmission (or serialization) delay is the time required to push all the bits of a packet onto the physical communication link.<br></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;D_{\\text{transmission}} = \\frac{\\text{Packet Size (bits)}}{\\text{Link Data Rate (bps)}}&quot;,&quot;id&quot;:&quot;JBVPAMOPMQ&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>Transmission delay depends strictly on packet size and link capacity: it is completely independent of physical distance.</p><ul><li><p>Standard 1500-byte MTU(Maximum Transmission Unit)  Packet (12,000 bits):</p><ul><li><p>At 1 Mbps: 12 ms</p></li><li><p>At 1 Gbps: 12 microseconds (0.012 ms)</p></li><li><p>At 100 Gbps: 0.12 microseconds</p></li></ul></li><li><p>Bulk Data Example (10 MB payload):</p><ul><li><p>At 1 Mbps: 10 seconds</p></li><li><p>At 100 Mbps: 0.1 seconds</p></li></ul></li></ul><blockquote><p><strong>The Takeaway:</strong> Upgrading to a fatter pipe (1 Gbps to 100 Gbps) shrinks only the transmission delay slice. It reduces the time needed to push bytes out of the network card, but does not move those bytes across the ocean any faster.</p></blockquote><h3>3. Queuing Delay: The Variable Bottleneck</h3><p>Queuing delay is the time a packet sits in intermediate router and switch buffers waiting for an egress link to free up.</p><ul><li><p><strong>The Source of Jitter:</strong> Queuing delay is dynamic and non-deterministic. When network traffic spikes or upstream links saturate, buffer queues fill up, causing packet arrival times to fluctuate wildly.</p></li><li><p><strong>Bufferbloat:</strong> When network operators configure excessively large router buffers to prevent packet drops, saturated connections accumulate massive queuing delays (hundreds of milliseconds of latency) instead of shedding load quickly.</p></li></ul><h3>4. Processing Delay: The Hardware Check</h3><p>Processing delay is the time an intermediate router or switch spends inspecting packet headers, validating checksums, and consulting routing tables to determine the next-hop interface.</p><ul><li><p>In modern network hardware, processing delay is handled directly by ASICs at wire speed and is practically negligible (typically low microseconds or nanoseconds).</p></li><li><p>Processing delay only becomes a critical bottleneck when the network hits its packets-per-second (PPS) limit rather than its raw bit bandwidth limit (e.g., during high-frequency SYN floods or tiny-packet micro-benchmarks).</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!BxX1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!BxX1!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!BxX1!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!BxX1!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!BxX1!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!BxX1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:756576,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/213205150?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!BxX1!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!BxX1!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!BxX1!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!BxX1!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11ff43ff-aefa-4c44-abf4-698dcf2c0de8_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h1>The Pipe You Have to Fill: Bandwidth-Delay Product</h1><p>Upgrading to a 100Gbps network link does not mean a single TCP connection will automatically transfer data at 100Gbps.</p><p>TCP requires acknowledgments (ACKs) to confirm data delivery. If the sender exhausts its allowed transmission window before an ACK returns from across the world, it stops transmitting. The physical fiber optic line sits completely empty while the sender waits.</p><h3>The Bandwidth-Delay Product (BDP)</h3><p>The <strong>Bandwidth-Delay Product (BDP)</strong> defines the exact volume of unacknowledged data (bytes in flight) required to keep a network link saturated at 100% capacity:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{BDP} = \\text{Bandwidth} \\times \\text{RTT}&quot;,&quot;id&quot;:&quot;QYLKZUGDJT&quot;}" data-component-name="LatexBlockToDOM"></div><p>BDP represents Little&#8217;s Law applied to raw network cabling: it is the total storage capacity of the physical fiber between two endpoints.</p><h4>The 100Gbps WAN Example</h4><p>Consider a 100Gbps intercontinental connection with a 100 ms Round-Trip Time (RTT):</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{BDP} = 100\\text{ Gbps} \\times 0.1\\text{ s} = 10\\text{ Gbits in flight} = 1.25\\text{ GB}&quot;,&quot;id&quot;:&quot;XBJLYLIMNU&quot;}" data-component-name="LatexBlockToDOM"></div><p>To keep this 100Gbps pipe fully saturated, the sender must transmit <strong>1.25 Gigabytes of continuous data</strong> into the network before receiving a single acknowledgment.</p><h3>The Single-Flow TCP Ceiling</h3><p>The maximum throughput of a single TCP connection is mathematically bounded by its buffer window and the round-trip latency:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Max TCP Throughput} \\approx \\frac{\\min(\\text{cwnd}, \\text{rwnd})}{\\text{RTT}}&quot;,&quot;id&quot;:&quot;KXGXMUMCKF&quot;}" data-component-name="LatexBlockToDOM"></div><p>Where:</p><ul><li><p><strong>cwnd (Congestion Window):</strong> The amount of data the sender allows into the network before receiving an ACK.</p></li><li><p><strong>rwnd (Receive Window):</strong> The buffer space advertised by the receiver.</p></li></ul><p>If your window size is smaller than the BDP of the connection, your achieved throughput collapses:</p><ul><li><p><strong>16 KB Window at 100 ms RTT:</strong></p><p></p></li></ul><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Throughput} = \\frac{16\\text{ KB}}{0.1\\text{ s}} \\approx 1.31\\text{ Mbps}&quot;,&quot;id&quot;:&quot;ERTSOEXOKF&quot;}" data-component-name="LatexBlockToDOM"></div><p><em>(Even on a 100Gbps physical link, the connection transfers at dial-up speeds).</em></p><ul><li><p><strong>64 KB Window at 100 ms RTT:</strong></p></li></ul><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Throughput} = \\frac{65,535\\text{ bytes}}{0.1\\text{ s}} \\approx 5.24\\text{ Mbps}&quot;,&quot;id&quot;:&quot;DYEVVQHNXD&quot;}" data-component-name="LatexBlockToDOM"></div><h3>The 16-Bit Ceiling &amp; TCP Window Scaling</h3><p>The original TCP header specification allocated only <strong>16 bits</strong> for the window size field, creating a hard mathematical ceiling of <strong>65,535 bytes (64 KB)</strong> per connection.</p><p>On long fat networks (LFNs), a 64 KB limit caps throughput at roughly 5.2 Mbps regardless of how many gigabits your physical NIC supports.</p><h4>The Solution: TCP Window Scaling (RFC 7323)</h4><p>To overcome this constraint, modern operating systems use <strong>TCP Window Scaling</strong>:</p><ul><li><p>Uses a TCP option during the initial SYN/SYN-ACK 3-way handshake.</p></li><li><p>Adds a scale factor shift (up to 14 bits), multiplying the 16-bit window value up to a maximum window size of <strong>1 GiB (<span>2^30</span> bytes)</strong>.</p></li></ul><blockquote><p><strong>The Production Hazard:</strong> If misconfigured middleboxes, firewalls, or legacy load balancers strip the TCP Window Scale option from SYN packets, the connection falls back to the legacy 64 KB ceiling. The network engineer sees a 100Gbps link, the application dashboard sees a 5 Mbps transfer rate, and both measurements are technically correct.</p></blockquote><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!9hx5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!9hx5!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!9hx5!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!9hx5!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!9hx5!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!9hx5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg" width="1456" height="794" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:794,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:629288,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/213205150?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!9hx5!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!9hx5!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!9hx5!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!9hx5!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25be10dc-c678-4a35-9320-06eb5d7a2d76_2816x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h1>Why the Service Times Out at 1Gbps on a 100G NIC</h1><p>A timeout is a <strong>wait budget</strong>, not a bandwidth budget. Upgrading to a 100G network interface card gives you massive carrying capacity, but 99 unused gigabits do not grant your application a single extra millisecond of time.</p><p>If your service residence time (time waiting in the kernel listen queue + application execution time) exceeds the caller&#8217;s timeout budget, the caller closes the socket and often triggers an automatic retry.</p><p>Here is why services fail with timeouts while the 100G NIC sits virtually idle.</p><h3>1. The Chatty Call Graph: Sequential Latency Accumulation</h3><p>When a microservice architecture processes a single incoming request by making sequential downstream RPCs, <strong>propagation delay acts as an absolute physical floor on every single hop</strong>.<br></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;T_{\\text{total}} = \\sum_{i=1}^{N} (\\text{Network RTT}_i + \\text{Processing Time}_i)&quot;,&quot;id&quot;:&quot;PISQWRLMVE&quot;}" data-component-name="LatexBlockToDOM"></div><p>If a caller sets a 50 ms timeout budget:</p><ul><li><p>Two sequential 20 ms RPC hops will easily exceed the 50 ms budget once minor server processing is added, even if each hop would comfortably pass in isolation.</p></li><li><p><strong>Real Cloud Floors:</strong></p><ul><li><p><strong>Intra-AZ:</strong> Typically sub-millisecond (100 to 300 &#956;s with SR-IOV/Enhanced Networking).</p></li><li><p><strong>Cross-AZ </strong> Single-digit milliseconds (roughly 1 to 1.5 ms).</p></li><li><p><strong>Cross-Region:</strong> Tens to hundreds of milliseconds (e.g., US-East to EU-West is ~70 to 80 ms).</p></li></ul></li><li><p><strong>The Math:</strong> Executing 20 serial RPC hops across regions at 80 ms each costs <strong>1.6 seconds of pure wait time</strong>, transferring barely a few kilobytes while violating every standard timeout SLA.</p><p></p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!6zAS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!6zAS!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!6zAS!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!6zAS!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!6zAS!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!6zAS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:857744,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/213205150?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!6zAS!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!6zAS!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!6zAS!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!6zAS!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F381fed9b-cbc4-47dd-b53d-702f95bed0a8_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>2. Client and Edge Timeout Defaults</h3><p>Timeouts are strictly an application-layer construct, not a property of your network hardware:</p><ul><li><p><strong>NGINX:</strong> <code>proxy_read_timeout</code> defaults to <strong>60 seconds</strong>, measuring idle time between successive read operations, not total request duration.</p></li><li><p><strong>cURL:</strong> Has <strong>no default max-time</strong>; it will hang indefinitely unless explicitly configured via <code>--max-time</code>.</p></li><li><p><strong>Java Sockets (</strong><code>java.net.Socket</code><strong>):</strong> Read calls block <strong>forever</strong> by default unless <code>setSoTimeout()</code> is explicitly set.</p></li></ul><p>A timeout occurs because a client timer fired, not because the physical wire reached its bandwidth limit.</p><h3>3. Starving the Pipe: Small Windows and No Pipelining</h3><p>If your application protocol relies on strict request-response ping-pong (stop-and-wait) over a single TCP connection, you never generate enough in-flight bytes to fill the pipe.</p><ul><li><p>When <span>cwnd &lt; BDP</span> (due to slow start, small receive buffers, or missing window scaling), the sender pauses after sending a few kilobytes to wait for round-trip ACKs.</p></li><li><p>The physical 100G link sits empty, throughput stagnates around a few megabits per second, and sequential requests time out waiting for their turn on the wire.</p></li></ul><h3>4. Small Packets vs. High Packets-Per-Second (PPS)</h3><p>A link&#8217;s capacity is constrained by <strong>packets per second (PPS)</strong> and CPU interrupt processing just as much as raw bit throughput:</p><ul><li><p><strong>1 Gbps of 64-byte minimum Ethernet frames</strong> (84 bytes on the wire with preamble and inter-frame gap) requires <strong>1,488,095 packets/second</strong>.</p></li><li><p><strong>1 Gbps of standard 1500-byte MTU frames</strong> requires only <strong>~81,274 packets/second</strong>.</p></li></ul><p>At 1.48 million PPS, the bottleneck shifts to kernel <code>softirq</code> handling, CPU core pinning, and context switching. The CPU saturates handling network interrupts while raw network bandwidth appears underutilized at just 1%.</p><h3>5. Bufferbloat and Hidden Queuing Delay</h3><p>When intermediate switches or routers configure excessively deep packet buffers to avoid dropping packets:</p><ul><li><p>Congested links accumulate hundreds of milliseconds (or even seconds) of queuing delay inside intermediate hardware buffers.</p></li><li><p>TCP never receives immediate packet-drop signals to trigger congestion backoff, breaking feedback loops.</p></li><li><p>Interface monitoring counters report healthy zero-loss throughput, while application p99 response times spike directly into timeout territory.</p></li></ul><h3>6. The Non-Network Culprits: Proving the Root Cause</h3><p>Before assuming the network is broken, remember that application stalls manifest with identical symptoms:</p><ul><li><p><strong>Garbage Collection (GC) Pauses:</strong> Stop-the-world pauses freeze thread execution, causing TCP listen queues to back up.</p></li><li><p><strong>Thread Pool Exhaustion:</strong> When all worker threads block on a shared lock or a hung downstream dependency, incoming requests sit in the socket backlog until the client timer expires.</p></li><li><p><strong>Disk I/O Wait:</strong> Synchronous logging or database write stalls hold request threads hostage while the network card sits idle at 0% utilization.</p></li></ul><h1>Jitter, Loss, and the Throughput You Actually Get</h1><p>High advertised bandwidth is meaningless in the presence of packet loss and timing variance.</p><p>When packets drop or queue unpredictably, TCP&#8217;s underlying congestion control algorithms reduce transmission rates, transforming minor network hiccups into severe application tail latencies.</p><h3>1. Where Jitter Actually Originates</h3><p>Jitter is the variance in packet arrival times. It rarely comes from a single source; it accumulates across the entire physical and logical path:</p><ul><li><p><strong>Buffer Queuing &amp; Bufferbloat:</strong> Packets wait behind varying traffic bursts in intermediate router buffers.</p></li><li><p><strong>Multi-Tenant &#8220;Noisy Neighbors&#8221;:</strong> Shared virtualized network interfaces and hypervisor vCPU scheduling introduce random micro-stalls.</p></li><li><p><strong>Physical Medium &amp; Last-Mile Variance:</strong> Baseline first-hop latency varies dramatically before traffic even reaches the core internet:</p><ul><li><p><strong>Fiber:</strong> 10 to 20 ms</p></li><li><p><strong>Cable:</strong> 15 to 40 ms</p></li><li><p><strong>DSL:</strong> 30 to 65 ms</p></li></ul></li><li><p><strong>Equal-Cost Multi-Path (ECMP) Hash Flips:</strong> If a flow&#8217;s 5-tuple changes or a router rebalances paths dynamically, packets suddenly take a longer or shorter route mid-stream, arriving out of order.</p></li><li><p><strong>Runtime &#8220;Ghost&#8221; Jitter:</strong> Stop-the-world Garbage Collection (GC) pauses, hypervisor steals, and thread context switching look identical to network jitter on client-side latency histograms.</p></li></ul><h3>2. TCP Head-of-Line (HOL) Blocking: Structural Jitter</h3><p>TCP guarantees strict, in-order byte stream delivery. This fundamental guarantee creates structural jitter at the transport layer:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!1IYT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!1IYT!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!1IYT!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!1IYT!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!1IYT!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!1IYT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:927048,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/213205150?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!1IYT!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!1IYT!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!1IYT!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!1IYT!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F542b006a-511a-4aeb-8f3b-87af1a35a0dc_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>If Segment 1 is dropped, the receiving operating system kernel cannot deliver Segments 2, 3, or 4 to the application layer. They sit in the socket receive buffer until Segment 1 is successfully retransmitted.</p><p>Your median latency (p50) remains unaffected, but your tail latency (p99) absorbs the full cost of the lost packet plus the entire retransmission round trip.</p><h3>3. The Timeout-Retry Death Spiral</h3><p>Setting aggressive timeouts without understanding jitter distributions creates cascading systemic failure:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!qfyz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!qfyz!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!qfyz!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!qfyz!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!qfyz!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!qfyz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:839166,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/213205150?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!qfyz!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!qfyz!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!qfyz!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!qfyz!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a4158ff-77f2-4332-9da6-c273931a1364_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h4>Mitigating the Spiral</h4><ul><li><p><strong>Retry Budgets:</strong> Enforce a hard per-client retry budget (capping retries at ~10% of total requests) to restrict maximum load amplification to roughly 1.1&#215;.</p></li><li><p><strong>Exponential Backoff with Jitter:</strong> Always add randomized jitter to retry intervals. Without randomness, synchronized client herds retry in lockstep waves, repeatedly hammering recovered services back into failure. (This will have an entire article on its own later)</p></li></ul><h3>4. Packet Loss: Fast Retransmit vs. The RTO Cliff</h3><p>When packet loss occurs, TCP treats it as an explicit signal of network congestion. The latency penalty depends entirely on how the loss is detected:</p><ul><li><p><strong>Fast Retransmit (3 Duplicate ACKs):</strong> If subsequent packets make it through, the receiver generates duplicate ACKs. The sender retransmits the missing segment immediately without waiting for a timer, incurring a minor latency hit of roughly one RTT.</p></li><li><p><strong>Retransmission Timeout (RTO):</strong> If a full burst or the tail packet of a transaction is dropped, duplicate ACKs cannot be generated. The sender must wait for the RTO timer to expire (often hundreds of milliseconds). Once RTO fires:</p><ul><li><p>The Congestion Window (<code>cwnd</code>) collapses back toward 1 MSS (Maximum Segment Size).</p></li><li><p>The connection resets to Slow Start.</p></li><li><p>Application p99 tail latency spikes dramatically.</p></li></ul></li></ul><h3>5. The Mathis Equation: Throughput Collapse Under Loss</h3><p>The mathematical ceiling of a TCP Reno-style flow under steady-state packet loss (detected by duplicate ACKs without timing out) is defined by the <strong>Mathis Equation</strong>:<br></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Throughput} \\lesssim \\frac{\\text{MSS}}{\\text{RTT}} \\times \\frac{1}{\\sqrt{p}}&quot;,&quot;id&quot;:&quot;QEDFZJAEKH&quot;}" data-component-name="LatexBlockToDOM"></div><p>Where:</p><ul><li><p><strong>MSS:</strong> Maximum Segment Size (typically 1460 bytes for a 1500-byte MTU).</p></li><li><p><strong>RTT:</strong> Round-Trip Time.</p></li><li><p><strong>p:</strong> Packet loss rate (<span>0 &lt; p &lt; 1</span>).</p></li></ul><p><em>(Note: At <span>p = 0</span>, the formula does not apply; throughput defaults to:</em></p><p><em><span>min(cwnd, rwnd)/RTT</span>).</em></p><h4>The Math in Practice</h4><p>On a 100 ms intercontinental link with a standard 1460-byte MSS:</p><ul><li><p>At <strong>1% packet loss (<span>p = 0.01</span>):</strong> Throughput is capped at roughly <strong><span>1.17 Mbps</span></strong>.</p></li><li><p>At <strong>0.1% packet loss (<span>p = 0.001</span>):</strong> Throughput is capped at roughly <strong><span>3.69 Mbps</span></strong>.</p></li></ul><p>A tiny 1% packet loss rate reduces a 100Gbps physical link down to early-2000s DSL throughput for a single TCP stream.</p><h3>6. The Production Law: Quote the Tail</h3><p>Your median metrics (p50) represent what is going right; your tail metrics (p95, p99, p99.9) represent what is breaking.</p><p>A system can report an apparently healthy p50 latency of 15 ms while its p99 is 2,500 ms due to HOL blocking and RTO resets. Always measure and set Service Level Objectives (SLOs) against the tail distribution.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!DcMD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!DcMD!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!DcMD!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!DcMD!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!DcMD!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!DcMD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:568325,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/213205150?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!DcMD!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!DcMD!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!DcMD!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!DcMD!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0db77ae7-ee81-4e65-8fb4-f62de1dd0f81_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h1>Failure Modes: Where Distributed Systems Break on the Wire</h1><p>Network failures rarely announce themselves with a clean &#8220;connection failed&#8221; error. Instead, they manifest as ghost stalls, asymmetric status codes, and silent socket deadlocks.</p><p>Understanding these failure modes requires looking at the exact state of the kernel, network buffers, and timeout clocks.</p><h3>1. Connection &amp; Handshake Failures</h3><ul><li><p><strong>Listen Queue Exhaustion:</strong> When the operating system kernel completes the TCP 3-way handshake, it places the socket into the accept queue (listen backlog). If the application runtime is slow or blocked, it fails to call <code>accept()</code> in time, causing the backlog to fill. New incoming <code>SYN</code> packets are ignored or dropped. The calling client blocks inside its kernel <code>connect()</code> call, where default OS-level connect timeouts can last several minutes before throwing an error.</p></li><li><p><strong>The Three-Clock Confusion:</strong> Engineers frequently mix up three distinct timeout boundaries:</p><ul><li><p><strong>Connect Timeout:</strong> Time allowed to establish the TCP 3-way handshake.</p></li><li><p><strong>Request (Deadline) Timeout:</strong> Total time allowed from request dispatch to final response delivery.</p></li><li><p><strong>Idle (Read/Write) Timeout:</strong> Maximum time allowed between successive chunks of data over an open socket.</p></li></ul></li></ul><h3>2. In-Flight Failure Modes</h3><ul><li><p><strong>The 504 Edge / 200 Upstream Asymmetry:</strong> An edge reverse proxy returns an HTTP <code>504 Gateway Timeout</code> to the client, but the upstream application logs show an HTTP <code>200 OK</code>. The upstream completed the work successfully, but exceeded the proxy&#8217;s idle read timeout limit (e.g., NGINX&#8217;s default 60-second <code>proxy_read_timeout</code>). The proxy dropped the client connection while the backend continued processing unaware.</p></li><li><p><strong>Missing Deadline Propagation:</strong> When downstream hops do not inherit the caller&#8217;s remaining time budget, each service waits for its own independent full timeout <span>T</span>. If a client disconnects at the edge after 200 ms, downstream services continue executing queries and burning CPU/thread resources for seconds on an abandoned request. Deadlines and cancellations must propagate down the entire RPC tree.</p></li><li><p><strong>TCP Incast (Many-to-One Fan-In):</strong> In scatter-gather patterns (e.g., MapReduce shuffles or distributed search aggregations), dozens of worker nodes reply to a single coordinator simultaneously. The coordinator&#8217;s top-of-rack (ToR) switch port buffer overflows instantly, triggering massive packet drops and forced Retransmission Timeouts (RTOs).</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!F2ZH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!F2ZH!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!F2ZH!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!F2ZH!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!F2ZH!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!F2ZH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:891976,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/213205150?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!F2ZH!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!F2ZH!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!F2ZH!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!F2ZH!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fcc6da7-69bf-461c-a9f4-5a01adbf62fc_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ul><li><p><strong>Path MTU / Black Hole Discovery:</strong> If intermediate routers have a smaller Maximum Transmission Unit (MTU) and the Don&#8217;t Fragment (DF) bit is set, the router drops large packets and attempts to return an ICMP &#8220;Fragmentation Needed&#8221; packet. If a firewall filters out ICMP messages, the sender never knows to reduce packet size. Small ICMP pings and TLS handshakes succeed, but large HTTP response payloads vanish silently.</p></li><li><p><strong>Window-Limited Single Flow:</strong> Running <code>iperf3 -P 32</code> achieves 100Gbps by aggregating 32 concurrent connections, but your application runs as <code>iperf3 -P 1</code> over a single TCP stream. If the Congestion Window (<code>cwnd</code>) or TCP window scale is constrained, a single stream cannot fill the pipe&#8217;s Bandwidth-Delay Product.</p></li></ul><h3>3. Idle Socket Failures</h3><ul><li><p><strong>Silent NAT/Firewall Table Eviction (The 5 AM Problem):</strong> Stateful firewalls and NAT gateways maintain finite state tables with idle timeout limits (often 5 to 60 minutes). If a connection sits idle, the firewall drops the state entry silently without sending a <code>TCP RST</code>. On the next application write, packets vanish into a black hole. Under Linux defaults (<code>tcp_retries2 = 15</code>), the kernel retransmits for up to 15 to 30 minutes before returning an error, locking application worker threads in a synchronous write block the entire time.</p></li><li><p><strong>The 0% CPU Ghost Outage:</strong> When downstream network calls hang without socket read timeouts, every application worker thread blocks synchronously on kernel I/O wait. Dashboards show near 0% CPU utilization and zero network traffic, yet the service is completely unresponsive to new requests.</p></li></ul><h3>4. Measuring the Wrong Layer</h3><ul><li><p><strong>Raw Throughput vs. Serial Latency:</strong> Sinking time into maximizing raw <code>iperf</code> throughput does not resolve a chatty call graph bottlenecked on 40 serial, synchronous gRPC round trips.</p></li><li><p><strong>Average Dashboard Latency:</strong> Averages conceal tail breakdown. A dashboard displaying a stable 15 ms average latency will completely mask a 3,000 ms p99 spike driven by packet loss recovery and thread pool saturation.</p></li><li><p><strong>SoftIRQ &amp; Packet Rate Saturation:</strong> When a machine processes millions of minimum-sized Ethernet frames per second (e.g., small UDP messages or SYN packets), CPU cores saturate handling <code>ksoftirqd</code> hardware interrupts long before raw bit bandwidth capacity is reached.</p></li></ul><h1>Trade-Offs Against the Real Alternatives</h1><p>The core architectural tension in networking is predictable tail latency versus cost efficiency:</p><ul><li><p><strong>Predictable tail latency</strong> requires static partitioning: dedicated capacity, provisioned slack, and minimal queue depths.</p></li><li><p><strong>Cost efficiency and high utilization</strong> rely on dynamic sharing: packet switching, multi-tenancy, and statistical multiplexing.</p></li></ul><p>Queuing delay and jitter are simply the bill you pay for running infrastructure near capacity. They are not inevitable laws of physics; they are the direct trade-offs of your deployment choices.</p><h3>The Decision Matrix: What Problem Are You Actually Solving?</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!sTLb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!sTLb!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!sTLb!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!sTLb!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!sTLb!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!sTLb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1135129,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/213205150?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!sTLb!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!sTLb!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!sTLb!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!sTLb!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a465439-9f08-44a4-b804-ee6a956ea7b9_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>1. When to Buy More Bandwidth</h3><p>Upgrade link capacity when you are moving raw, bulk byte volume and the physical pipe itself is saturated.</p><ul><li><p><strong>Ideal Use Cases:</strong> Video streaming ingest, large-scale database backups, bulk file transfers, and asynchronous cross-region blob replication.</p></li><li><p><strong>When It Fails:</strong> Buying bandwidth is useless against propagation delays and single-stream window limits. For standard HTTP and REST/gRPC microservices, latency&#8212;not bandwidth&#8212;is almost always the performance ceiling. RTT is bounded by the speed of light in fiber (<span>approx 2/3 c</span>), which more gigabits cannot accelerate.</p></li></ul><h3>2. When to Cut RTT (Move Closer)</h3><p>Shrinking round-trip distance is the primary fix for chatty call graphs and strict timeout budgets.</p><ul><li><p><strong>Architectural Lever:</strong> Deploy edge CDNs for static assets, regionalize application clusters closer to users, or collapse serial microservice hops into co-located pods.</p></li><li><p><strong>The Math:</strong> Eliminating three inter-region hops at 70 ms each reclaims <strong>210 ms of pure wait time</strong> on every transaction before application logic even starts executing.</p></li></ul><h3>3. When to Fill the Pipe (Maximize In-Flight Bytes)</h3><p>When Bandwidth-Delay Product (BDP) is your bottleneck, tune the transport layer to keep the pipe saturated.</p><ul><li><p><strong>Architectural Lever:</strong> Enable TCP window scaling, configure long-lived HTTP keepalive pools, and adopt HTTP/2 or HTTP/3 stream multiplexing over persistent sockets.</p></li><li><p><strong>The Caveat:</strong> Running a single massive TCP stream risks transport-level Head-of-Line (HOL) blocking if a packet drops. Balancing across multiple parallel connections or migrating to QUIC mitigates single-stream stalls.</p></li></ul><h3>4. Timeouts vs. Retries: Pick Your Failure Mode</h3><ul><li><p><strong>Looser Timeouts:</strong> Absorbs tail jitter spikes without failing, but delays load shedding and locks up server worker threads when downstreams stall.</p></li><li><p><strong>Tighter Timeouts + Bounded Retries:</strong> Fails fast and recovers quickly from transient network drops. Enforce a strict per-client retry budget (capping retries to <span>&lt;= 10%</span>) combined with exponential backoff and randomized jitter to prevent retry storms.</p></li></ul><h3>5. Buffer Sizing: Queue Depth vs. Bufferbloat</h3><p>Queues must be finite, or response times will be unbounded.</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Queuing Trade-off} = \\begin{cases} \n\\text{Shallow Buffers} &amp; \\rightarrow \\text{Drop packets early on bursts (Fail Fast)} \\\\ \n\\text{Deep Buffers} &amp; \\rightarrow \\text{Absorb bursts, but inject massive queuing delay (Bufferbloat)} \n\\end{cases}&quot;,&quot;id&quot;:&quot;DPTPVYKBNN&quot;}" data-component-name="LatexBlockToDOM"></div><ul><li><p><strong>Active Queue Management (CoDel / FQ-CoDel):</strong> Modern Linux queueing disciplines measure <strong>sojourn time</strong> (the actual time a packet spends sitting in queue) rather than raw byte counts. By default, CoDel drops or marks packets if sojourn time exceeds a 5 ms target over a 100 ms sliding window, keeping queues short without penalizing transient bursts.</p></li></ul><h3>6. Compression: The CPU vs. Wire Trade-Off</h3><ul><li><p><strong>Bandwidth-Bound Transfers:</strong> Compressing large JSON payloads or bulk database dumps (using Zstandard or Gzip) significantly improves throughput by reducing raw bytes over the wire.</p></li><li><p><strong>Latency-Bound Micro-RPCs:</strong> Running CPU compression on a small 128-byte payload introduces serialization overhead and context switching delays without providing meaningful payload reduction on the wire.</p></li></ul><h3>7. TCP vs. UDP vs. QUIC</h3><p>Every protocol purchase buys you out of one failure mode while buying into another:</p><ul><li><p><strong>TCP:</strong> Buys reliable, ordered byte delivery; pays for it with transport-level Head-of-Line blocking and handshake latency.</p></li><li><p><strong>UDP:</strong> Buys zero-handshake delivery and zero head-of-line stalls; pays for it by pushing packet reordering, loss handling, and congestion control entirely to the application layer (essential for real-time voice, video, and gaming).</p></li><li><p><strong>QUIC (HTTP/3):</strong> Runs over UDP to eliminate TCP-level HOL blocking by isolating streams within a single connection; pays for it with higher user-space CPU utilization during packet processing.</p></li></ul><h1>The Incident Walkthrough: 8-Minute Rehearsal Script</h1><p><strong>Scenario:</strong> The monitoring dashboard shows a 100G network interface card carrying only ~1 Gbps of traffic, but client requests are aggressively timing out.</p><p>Triage this step-by-step from latency physics to kernel state.</p><h3>Step 1: Identify the Clock That Actually Expired</h3><p>Do not assume the client has a standard timeout budget just because edge NGINX defaults to <code>proxy_read_timeout 60s</code>.</p><ul><li><p><strong>Ask immediately:</strong> <em>Which clock fired?</em> Is it a <strong>Connect Timeout</strong> (TCP 3-way handshake failure), a <strong>Request Deadline</strong> (end-to-end transaction budget), an <strong>Idle Read Timeout</strong> (gap between received chunks), or an <strong>Edge Proxy Timeout</strong> (e.g., 504 Gateway Timeout)?</p></li><li><p><strong>Check for missing budgets:</strong> If no explicit read timeout was set, default client socket libraries (such as <code>java.net.Socket</code>) block forever, while dropped stateful firewall sessions linger for up to <strong>20 minutes</strong> under Linux defaults (<code>tcp_retries2 = 15</code>) before failing.</p></li></ul><h3>Step 2: Calculate the Serial Round-Trip Floor</h3><p>Count the serial downstream RPC hops required to fulfill a single user transaction.</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;T_{\\text{network\\_floor}} = \\sum_{i=1}^{N} \\text{RTT}_i&quot;,&quot;id&quot;:&quot;LYBPFYYHQQ&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><ul><li><p><strong>Cloud latency baselines:</strong></p><ul><li><p><strong>Intra-AZ:</strong> Sub-millisecond (100 to 300 &#956;s)</p></li><li><p><strong>Cross-AZ:</strong> ~1 to 2 ms</p></li><li><p><strong>Cross-Region:</strong> Tens to hundreds of ms (e.g., US-East to EU-West is ~70 to 80 ms)</p></li></ul></li><li><p><strong>The Math:</strong> If a service makes 15 serial cross-region RPCs (<span>15 x 70 ms} = 1,050 ms</span>), a 500 ms client SLA is physically impossible. The 100G NIC bandwidth is completely irrelevant when bounded by fiber propagation delay.</p></li></ul><h3>Step 3: Compare In-Flight Window to Bandwidth-Delay Product</h3><p>Evaluate whether the application can physically saturate the available bandwidth over the measured RTT.</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{BDP} = \\text{Bandwidth} \\times \\text{RTT}&quot;,&quot;id&quot;:&quot;UOJNDQTBQB&quot;}" data-component-name="LatexBlockToDOM"></div><ul><li><p>On a 100 Gbps WAN link with a 100 ms RTT, the <strong>Bandwidth-Delay Product is 1.25 GB</strong>.</p></li><li><p>If TCP Window Scaling is disabled or stripped by a middlebox, the window caps at <strong>64 KB</strong>, capping single-stream throughput at <strong>~5.2 Mbps</strong>:</p></li></ul><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Throughput}_{\\text{max}} \\approx \\frac{64\\text{ KB}}{100\\text{ ms}} \\approx 5.24\\text{ Mbps}&quot;,&quot;id&quot;:&quot;PKOQAHYQHK&quot;}" data-component-name="LatexBlockToDOM"></div><ul><li><p>The pipe sits 99% empty because the transport layer was never configured to fill it.</p></li></ul><h3>Step 4: Inspect Loss, Jitter, and Tail Dispersion (p99 vs. p50)</h3><p>Look at the distribution of latency rather than dashboard averages.</p><ul><li><p><strong>The Symptom:</strong> If median latency (p50) is healthy (e.g., 12 ms) while p99 latency hits the exact client timeout threshold (e.g., 2,000 ms), the root cause is <strong>jitter, Head-of-Line (HOL) blocking, or Retransmission Timeouts (RTO)</strong>, not aggregate link saturation.</p></li><li><p><strong>The Cause:</strong> Packet loss triggers TCP fast retransmits or RTO backoffs, forcing receiver buffers to stall while waiting for in-order delivery.</p></li></ul><h3>Step 5: Evaluate Packet Rate and Interrupt Load</h3><p>Check whether the host is packet-per-second (PPS) bound rather than bit-bandwidth bound.</p><ul><li><p><strong>1 Gbps of 64-byte minimum frames</strong> generates <strong>~1,488,000 packets per second</strong>.</p></li><li><p><strong>1 Gbps of standard 1500-byte MTU frames</strong> generates <strong>~81,000 packets per second</strong>.</p></li><li><p>If host CPU shows <code>ksoftirqd</code> or <code>softirq</code> pinned at 100%, the machine is CPU-bound on packet interrupts. Bandwidth utilization looks deceptively low at 1% while the network processing pipeline is completely saturated.</p></li></ul><h3>Step 6: Verify Non-Network System Bottlenecks</h3><p>Confirm whether the stall is truly in the network layer or hidden in application runtime state:</p><ul><li><p>Full thread pools with worker threads blocking on database locks.</p></li><li><p>JVM/Go Stop-the-World Garbage Collection pauses.</p></li><li><p>Listen backlog (accept queue) overflow where the OS accepts SYNs, but the blocked application fails to call <code>accept()</code>.</p></li></ul><h3>The Inevitable Follow-Up: &#8220;Why not just increase the timeout?&#8221;</h3><blockquote><p><strong>The Response:</strong> &#8220;Increasing the timeout blindly is an anti-pattern. If the downstream dependency is dead, locked, or running a 20-minute silent TCP retry loop, raising the timeout only forces upstream worker threads to hang longer, tying up file descriptors and exhausting the thread pool.</p><p>If we must widen the timeout to accommodate legitimate tail jitter, we must simultaneously attach a <strong>strict per-client retry budget (capped at ~10%)</strong> and <strong>exponential backoff with randomized jitter</strong>. Otherwise, tail timeouts will trigger lockstep client retry storms that amplify traffic by <span>3x </span>and permanently prevent degraded downstream services from recovering.&#8221;</p></blockquote><h2>Sources</h2><h3>Books (System Design Playbook notebook)</h3><ul><li><p><em>High Performance Browser Networking</em> &#8212; ch 1 latency components, fiber Table 1-1, last-mile, bufferbloat/CoDel; ch 2 BDP, window scaling, HOL/jitter, fast retransmit, loss as congestion signal, &#8220;latency not bandwidth&#8221;; ch 3 UDP; ch 11 keepalive</p></li><li><p><em>Designing Data-Intensive Applications</em> &#8212; ch 1 latency vs response time, response-time distribution; ch 8 queueing, packet switching vs static partition, UDP, many-to-one switch queues</p></li><li><p><em>Site Reliability Engineering</em> &#8212; ch 4 histograms / tail vs average; ch 21 retry budget (~10%, ~3&#215; vs ~1.1&#215;); RPC deadlines and cancellation; cost of low-latency vs throughput clusters</p></li><li><p><em>Release It!</em> &#8212; ch 4 listen queue, default-forever reads, firewall idle drop, <code>tcp_retries2</code> ~20 min, chatty WAN, Slow Responses; ch 5 finite queues; ch 6/4 hung pools at 0% CPU; ch 9 residence time</p></li><li><p><em>System Design Handbook</em> &#8212; throughput as rate work completes</p></li></ul><h3>Web</h3><ul><li><p><a href="https://hpbn.co/primer-on-latency-and-bandwidth/">https://hpbn.co/primer-on-latency-and-bandwidth/</a></p></li><li><p><a href="https://datatracker.ietf.org/doc/html/rfc7323">https://datatracker.ietf.org/doc/html/rfc7323</a></p></li><li><p><a href="https://aws.amazon.com/blogs/architecture/improving-performance-and-reducing-cost-using-availability-zone-affinity/">https://aws.amazon.com/blogs/architecture/improving-performance-and-reducing-cost-using-availability-zone-affinity/</a></p></li><li><p><a href="https://nginx.org/en/docs/http/ngx_http_proxy_module.html">https://nginx.org/en/docs/http/ngx_http_proxy_module.html</a></p></li><li><p><a href="https://everything.curl.dev/usingcurl/timeouts.html">https://everything.curl.dev/usingcurl/timeouts.html</a></p></li><li><p><a href="https://slac.stanford.edu/comp/net/wan-mon/thru-vs-loss.html">https://slac.stanford.edu/comp/net/wan-mon/thru-vs-loss.html</a></p></li><li><p><a href="https://queue.acm.org/detail.cfm?id=2209336">https://queue.acm.org/detail.cfm?id=2209336</a></p></li><li><p><a href="https://datatracker.ietf.org/doc/html/rfc8289">https://datatracker.ietf.org/doc/html/rfc8289</a></p></li><li><p><a href="https://datatracker.ietf.org/doc/html/rfc8290">https://datatracker.ietf.org/doc/html/rfc8290</a></p></li><li><p><a href="https://man7.org/linux/man-pages/man8/tc-fq_codel.8.html">https://man7.org/linux/man-pages/man8/tc-fq_codel.8.html</a></p></li><li><p><a href="https://sec.cloudapps.cisco.com/security/center/resources/network_performance_metrics.html">https://sec.cloudapps.cisco.com/security/center/resources/network_performance_metrics.html</a></p></li><li><p><a href="https://supportportal.juniper.net/s/article/How-many-Packets-per-Second-per-port-are-needed-to-achieve-Wire-Speed">https://supportportal.juniper.net/s/article/How-many-Packets-per-Second-per-port-are-needed-to-achieve-Wire-Speed</a></p></li><li><p><a href="https://www.geeksforgeeks.org/computer-networks/difference-between-bandwidth-and-throughput/">https://www.geeksforgeeks.org/computer-networks/difference-between-bandwidth-and-throughput/</a></p></li><li><p><a href="https://www.geeksforgeeks.org/computer-networks/latency-vs-jitter-in-computer-networks/">https://www.geeksforgeeks.org/computer-networks/latency-vs-jitter-in-computer-networks/</a></p></li></ul><h3></h3>]]></content:encoded></item><item><title><![CDATA[Forward vs Reverse vs Transparent Proxies]]></title><description><![CDATA[Nginx is a reverse proxy. HAProxy is a load balancer. Both statements are half true, and the half that is missing is the one interviewers ask about.]]></description><link>https://saifhatem.substack.com/p/forward-vs-reverse-vs-transparent</link><guid isPermaLink="false">https://saifhatem.substack.com/p/forward-vs-reverse-vs-transparent</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Tue, 25 Aug 2026 20:38:17 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!ry4p!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1>One Word, Three Different Jobs</h1><p>A proxy is fundamentally simple: it terminates a client connection and opens a separate connection of its own. That connection boundary is the architectural magic that makes <strong>caching, authentication, request retries, and header rewrites possible</strong>. For instance, Google Front Ends (GFEs) act as reverse proxies precisely to terminate incoming TCP connections at the network edge.</p><p>What separates forward, reverse, and transparent proxies is not the direction bytes travel across the wire. <strong>It is whose agent the proxy is, and who actually knows it is there.</strong></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading The Blueprint Dynasty! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h3>1. Forward Proxy: The Client&#8217;s Agent on the Way Out</h3><p>A forward proxy sits in front of clients on the local network and intercepts outgoing requests.</p><p>To the external internet, the forward proxy is the client. It is configured directly inside the client application or network settings. Corporations and universities use forward proxies to enforce content filtering, log employee web traffic, or cache frequently accessed static assets before they hit the public WAN.</p><h3>2. Reverse Proxy: The Server&#8217;s Shield at the Origin</h3><p>A reverse proxy sits in front of backend servers and intercepts incoming traffic from the public internet.</p><p>To the external client, the reverse proxy appears to be the actual origin server. The client has no idea backend worker nodes even exist. Reverse proxies handle load balancing, SSL termination, web application firewall (WAF) filtering, and global content caching, protecting raw infrastructure from direct exposure.</p><h3>3. Transparent Proxy: The Interceptor Without Client Configuration</h3><p>A transparent proxy intercepts network traffic without requiring any manual setup on the client device.</p><p>To understand how it works, look at how traffic flows compared to a normal proxy:</p><ul><li><p><strong>Explicit Proxy:</strong> Your application or operating system settings are configured intentionally to talk to an intermediary. The client addresses the proxy directly (e.g., <code>proxy.corp.internal:8080</code>).</p></li><li><p><strong>Transparent (Inline) Proxy:</strong> The client has zero proxy settings configured and believes it is talking directly to the destination server (like <code>google.com</code>). However, the proxy sits directly inside the physical or logical network path between the client and the internet. The network router or default gateway intercepts the packets mid-flight and forcibly routes them through the proxy before letting them leave the network.</p></li></ul><p>To the client operating system, the connection appears direct. It has no idea an intermediary intercepted the traffic on the wire.</p><blockquote><p><strong>The Transparency Misconception:</strong> Never teach that &#8220;transparent means it does not hide your IP.&#8221; That is completely backwards. Transparent simply means nobody asked the client for permission or configuration. If the intercepting gateway is equipped with an internal trusted root CA certificate, it can easily rewrite headers, mask client IP addresses, and decrypt TLS traffic on the fly.</p></blockquote><p>Transparent deployment is simply a routing technique at the network gateway layer, not a fundamentally different species of proxy software.</p><h3>Proxy Types: The Definitions</h3><p>&#8220;Forward&#8221; and &#8220;reverse&#8221; name the agent, not a distinct physical topology. Whether traffic flows inbound or outbound, both variants sit in the middle of the TCP connection, terminating the socket and establishing their own.</p><p>What separates them is simply <strong>whose agent it is</strong> and <strong>how traffic reaches it</strong>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!EWb_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!EWb_!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!EWb_!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!EWb_!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!EWb_!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!EWb_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:814309,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/212668110?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!EWb_!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!EWb_!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!EWb_!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!EWb_!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2779d000-273f-4452-b65d-d4d86091a37e_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Key Architectural Clarifications</h3><ul><li><p><strong>Agent Split vs. Packet Direction:</strong> A forward proxy acts on behalf of the client to shield, monitor, or accelerate outbound requests. A reverse proxy acts on behalf of the server to shield, load-balance, or cache inbound traffic.</p></li><li><p><strong>The &#8220;Configuration&#8221; Fallacy:</strong> Common interview guides often claim that <em>&#8220;clients must always manually configure a forward proxy.&#8221;</em> This is only true for <strong>explicit forward proxies</strong>. Transparent forward proxies exist, intercepting outbound traffic at the network router level without any client-side configuration.</p></li></ul><h3>Neighbors People Mix This Up With</h3><p>The networking world is full of intermediary components, and engineers frequently blur the boundaries between them.</p><p>To keep your architectural terminology clean, use one foundational mental model: <strong>a true proxy terminates the application-layer connection and opens an entirely new one as an agent.</strong></p><p>If a device or software layer does not terminate the connection to act as an agent, it is not a proxy.</p><h3>The Non-Proxies: NAT and VPNs</h3><ul><li><p><strong>Network Address Translation (NAT):</strong> A NAT router merely rewrites the source or destination IP addresses and ports inside the packet headers at the network/transport layer. It does not terminate the TCP socket, and it does not understand application protocols like HTTP.</p></li><li><p><strong>Virtual Private Networks (VPNs):</strong> A VPN encrypts and encapsulates raw network packets inside an encrypted tunnel. It passes bytes across a virtual network interface without parsing, inspecting, or terminating application-level streams.</p></li></ul><blockquote><p><strong>The Architectural Litmus Test:</strong> Ask yourself: <em>Did an intermediary terminate the TCP socket and open a brand new connection on my behalf?</em> If no, you are looking at NAT, routing, or packet tunneling, not a proxy.</p></blockquote><h3>The Proxy Family Tree: Variations on the Same Pattern</h3><p>Most advanced infrastructure components are simply specialized reverse or forward proxies adapted for a specific operational role:</p><ul><li><p><strong>Software Load Balancer (Reverse Proxy):</strong> Tools like NGINX, HAProxy, Envoy, and Squid terminate incoming client traffic and distribute the workload across backend worker pools.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Y11c!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c98c387-7e47-4b4c-896a-b1b522306d01_1200x481.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Y11c!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c98c387-7e47-4b4c-896a-b1b522306d01_1200x481.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!Y11c!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c98c387-7e47-4b4c-896a-b1b522306d01_1200x481.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!Y11c!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c98c387-7e47-4b4c-896a-b1b522306d01_1200x481.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!Y11c!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c98c387-7e47-4b4c-896a-b1b522306d01_1200x481.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Y11c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c98c387-7e47-4b4c-896a-b1b522306d01_1200x481.jpeg" width="424" height="169.95333333333335" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3c98c387-7e47-4b4c-896a-b1b522306d01_1200x481.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:481,&quot;width&quot;:1200,&quot;resizeWidth&quot;:424,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;What is Nginx?. In this article, we're learning about&#8230; | by Kasun  Dissanayake | Geek Culture | Medium&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="What is Nginx?. In this article, we're learning about&#8230; | by Kasun  Dissanayake | Geek Culture | Medium" title="What is Nginx?. In this article, we're learning about&#8230; | by Kasun  Dissanayake | Geek Culture | Medium" srcset="/__u/substackcdn.com/image/fetch/$s_!Y11c!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c98c387-7e47-4b4c-896a-b1b522306d01_1200x481.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!Y11c!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c98c387-7e47-4b4c-896a-b1b522306d01_1200x481.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!Y11c!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c98c387-7e47-4b4c-896a-b1b522306d01_1200x481.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!Y11c!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c98c387-7e47-4b4c-896a-b1b522306d01_1200x481.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption"></figcaption></figure></div></li><li><p><strong>Hardware Load Balancer (L4-L7 Appliance):</strong> Dedicated physical or virtual appliances (such as F5 BIG-IP) optimized with specialized ASICs to handle massive connection volumes, SSL offloading, and traffic shaping at wire speed.</p></li><li><p><strong>API Gateway (Reverse Proxy + Business Logic):</strong> An API gateway is an application-aware reverse proxy layered with cross-cutting concerns: OAuth token verification, rate limiting, request quotas, schema validation, and protocol translation (e.g., gRPC-Web to JSON).</p></li><li><p><strong>Content Delivery Network (CDN):</strong> A CDN (like Cloudflare, CloudFront, or Akamai) is logically equivalent to a massive, geographically distributed fleet of caching reverse proxies placed at the network edge to serve static and dynamic content close to the end user.</p></li><li><p><strong>Service Mesh Sidecar (Dual-Role Proxy):</strong> An Envoy or Linkerd sidecar container deployed alongside an application container plays both roles simultaneously:</p><ul><li><p><strong>Inbound Traffic:</strong> Acts as a <strong>reverse proxy</strong> to intercept, authenticate (via mTLS), and observe incoming traffic before handing it to the local container.</p></li><li><p><strong>Outbound Traffic:</strong> Acts as a <strong>forward proxy</strong> to intercept egress requests from the local container, route them across the mesh, and handle automatic retries or circuit breaking.</p></li></ul></li></ul><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ry4p!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ry4p!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!ry4p!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!ry4p!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!ry4p!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ry4p!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:777670,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/212668110?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!ry4p!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!ry4p!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!ry4p!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!ry4p!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dcd3099-1f52-4629-9f2e-71f35b67abbf_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="callout-block" data-callout="true"><p><strong>You have covered the fundamentals of this topic, the next part is advanced stuff, derived from staff SW engineers at FAANG(Google ETC). Proceed with mental caution.<br><br>See sources at the end if you are curious.</strong></p></div><p></p><h1>Under the Hood: How Proxies Work on the Wire</h1><p>To debug proxy issues in production or defend an architecture in a staff-level interview, you have to understand the exact mechanics happening on the wire.</p><h3>1. Forward Proxy Mechanics: Explicit Opt-In and <code>CONNECT</code></h3><p>A forward proxy requires the client to explicitly route traffic through it via environment variables (<code>HTTP_PROXY</code>, <code>HTTPS_PROXY</code>, <code>NO_PROXY</code>), browser configurations, or a PAC (Proxy Auto-Configuration) file via WPAD, short for Web Proxy Auto-Discovery Protocol.</p><ul><li><p><strong>Plaintext HTTP:</strong> The client sends an absolute URL in the request line (<code>GET [http://api.example.com/v1/users](http://api.example.com/v1/users) HTTP/1.1</code>). The proxy reads the host header/URL, opens a socket to the origin, and relays the payload.</p></li><li><p><strong>Encrypted HTTPS (The </strong><code>CONNECT</code><strong> Tunnel):</strong> For TLS traffic, the client issues an HTTP <code>CONNECT</code> method:</p></li></ul><p>Plaintext</p><pre><code><code>CONNECT api.example.com:443 HTTP/1.1
Host: api.example.com:443
</code></code></pre><p>Once the proxy returns an <code>HTTP 200 Connection Established</code>, it drops down to a <strong>blind, bidirectional TCP byte tunnel</strong>. It does not parse HTTP, inspect headers, or see payloads.</p><blockquote><p><strong>What a Standard Forward Proxy Logs:</strong> Without an active TLS-terminating Man-in-the-Middle (MITM) setup, an outbound logging proxy only sees the destination <code>host:port</code>, the TLS Server Name Indication (SNI), peer certificates, byte transfer counts, and connection timing. It <strong>cannot</strong> see request paths, query parameters, headers, or bodies.</p><p><strong>The Port 25/22 Pivot Hazard:</strong> An improperly configured forward proxy that allows open <code>CONNECT</code> methods to arbitrary ports (like port 25 for SMTP or port 22 for SSH) instantly turns your corporate network into an open spam relay or botnet pivot point. Production forward proxies must restrict <code>CONNECT</code> targets strictly to port 443.</p></blockquote><h3>2. Reverse Proxy Mechanics: DNS Ingress &amp; Identity Forwarding</h3><p>With a reverse proxy, the client resolves the service&#8217;s public domain name and receives the Virtual IP (VIP) of the reverse proxy tier. The client believes it is talking directly to the origin.</p><h4>The Three TLS Termination Postures</h4><ul><li><p><strong>Edge Termination:</strong> The proxy decrypts TLS at the edge using its certificates, then routes clear plaintext traffic to upstream services over private VPC networks. This offloads CPU-heavy crypto operations from application instances. What NGINIX uses by default.</p></li><li><p><strong>TLS Bridging:</strong> The proxy decrypts incoming TLS at the edge (allowing WAF inspection, caching, and header rewriting), then initiates a brand-new TLS handshake to re-encrypt traffic before sending it upstream.</p></li><li><p><strong>TLS Passthrough (Layer 4):</strong> The proxy inspects only TCP/SNI metadata and forwards the encrypted stream straight to the origin without ever holding or seeing the private keys.</p></li></ul><h4>Preserving Client Identity Across Hops</h4><p>Because the upstream application server only sees the TCP connection originating from the reverse proxy&#8217;s private IP, client identity must be passed explicitly:</p><ul><li><p><strong>APPLICATION: Layer 7 (HTTP):</strong> Handled via <code>X-Forwarded-For: &lt;client&gt;, &lt;proxy1&gt;</code> or standard <code>Forwarded: for=&lt;client&gt;;proto=https;by=&lt;proxy&gt;</code> headers.</p></li><li><p><strong>TRANSPORT: Layer 4 (Raw TCP / Non-HTTP):</strong> Handled via the <strong>PROXY Protocol</strong>. The proxy prepends a small, standardized human-readable or binary header (containing source IP, dest IP, and ports) to the very first bytes of the incoming TCP socket before passing application data.</p></li></ul><h3>3. Transparent Proxy Mechanics: Intercepting Without Opt-In</h3><p>A transparent proxy relies entirely on network-layer routing (such as Linux <code>iptables REDIRECT</code>, <code>TPROXY</code>, policy routing, or Cisco WCCP) to snatch packets mid-flight.</p><ul><li><p><strong>Redirect vs. TPROXY:</strong> <code>REDIRECT</code> uses target NAT to rewrite the destination IP to the local proxy socket (which loses original destination metadata for UDP, because its fire and forget protocol). <code>TPROXY</code> intercepts packets without rewriting destination IPs, requiring the proxy application to open sockets with the <code>IP_TRANSPARENT</code> flag enabled.</p></li><li><p><strong>The Asymmetric Routing Trap:</strong> Both the request and the response packets must flow through the exact same transparent proxy appliance. If response packets bypass the proxy and travel directly back to the client via an alternate gateway (asymmetric return), the client drops the packets because the source IP does not match the initial socket.</p></li><li><p><strong>TLS Inspection and Pinning:</strong> For a proxy to secretly read your encrypted HTTPS traffic, it has to create fake certificates on the spot. These fake certificates are signed by the company&#8217;s own private signing authority, which they previously installed on your device so that your device would automatically trust anything they sign.</p><p></p><p>However, if a mobile app uses <strong>SSL Certificate Pinning</strong> (meaning the app has a hard-coded copy of the real server&#8217;s certificate fingerprint), that app completely ignores your device&#8217;s trusted list. When the proxy presents its fake certificate, the app instantly recognizes it as a forgery and kills the connection. As a result, the mobile app fails to work at all, while websites in your regular browser continue to work perfectly fine.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!9S0q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!9S0q!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!9S0q!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!9S0q!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!9S0q!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!9S0q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:730011,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/212668110?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!9S0q!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!9S0q!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!9S0q!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!9S0q!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75bae71e-d4d7-4d1d-b2f7-73b2a861260c_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h1>Layer 4 vs. Layer 7: Same Binary, Different Modes</h1><p>The distinction between Layer 4 (L4) and Layer 7 (L7) applies across all proxy implementations:</p><ul><li><p><strong>Layer 4 (Transport Layer):</strong> Operates on IP addresses and TCP/UDP ports. It is blazing fast, consumes minimal memory, is completely protocol-agnostic, and enables TLS passthrough. However, it cannot inspect URLs, route by headers, balance based on HTTP paths, or cache payloads.</p></li><li><p><strong>Layer 7 (Application Layer):</strong> Understands high-level protocols (HTTP, gRPC, WebSocket). It can terminate TLS, rewrite headers, enforce rate limits per API route, execute intelligent retries, and cache responses, but incurs higher CPU and memory overhead per connection.</p></li></ul><h1>NGINX vs. HAProxy vs. Envoy: The Tooling Matrix</h1><p>Engineers frequently confuse these tools because their capabilities overlap. However, they are built around fundamentally different operational philosophies:</p><h1>NGINX vs. HAProxy vs. Envoy: Same Family, Different Instincts</h1><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!6EEP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!6EEP!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png 424w, /__u/substackcdn.com/image/fetch/$s_!6EEP!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png 848w, /__u/substackcdn.com/image/fetch/$s_!6EEP!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png 1272w, /__u/substackcdn.com/image/fetch/$s_!6EEP!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!6EEP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png" width="487" height="112" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:112,&quot;width&quot;:487,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:71800,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/212668110?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!6EEP!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png 424w, /__u/substackcdn.com/image/fetch/$s_!6EEP!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png 848w, /__u/substackcdn.com/image/fetch/$s_!6EEP!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png 1272w, /__u/substackcdn.com/image/fetch/$s_!6EEP!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51d618b8-dbc3-4317-80e2-256cf98b55d8_487x112.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>All three tools belong to the exact same architectural family: <strong>they are all reverse proxies</strong>.</p><p>Load balancing is simply one feature they can perform, but not every reverse proxy actually balances traffic (a reverse proxy in front of a single monolith still provides caching, rate limiting, and TLS termination without balancing a single request).</p><p>Do not fall into the trap of thinking these are fundamentally different species. Instead, understand their specific design trade-offs and operational instincts.</p><h3>1. NGINX: The Web Server and Ingress Layer</h3><p>NGINX was built from the ground up to serve static content from disk efficiently while acting as a reverse proxy.</p><ul><li><p><strong>The Core Distinction:</strong> NGINX is a true origin web server. It can read HTML, images, and static assets directly from the filesystem and serve them to clients. HAProxy cannot do this.</p></li><li><p><strong>Configuration Model:</strong> Built around static configuration files. Applying route changes, SSL certificate updates, or new upstreams historically requires a configuration reload (<code>nginx -s reload</code>).</p></li><li><p><strong>Where It Shines:</strong> Public-facing edge ingress, single-tier reverse proxying, API gateway routing, and serving static assets from local storage.</p></li><li><p><strong>The Weak Spot:</strong> Highly dynamic backends require workarounds, Lua scripting, or commercial add-ons (NGINX Plus) to adjust upstreams on the fly without process reloads.</p></li></ul><h3>2. HAProxy: The High-Throughput Traffic Specialist</h3><p>HAProxy was engineered specifically for extreme connection throughput, intelligent queueing, and advanced traffic admission control.</p><ul><li><p><strong>The Core Distinction:</strong> HAProxy is strictly a proxy and load balancer. It does not serve static files from disk or act as an origin web server.</p></li><li><p><strong>Runtime Control:</strong> Features a dedicated Runtime Unix Socket API. This allows operators to drain backends, adjust server weights, modify stickiness tables, and disable failing nodes dynamically in real time without reloading the configuration file or dropping active TCP sockets.</p></li><li><p><strong>Where It Shines:</strong> Dedicated Layer 4 and Layer 7 load-balancing tiers in front of large application pools, handling raw TCP traffic, session stickiness, and aggressive admission control under heavy load.</p></li></ul><h3>3. Envoy: The Dynamic Cloud-Native Data Plane</h3><p>Envoy was designed for high-scale microservices, service mesh architectures, and dynamic container environments.</p><ul><li><p><strong>The Core Distinction:</strong> Envoy is a programmable data plane built to be configured dynamically via the Discovery Service API (<code>xDS</code>) by an external control plane (like Istio or AWS ECS Service Connect).</p></li><li><p><strong>Configuration Model:</strong> You do not manage Envoy by manually writing giant static YAML files and reloading processes. It streams its routing tables, cluster members, and TLS certs dynamically over gRPC without dropping a single active connection.</p></li><li><p><strong>Where It Shines:</strong> Service-to-service communication (East-West traffic), microservice sidecar proxies, and cloud-native mesh policies.</p></li><li><p><strong>The Weak Spot:</strong> High operational complexity. Deploying Envoy without an automated control plane to drive xDS creates unnecessary configuration overhead.</p></li></ul><h3>When They Are Interchangeable</h3><p>If your architecture only requires a single ingress tier to terminate incoming TLS and round-robin traffic across a fixed pool of upstream application servers, <strong>all three are largely interchangeable</strong>. Pick whichever tool your infrastructure team already knows how to operate, monitor, and scale.</p><h3>When the Choice Actually Matters</h3><p>Make your decision based on the specific operational boundary of your workload:</p><ul><li><p><strong>Pick NGINX</strong> if you need to serve static assets directly from disk, handle edge caching, or run a simple single-tier ingress for your web applications.</p></li><li><p><strong>Pick HAProxy</strong> if you need massive raw TCP throughput, serious Layer 4 performance, complex queue management, or the ability to drain and manage backends dynamically via runtime APIs.</p></li><li><p><strong>Pick Envoy</strong> if your upstream topology changes every few seconds (Kubernetes pods scaling dynamically), or if you are enforcing service mesh security policies, distributed tracing, and advanced mTLS between microservices.</p></li></ul><blockquote><p><strong>The Architectural Rule:</strong> Do not categorize HAProxy as a "load balancer" and NGINX as a "reverse proxy" as if they are different species. Both are reverse proxies. Pick <strong>NGINX</strong> if you need edge web serving and static caching; pick <strong>HAProxy</strong> for raw TCP throughput, complex queue admission, and runtime socket draining; pick <strong>Envoy</strong> for dynamic microservice topologies and service mesh deployments.</p></blockquote><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!7O9h!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!7O9h!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!7O9h!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!7O9h!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!7O9h!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!7O9h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:895655,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/212668110?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!7O9h!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!7O9h!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!7O9h!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!7O9h!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b3eda44-f59f-4cdf-991d-08f23c930a1d_2752x1536.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h1>System Capacity Physics: The Cost of an Extra Hop</h1><p>Adding a proxy tier introduces operational trade-offs governed by connection physics and operating system limits:</p><ul><li><p><strong>Latency Overhead:</strong> An intra-AZ(Availability zone, AWS) Envoy sidecar hop adds approximately 300 to 400 microseconds. Cross-AZ hops jump to 1.5 milliseconds or more. Cross-region routing adds tens to hundreds of milliseconds.</p></li><li><p><strong>Little&#8217;s Law and Upstream Connection Pools:</strong> The number of concurrent sockets required between your proxy and upstream backends is governed by Little&#8217;s Law:</p></li></ul><p><span>Plaintext</span></p><pre><code><code>L = lambda x W
</code></code></pre><p><em>(Where L = concurrent open connections, <span>lambda</span> = arrival rate in RPS, and W = mean backend response duration).</em></p><p>If an upstream database or API slows down under load, response duration (<span>W</span>) increases. To maintain throughput, the proxy must consume more sockets (<span>L</span>) precisely when the cluster is least capable of handling them. Sizing long-lived upstream connection pools prevents ephemeral connection exhaustion.</p><ul><li><p><strong>Operating System Ceilings:</strong> High-concurrency proxies consume file descriptors and kernel socket buffers. Sockets closed by clients linger in the kernel <code>TIME_WAIT</code> state for up to 60 seconds. A single source-to-destination IP pair has a default ephemeral port range of roughly 28,000 ports (<code>ip_local_port_range</code>), meaning high connection turnover can exhaust available local ports rapidly if keepalive pools are not configured.</p></li></ul><h1>Critical Failure Modes &amp; Edge Cases</h1><p>When you place a middleman in the critical request path, it introduces distinct failure states:</p><h3>1. HTTP Status Code Attribution</h3><ul><li><p><strong>502 Bad Gateway:</strong> The proxy received an invalid response, connection reset (RST), or TCP connection refusal from the upstream application server.</p></li><li><p><strong>503 Service Unavailable:</strong> The proxy itself is shedding load because its internal listen queues are full, health checks failed for all upstream instances, or CPU capacity is saturated.</p></li><li><p><strong>504 Gateway Timeout:</strong> The proxy successfully connected to the upstream, but the upstream failed to return a response before the proxy&#8217;s read timeout limit (e.g., NGINX <code>proxy_read_timeout</code> default of 60 seconds) expired.</p></li></ul><h3>2. The Asymmetric 504 Anomaly</h3><p>In a misconfigured system, a client might receive an HTTP <code>504 Gateway Timeout</code> even while backend application logs show a successful <code>HTTP 200 OK</code>.</p><p>This occurs when the backend completes the processing work, but takes longer than the proxy&#8217;s strict read timeout limit. The proxy terminates the client connection with a 504, while the backend application finishes the task unaware that the client has already disconnected.</p><p><strong>The Fix:</strong> Propagate explicit deadline budgets across headers down the entire call chain (<code>Client Timeout &gt; Edge Proxy Timeout &gt; Upstream Execution Timeout</code>).</p><blockquote><h2><strong>Why This Order?</strong></h2><p><strong>Client Timeout (10s):</strong> Longest in the chain because the user is the most important. If the client times out first, the user gets a vague browser error even if the server was still working. You want the server to fail first and return a meaningful error, not the client.</p><p><strong>Edge Proxy Timeout (8s):</strong> Must be shorter than the client so it times out <em>before</em> the client does. When the proxy times out, it returns a clear <strong>504 Gateway Timeout</strong> error to the client, which tells the user exactly what happened (the upstream was too slow). This is far better than the client timing out and giving a generic connection error.</p><p><strong>Upstream Service Timeout (6s):</strong> Must be the shortest so it fails first. If the service is taking too long, it should give up quickly, return an error to the proxy, and free up its resources (threads, connections, memory). This prevents cascading failures where slow services hold onto resources and bring down the entire system</p></blockquote><h3>3. Trust Boundary &amp; Security Vulnerabilities</h3><ul><li><p><code>X-Forwarded-For</code><strong> Spoofing:</strong> Never trust the leftmost IP in the <code>X-Forwarded-For</code> header for security or rate limiting unless your edge proxy explicitly strips or overrides it. An attacker can send <code>X-Forwarded-For: 127.0.0.1</code>, which will simply be appended to by downstream proxies. Always configure your application to evaluate IPs by counting backward from trusted internal proxy hops.</p><blockquote><h3>The <code>X-Forwarded-For</code> Spoofing Trap</h3><p>The <code>X-Forwarded-For</code> (XFF) header records the proxy chain as an incoming request travels toward your application:</p><p>Plaintext</p><pre><code><code>X-Forwarded-For: client, proxy1, proxy2
</code></code></pre><p>Each intermediate proxy simply appends the IP address it received the connection from onto the right end of the header.</p><h3>The Vulnerability: Leftmost IP is Untrusted</h3><p>Because <code>X-Forwarded-For</code> is just an HTTP header, <strong>an attacker can set it to whatever they want</strong> before sending the request.</p><ol><li><p><strong>Attacker (</strong><code>198.51.100.4</code><strong>) sends:</strong> <code>X-Forwarded-For: 127.0.0.1</code></p></li><li><p><strong>Your Edge Load Balancer (</strong><code>203.0.113.10</code><strong>) receives it and appends the sender:</strong></p><p>Plaintext</p></li></ol><pre><code><code>X-Forwarded-For: 127.0.0.1, 198.51.100.4
</code></code></pre><ol><li><p><strong>Your Internal Gateway (</strong><code>10.0.0.2</code><strong>) appends the load balancer:</strong></p><p>Plaintext</p></li></ol><pre><code><code>X-Forwarded-For: 127.0.0.1, 198.51.100.4, 203.0.113.10
</code></code></pre><p>If your application naively reads the <strong>leftmost IP</strong> (<code>127.0.0.1</code>) for authentication or rate limiting, the attacker successfully impersonates <code>localhost</code> and bypasses your security controls.</p><h3>The Solution: Walk Backward from the Right</h3><p>Never trust the header from left to right. Instead, start at the right (the newest, trusted entries) and count backward past the internal proxies you own:</p><p>Plaintext</p><pre><code><code>Header: [ 127.0.0.1 , 198.51.100.4 , 203.0.113.10 ]
          ^^^^^^^^^   ^^^^^^^^^^^^   ^^^^^^^^^^^^
          Forged IP   REAL CLIENT    Edge Proxy
          (Untrusted)   (Target)      (Trusted)
                            ^
                            |-- Walk 1 hop back from your trusted edge
</code></code></pre><h3>Production Rules</h3><ul><li><p><strong>Overwrite at the Edge:</strong> Configure your public edge proxy (Cloudflare, AWS ALB, NGINX) to <strong>replace/strip</strong> incoming XFF headers with the actual incoming socket IP (<code>$remote_addr</code>) instead of appending.</p></li><li><p><strong>Configure Trusted Proxies:</strong> In your application framework, set the explicit number of trusted proxy hops so it automatically resolves the client IP from the right side of the list.</p></li></ul></blockquote></li><li><p><strong>HTTP Request Smuggling:</strong> If a front-end reverse proxy and a back-end server disagree on where a request boundary ends (due to conflicting <code>Content-Length</code> vs <code>Transfer-Encoding</code> headers), an attacker can smuggle an unauthorized request inside another user&#8217;s connection. Always enforce strict HTTP normalization at the edge proxy tier.</p><blockquote><p><strong>HTTP normalization</strong> is the process of <strong>cleaning and standardizing</strong> incoming HTTP requests (like URLs, headers, and query parameters) into a consistent format.</p><p>It removes irregularities like duplicate slashes (<code>//</code>), resolves path traversal (<code>../</code>), decodes percent-encoded characters (<code>%20</code> &#8594; space), and handles case sensitivity.</p><p>This is done to <strong>prevent security bypasses</strong> (like attackers exploiting different interpretations of the same URL), improve <strong>caching efficiency</strong>, ensure consistent <strong>routing</strong>, and enforce <strong>rate limiting</strong> accurately.</p></blockquote></li><li><p><strong>Retry Storms:</strong> Unbounded client and proxy retries on upstream timeouts can amplify a <span>1</span> outage into a <span>3</span> to <span>5</span> traffic surge. Implement strict per-proxy retry budgets (capping retries at <span>10%</span> of normal traffic) and exponential backoff with jitter.</p></li></ul><h1>The Interview &amp; Production Decision Tree</h1><p>When justifying proxy architecture in an interview or design document, run through this mental checklist:</p><p><span>Plaintext</span></p><pre><code><code>1. Whose agent is it? (Client = Forward | Server = Reverse | Network = Transparent)
2. What layer? (L4 for raw wire speed &amp; passthrough | L7 for routing, auth &amp; cache)
3. Where does TLS terminate? (Edge termination vs. Bridge vs. Passthrough)
4. How is client identity carried? (X-Forwarded-For at L7 | PROXY Protocol at L4)
5. What is the fallback? (Connection pool sizing, timeout budgets, and retry caps)</code> </code></pre><p></p><h2>Sources</h2><h3>Books </h3><ul><li><p><em>Site Reliability Engineering</em> &#8212; GFE reverse proxy (ch 2); 502 (ch 17); pooling, FDs, regional proxies, subsetting (ch 20, 23); retry storms (ch 21); DSR/GRE</p></li><li><p><em>Release It!</em> ch 9 &#8212; software LB as reverse proxy; hardware LB; XFF; cache/Akamai; Little&#8217;s law; TIME_WAIT; 503</p></li><li><p><em>System Design Handbook</em> &#8212; Forward / Reverse / API Gateway; extra hop; TLS termination; SPOF; explicit client config</p></li><li><p><em>Designing Data-Intensive Applications</em> &#8212; nginx as origin (ch 10); routing tier vs client-to-any-node (ch 6)</p></li><li><p><em>System Design Interview</em> &#8212; DNS to LB VIP; private IPs behind the balancer</p></li></ul><h3>Web</h3><ul><li><p><a href="https://httpwg.org/specs/rfc9110.html#CONNECT">https://httpwg.org/specs/rfc9110.html#CONNECT</a></p></li><li><p><a href="https://www.rfc-editor.org/rfc/rfc7239.html">https://www.rfc-editor.org/rfc/rfc7239.html</a></p></li><li><p><a href="https://www.haproxy.com/blog/use-the-proxy-protocol-to-preserve-a-clients-ip-address">https://www.haproxy.com/blog/use-the-proxy-protocol-to-preserve-a-clients-ip-address</a></p></li><li><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-For">https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-For</a></p></li><li><p><a href="https://docs.kernel.org/6.5/networking/tproxy.html">https://docs.kernel.org/6.5/networking/tproxy.html</a></p></li><li><p><a href="https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt">https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt</a></p></li><li><p><a href="https://nginx.org/en/docs/http/ngx_http_proxy_module.html">https://nginx.org/en/docs/http/ngx_http_proxy_module.html</a></p></li><li><p><a href="https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/operations/dynamic_configuration">https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/operations/dynamic_configuration</a></p></li><li><p><a href="https://aws.amazon.com/blogs/containers/announcing-zone-aware-routing-in-amazon-ecs-service-connect/">https://aws.amazon.com/blogs/containers/announcing-zone-aware-routing-in-amazon-ecs-service-connect/</a></p></li><li><p><a href="https://www.geeksforgeeks.org/system-design/difference-between-forward-proxy-and-reverse-proxy/">https://www.geeksforgeeks.org/system-design/difference-between-forward-proxy-and-reverse-proxy/</a></p></li><li><p><a href="https://guptadeepak.com/guides/choose-a-reverse-proxy/">https://guptadeepak.com/guides/choose-a-reverse-proxy/</a></p></li><li><p><a href="https://kindatechnical.com/system-design-interview/reverse-proxies-nginx-haproxy-and-envoy.html">https://kindatechnical.com/system-design-interview/reverse-proxies-nginx-haproxy-and-envoy.html</a></p></li><li><p><a href="https://www.netdata.cloud/guides/nginx/nginx-504-gateway-timeout/">https://www.netdata.cloud/guides/nginx/nginx-504-gateway-timeout/</a></p></li><li><p><a href="https://www.systemshardening.com/articles/network/request-smuggling-prevention/">https://www.systemshardening.com/articles/network/request-smuggling-prevention/</a></p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading The Blueprint Dynasty! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[SLI/SLO/SLA & error budgets]]></title><description><![CDATA[What these mean in real teams and how they shape engineering decisions. SLI/SLO/SLA, error budgets, alert fatigue, anomaly detection, real-time dashboards]]></description><link>https://saifhatem.substack.com/p/slislosla-and-error-budgets</link><guid isPermaLink="false">https://saifhatem.substack.com/p/slislosla-and-error-budgets</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Wed, 29 Jul 2026 12:29:37 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!o9Zx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!o9Zx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!o9Zx!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png 424w, /__u/substackcdn.com/image/fetch/$s_!o9Zx!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png 848w, /__u/substackcdn.com/image/fetch/$s_!o9Zx!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png 1272w, /__u/substackcdn.com/image/fetch/$s_!o9Zx!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!o9Zx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png" width="1132" height="1037" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1037,&quot;width&quot;:1132,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1751518,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/207676451?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!o9Zx!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png 424w, /__u/substackcdn.com/image/fetch/$s_!o9Zx!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png 848w, /__u/substackcdn.com/image/fetch/$s_!o9Zx!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png 1272w, /__u/substackcdn.com/image/fetch/$s_!o9Zx!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99493a31-3d49-4e3c-a63f-c7657845a9f3_1132x1037.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h1>The Reliability Triad: Decoding SLIs, SLOs, and SLAs</h1><p>To build reliable systems without completely freezing feature development, you need a shared engineering vocabulary.</p><p>The industry often lumps these concepts together under the general umbrella of &#8220;SLAs,&#8221; but understanding the strict distinction between an <strong>indicator</strong>, an <strong>objective</strong>, and an <strong>agreement</strong> is critical when designing resilient architecture.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design Horizon! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{SLI (Metric)} \\longrightarrow \\text{SLO (Target)} \\longrightarrow \\text{SLA (Contract)}&quot;,&quot;id&quot;:&quot;RSJXOBFZXT&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><h3>SLI (Service Level Indicator): The Raw Measurement</h3><p>An SLI is a carefully defined quantitative measurement of your system&#8217;s current performance. It answers a simple question: <strong>&#8220;What is the system actually doing right now?&#8221; a.k.a <mark data-color="#b45f06" style="background-color: rgb(180, 95, 6); color: rgb(255, 255, 255);">what you measure</mark></strong></p><p>Common SLIs include request latency, error rate, system throughput, and availability.</p><blockquote><p><strong>The Long-Tail Trap:</strong> Never average your metrics. Averaging request latency completely hides bad user experiences by smearing the tail. </p><p>A mean latency of <span>50 ms</span> looks great on paper, but it obscures the <span>1%</span> of users experiencing brutal <span>5 second</span> delays. Track your SLIs using <strong>percentiles</strong> <span>p95</span>, <span>p99</span>, <span>p99.9</span>) instead of averages.</p></blockquote><p>Mathematically, a basic availability SLI is expressed as:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{SLI} = \\left( \\frac{\\text{Successful Requests}}{\\text{Total Requests}} \\right) \\times 100&quot;,&quot;id&quot;:&quot;CAJOBTBASC&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!0iWu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0233771c-4573-4a35-a323-2536af8295a2_1152x640.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!0iWu!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0233771c-4573-4a35-a323-2536af8295a2_1152x640.png 424w, /__u/substackcdn.com/image/fetch/$s_!0iWu!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0233771c-4573-4a35-a323-2536af8295a2_1152x640.png 848w, /__u/substackcdn.com/image/fetch/$s_!0iWu!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0233771c-4573-4a35-a323-2536af8295a2_1152x640.png 1272w, /__u/substackcdn.com/image/fetch/$s_!0iWu!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0233771c-4573-4a35-a323-2536af8295a2_1152x640.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!0iWu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0233771c-4573-4a35-a323-2536af8295a2_1152x640.png" width="1152" height="640" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0233771c-4573-4a35-a323-2536af8295a2_1152x640.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:640,&quot;width&quot;:1152,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:414949,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/207676451?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0233771c-4573-4a35-a323-2536af8295a2_1152x640.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!0iWu!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0233771c-4573-4a35-a323-2536af8295a2_1152x640.png 424w, /__u/substackcdn.com/image/fetch/$s_!0iWu!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0233771c-4573-4a35-a323-2536af8295a2_1152x640.png 848w, /__u/substackcdn.com/image/fetch/$s_!0iWu!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0233771c-4573-4a35-a323-2536af8295a2_1152x640.png 1272w, /__u/substackcdn.com/image/fetch/$s_!0iWu!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0233771c-4573-4a35-a323-2536af8295a2_1152x640.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>SLO (Service Level Objective): The Engineering Target</h3><p>An SLO is the target value or range of values you expect your SLI to meet. It answers the question: <strong>&#8220;How good does the service actually need to be?&#8221;</strong></p><ul><li><p><strong>Example:</strong> <em>&#8220;The <span>p99</span> latency of  the </em><code>GET/user</code><em> requests will be  <span>&lt; 100ms</span> over a rolling 30-day window.&#8221;</em></p></li><li><p><strong>Example:</strong> <em>&#8220;The system will maintain <span>99.9%</span> successful HTTP responses per calendar month.&#8221;</em></p></li></ul><p>Your SLO is the primary operational boundary for your team. <strong>It defines the exact line between acceptable performance and an outage</strong>, directly dictating how much <strong>Error Budget</strong> (<span>Error Budget = 100% - SLO</span>) you have left to ship new features.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!VVMu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!VVMu!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png 424w, /__u/substackcdn.com/image/fetch/$s_!VVMu!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png 848w, /__u/substackcdn.com/image/fetch/$s_!VVMu!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png 1272w, /__u/substackcdn.com/image/fetch/$s_!VVMu!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!VVMu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png" width="1146" height="637" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:637,&quot;width&quot;:1146,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:586416,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/207676451?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!VVMu!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png 424w, /__u/substackcdn.com/image/fetch/$s_!VVMu!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png 848w, /__u/substackcdn.com/image/fetch/$s_!VVMu!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png 1272w, /__u/substackcdn.com/image/fetch/$s_!VVMu!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe35982e6-115b-46d5-ae63-a5ef01459244_1146x637.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>SLA (Service Level Agreement): The Business Contract</h3><p>An SLA is an explicit or implicit contract between you and your business customers that includes tangible consequences (usually financial penalties, billing credits, or refunds) if your service misses its targets.</p><ul><li><p><strong>The Gold Rule:</strong> If there is no explicit penalty or financial refund tied to missing the target, <strong>it is an SLO, not an SLA</strong>.</p></li></ul><p>Engineering teams build toward <strong>SLOs</strong>, while legal and sales teams negotiate <strong>SLAs</strong>. To give your architecture a safety buffer, your internal SLO should always be stricter than your public SLA. If your SLA promises <span>99%</span> uptime to customers, your internal SLO should be set to <span>99.9%</span>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!p2Qo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!p2Qo!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png 424w, /__u/substackcdn.com/image/fetch/$s_!p2Qo!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png 848w, /__u/substackcdn.com/image/fetch/$s_!p2Qo!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png 1272w, /__u/substackcdn.com/image/fetch/$s_!p2Qo!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!p2Qo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png" width="1152" height="640" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:640,&quot;width&quot;:1152,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:479078,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/207676451?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!p2Qo!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png 424w, /__u/substackcdn.com/image/fetch/$s_!p2Qo!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png 848w, /__u/substackcdn.com/image/fetch/$s_!p2Qo!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png 1272w, /__u/substackcdn.com/image/fetch/$s_!p2Qo!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb1db00-22eb-490a-b7f7-0f402e8686b1_1152x640.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Direct comparison</h3><p>As the graph illustrates what we talked about above, the Safety buffer acts as a &#8216;cushion&#8217; for businesses to give a high-level insight of their state, in this example latency is being measured. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!WkEW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!WkEW!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png 424w, /__u/substackcdn.com/image/fetch/$s_!WkEW!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png 848w, /__u/substackcdn.com/image/fetch/$s_!WkEW!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png 1272w, /__u/substackcdn.com/image/fetch/$s_!WkEW!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!WkEW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png" width="1151" height="637" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:637,&quot;width&quot;:1151,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:384490,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/207676451?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!WkEW!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png 424w, /__u/substackcdn.com/image/fetch/$s_!WkEW!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png 848w, /__u/substackcdn.com/image/fetch/$s_!WkEW!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png 1272w, /__u/substackcdn.com/image/fetch/$s_!WkEW!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc83e48a-97e1-41a7-b706-600e501f1fda_1151x637.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!y9iz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!y9iz!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png 424w, /__u/substackcdn.com/image/fetch/$s_!y9iz!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png 848w, /__u/substackcdn.com/image/fetch/$s_!y9iz!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png 1272w, /__u/substackcdn.com/image/fetch/$s_!y9iz!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!y9iz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png" width="1152" height="640" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:640,&quot;width&quot;:1152,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:679925,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/207676451?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!y9iz!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png 424w, /__u/substackcdn.com/image/fetch/$s_!y9iz!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png 848w, /__u/substackcdn.com/image/fetch/$s_!y9iz!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png 1272w, /__u/substackcdn.com/image/fetch/$s_!y9iz!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9669900-8b2f-486f-9520-9dfbdc744cef_1152x640.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h1>Why 100% Reliability is the Wrong Target</h1><p>It is a classic engineering trap to aim for perfect, 100% uptime. However, as Google&#8217;s Site Reliability Engineers (SREs) famously point out, <strong>100% is almost always the wrong reliability target</strong> for virtually every software system (outside of rare life-or-death exceptions like pacemakers or anti-lock brakes).</p><p>Chasing that final, elusive percentage point breaks down for three major reasons:</p><h3>1. The Financial &amp; Operational Cost Explodes</h3><p>Reaching <span>99.9%</span> availability is hard, but reaching <span>100%</span> requires exponential investment. The cost to achieve that final fraction of a percent does not scale linearly&#8212;it explodes. You end up spending vast amounts of engineering capital on multi-region redundancy, real-time failovers, specialized infrastructure, and round-the-clock operational coverage just to chase a statistical ghost.</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Cost} \\propto \\frac{1}{100\\% - \\text{Target Reliability}}&quot;,&quot;id&quot;:&quot;WYYKPMDBTU&quot;}" data-component-name="LatexBlockToDOM"></div><p><em>p.s. the weird sign after cost means propotional to</em></p><h3>2. Maximum Stability Paralyzes Feature Velocity</h3><p>Systems only break when things change. If your goal is zero downtime, the safest engineering decision is to <strong>never ship new code</strong>.</p><p>Maximizing stability directly conflicts with product innovation. The harder you fight to maintain 100% uptime, the slower you deploy new features, ship bug fixes, and iterate on user feedback. You end up trading product velocity and competitive advantage for an arbitrary operational metric.</p><h3>3. Users Can&#8217;t Tell the Difference Anyway</h3><p>The end-user literally cannot distinguish between a system that is <span>100%</span> available and one that is <span>99.999%</span> available.</p><p>Why? Because the tiny marginal difference in your cloud uptime gets completely swallowed by the background noise of the real world:</p><ul><li><p>Unstable home Wi-Fi routers</p></li><li><p>Spotty 4G/5G cellular connections</p></li><li><p>Local ISP outages</p></li><li><p>Mobile device OS glitches</p></li></ul><p>If a user&#8217;s own network drops packets <span>1%</span> of the time, building a backend with <span>0.00001%</span> downtime offers <strong>zero perceptible improvement</strong> to their actual experience.</p><h3>The Engineering Takeaway: &#8220;Reliable Enough&#8221;</h3><p>Instead of chasing perfection, software teams must define the appropriate level of risk they are willing to take.</p><p>Your goal isn&#8217;t to build a system that never fails; it&#8217;s to build a service that is <strong>reliable enough, but no more reliable than it needs to be</strong>. Every fraction of reliability past that line is wasted money and sacrificed feature velocity.</p><h1>Error Budgets: The Ultimate Negotiation Tool</h1><p>The structural conflict between product managers (who want to ship features fast) and system architects (who want to keep the system stable) is legendary. The solution to this eternal tension isn&#8217;t endless meetings, it&#8217;s the <strong>Error Budget</strong>.</p><p>An error budget is simply <span>100%</span> minus your SLO target.</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Error Budget} = 100\\% - \\text{SLO}&quot;,&quot;id&quot;:&quot;XDJMJJTAOP&quot;}" data-component-name="LatexBlockToDOM"></div><p>If your service has an SLO to successfully serve <span>99.999%</span> of queries over a quarter, your error budget is a permissible failure rate of <strong><span>0.001%</span></strong>. That tiny fraction is a resource to be spent. You can spend it however you want, mostly on taking calculated risks to launch new features quickly.</p><h3>The Neutral, Data-Driven Referee</h3><p>The beauty of the error budget is that it removes emotion from the release process and acts as a neutral, data-driven referee:</p><ul><li><p><strong>Budget Remaining (<span>&gt; 0%</span>):</strong> The development team has the green light. They are free to push new code, run canary deployments, and take risks to move fast.</p></li><li><p><strong>Budget Exhausted (<span>= 0%</span>):</strong> Feature releases are automatically frozen. The engineering team must pivot <span>100%</span> of their focus to reliability, technical debt, and system stability until the budget resets or recovers.</p></li></ul><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Error Budget } > 0\\% \\longrightarrow \\text{Ship Features Fast}\n&quot;,&quot;id&quot;:&quot;GTRELJIYHT&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Error Budget } = 0\\% \\longrightarrow \\text{Freeze Deploys &amp; Fix Reliability}\n&quot;,&quot;id&quot;:&quot;LSBQYWSORN&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>In effect, the product team becomes completely <strong>self-policing</strong>. If they want to maintain high feature velocity, they are forced to write stable, resilient code that protects their budget.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!JiCc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!JiCc!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png 424w, /__u/substackcdn.com/image/fetch/$s_!JiCc!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png 848w, /__u/substackcdn.com/image/fetch/$s_!JiCc!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JiCc!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!JiCc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png" width="1150" height="642" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:642,&quot;width&quot;:1150,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:397323,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/207676451?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!JiCc!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png 424w, /__u/substackcdn.com/image/fetch/$s_!JiCc!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png 848w, /__u/substackcdn.com/image/fetch/$s_!JiCc!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JiCc!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89cb540-d891-4740-bf9a-915db6e08e1c_1150x642.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!p2N8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!p2N8!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png 424w, /__u/substackcdn.com/image/fetch/$s_!p2N8!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png 848w, /__u/substackcdn.com/image/fetch/$s_!p2N8!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png 1272w, /__u/substackcdn.com/image/fetch/$s_!p2N8!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!p2N8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png" width="762" height="695" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:695,&quot;width&quot;:762,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:864704,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/207676451?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!p2N8!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png 424w, /__u/substackcdn.com/image/fetch/$s_!p2N8!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png 848w, /__u/substackcdn.com/image/fetch/$s_!p2N8!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png 1272w, /__u/substackcdn.com/image/fetch/$s_!p2N8!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7323c31d-284f-4dba-b44e-4282e822cdfa_762x695.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div><hr></div><h1>Conquering Alert Fatigue: Symptoms vs. Causes</h1><p>Paging a human is an exceptionally expensive operational cost. It interrupts deep engineering workflows, ruins focus, and disrupts sleep.</p><p>When alerts fire too frequently, teams inevitably develop <strong>alert fatigue</strong>. Engineers begin skimming notifications, second-guessing the severity of pages, or completely ignoring them, a dangerous state that routinely masks catastrophic outages until it&#8217;s too late.</p><p>To build a high-signal, low-noise alerting system, you must follow a fundamental operational rule: <strong>page on symptoms, not causes.</strong></p><h3>Symptoms vs. Causes: Where to Draw the Line</h3><ul><li><p><strong>Symptoms (Page Immediately):</strong> A symptom directly measures end-user pain.</p><ul><li><p><em>Example:</em> <em>&#8220;The payment service error rate spiked to <span>5%</span>,&#8221;</em> or <em>&#8220;The checkout endpoint <span>p99</span> latency exceeded <span>2 seconds</span>.&#8221;</em></p></li><li><p>Users are actively suffering, so a human needs to wake up and intervene.</p></li></ul></li><li><p><strong>Causes (Keep for Debugging):</strong> A cause is a potential explanation for why a symptom might occur.</p><ul><li><p><em>Example:</em> <em>&#8220;Database CPU utilization reached <span>90%</span>,&#8221;</em> or <em>&#8220;Memory usage on Node 4 is high.&#8221;</em></p></li><li><p>High CPU utilization is not an outage if user requests are still completing successfully. Cause-oriented metrics belong on your dashboard, not in your PagerDuty schedule. Once an engineer is woken up by a symptomatic page, they use these cause-oriented metrics to debug the root issue.</p></li></ul></li></ul><h3>The Three Valid Outputs of Monitoring</h3><p>To eliminate noise, every single monitor or check in your infrastructure must map strictly to <strong>one</strong> of three outputs:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Telemetry Output} \\longrightarrow \n\\begin{cases} \n\\mathbf{Page} &amp; \\text{Urgent, immediate human action required NOW.} \\\\ \n\\mathbf{Ticket} &amp; \\text{Action required, but can wait for normal business hours.} \\\\ \n\\mathbf{Log} &amp; \\text{Diagnostic forensic data for post-hoc analysis.} \n\\end{cases}\n&quot;,&quot;id&quot;:&quot;SYLOEYPVMU&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><ol><li><p><strong>Pages:</strong> Reserved exclusively for critical, user-impacting symptoms. If an alert triggers a page and does not require immediate human action, it is a broken alert and must be deleted or downgraded.</p></li><li><p><strong>Tickets:</strong> Used for sub-critical issues that require human intervention but do not warrant an interruption. If a disk is at <span>80%</span> capacity and won&#8217;t fill up for two weeks, file a ticket for the next sprint.</p></li><li><p><strong>Logging/Metrics:</strong> Raw data generated for forensic analysis. Nobody needs to look at this in real time, but it must be queryable when investigating a symptom.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!zh6v!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b8dd90-4774-4777-b111-8767620c4925_1151x636.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!zh6v!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b8dd90-4774-4777-b111-8767620c4925_1151x636.png 424w, /__u/substackcdn.com/image/fetch/$s_!zh6v!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b8dd90-4774-4777-b111-8767620c4925_1151x636.png 848w, /__u/substackcdn.com/image/fetch/$s_!zh6v!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b8dd90-4774-4777-b111-8767620c4925_1151x636.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zh6v!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b8dd90-4774-4777-b111-8767620c4925_1151x636.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!zh6v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b8dd90-4774-4777-b111-8767620c4925_1151x636.png" width="1151" height="636" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/46b8dd90-4774-4777-b111-8767620c4925_1151x636.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:636,&quot;width&quot;:1151,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:422354,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/207676451?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b8dd90-4774-4777-b111-8767620c4925_1151x636.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!zh6v!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b8dd90-4774-4777-b111-8767620c4925_1151x636.png 424w, /__u/substackcdn.com/image/fetch/$s_!zh6v!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b8dd90-4774-4777-b111-8767620c4925_1151x636.png 848w, /__u/substackcdn.com/image/fetch/$s_!zh6v!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b8dd90-4774-4777-b111-8767620c4925_1151x636.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zh6v!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b8dd90-4774-4777-b111-8767620c4925_1151x636.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h3>Case Study: Google Bigtable and the &#8220;Alert Silencing&#8221; Reset</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!y9bY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a977c71-7ddd-4bf5-a3ac-9078726c7b16_602x419.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!y9bY!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a977c71-7ddd-4bf5-a3ac-9078726c7b16_602x419.png 424w, /__u/substackcdn.com/image/fetch/$s_!y9bY!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a977c71-7ddd-4bf5-a3ac-9078726c7b16_602x419.png 848w, /__u/substackcdn.com/image/fetch/$s_!y9bY!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a977c71-7ddd-4bf5-a3ac-9078726c7b16_602x419.png 1272w, /__u/substackcdn.com/image/fetch/$s_!y9bY!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a977c71-7ddd-4bf5-a3ac-9078726c7b16_602x419.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!y9bY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a977c71-7ddd-4bf5-a3ac-9078726c7b16_602x419.png" width="549" height="382.1112956810631" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8a977c71-7ddd-4bf5-a3ac-9078726c7b16_602x419.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:419,&quot;width&quot;:602,&quot;resizeWidth&quot;:549,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;How does BigTable work/Best practices: | by Arsh | Medium&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="How does BigTable work/Best practices: | by Arsh | Medium" title="How does BigTable work/Best practices: | by Arsh | Medium" srcset="/__u/substackcdn.com/image/fetch/$s_!y9bY!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a977c71-7ddd-4bf5-a3ac-9078726c7b16_602x419.png 424w, /__u/substackcdn.com/image/fetch/$s_!y9bY!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a977c71-7ddd-4bf5-a3ac-9078726c7b16_602x419.png 848w, /__u/substackcdn.com/image/fetch/$s_!y9bY!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a977c71-7ddd-4bf5-a3ac-9078726c7b16_602x419.png 1272w, /__u/substackcdn.com/image/fetch/$s_!y9bY!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a977c71-7ddd-4bf5-a3ac-9078726c7b16_602x419.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>At one point, Google&#8217;s Bigtable team found themselves trapped in an alert fatigue spiral. Non-urgent alerts were firing in such massive volumes that engineers spent 100% of their time playing whack-a-mole with noisy notifications, leaving zero room to fix the underlying infrastructure.</p><p>Their fix was drastic, effective, and counterintuitive:</p><ul><li><p>They <strong>temporarily lowered their internal SLO target</strong>.</p></li><li><p>They <strong>disabled email alerts completely</strong>.</p></li></ul><p>By muting the noise, the team created the necessary engineering breathing room to refactor fragile subsystems and fix the true root causes. Once the underlying infrastructure was hardened, they turned the alerts back on&#8212;this time targeting high-signal, actionable symptoms.</p><h1>The Four Golden Signals of Monitoring</h1><p>To protect your SLOs without burning out your on-call engineers, you need to be surgical about what you measure.</p><p>Monitoring everything creates useless noise. If you can only track four fundamental metrics across your distributed architecture, they should be Google&#8217;s <strong>Four Golden Signals</strong>:</p><h3>1. Latency: The Speed of Your Service</h3><p>Latency is the time it takes to process a request.</p><blockquote><p><strong>The Fast-Failure Trap:</strong> You must track the latency of <strong>successful requests separately from failed requests</strong>. An HTTP <span>500</span> Internal Server Error that fails instantly in <span>2ms </span>will artificially pull down your average latency, making a broken system look extremely &#8220;fast&#8221; on a dashboard. Always isolate your error latency so it doesn&#8217;t mask real user pain.</p></blockquote><p>Track latency across percentile distributions (<span>p50</span>, <span>p95</span>, <span>p99</span>) rather than simple means.</p><h3>2. Traffic: The Demand on Your System</h3><p>Traffic measures the high-level demand being placed on your service.</p><ul><li><p><strong>Web/API Services:</strong> Measured in HTTP requests per second (<span>RPS</span>).</p></li><li><p><strong>Streaming/Message Queues:</strong> Measured in network <span>I/O</span>, transactions per second (<span>TPS</span>), or message throughput.</p></li><li><p><strong>Storage Systems:</strong> Measured in read/write operations per second (<span>IOPS</span>).</p></li></ul><p>Monitoring traffic gives you a baseline for system load, helping you distinguish between an outage caused by external traffic spikes versus internal code regressions.</p><h3>3. Errors: The Rate of System Failure</h3><p>Errors measure the rate of requests that fail to complete correctly. These fall into two distinct categories:</p><ul><li><p><strong>Explicit Errors:</strong> The service actively throws an error code (e.g., HTTP <span>500</span>s, database connection timeouts, or RPC failures).</p></li><li><p><strong>Implicit Errors:</strong> The service returns a successful status code (e.g., HTTP <span>200 OK</span>), but delivers completely wrong content, an empty JSON payload, or misconfigured response headers.</p></li></ul><p>Your alerting pipeline must track both. An application returning HTTP <span>200 OK</span> with a payload reading <code>{"error": "Database disconnected"}</code> is still a broken user experience.</p><h3>4. Saturation: The Fullness of Your Resources</h3><p>Saturation measures how &#8220;full&#8221; your system is relative to its absolute capacity limits. It highlights your most constrained hardware or software resources (CPU utilization, RAM consumption, disk <span>I/O</span>, or thread pool limits).</p><p>While Latency, Traffic, and Errors measure direct user-facing symptoms, <strong>Saturation is a leading indicator</strong>. It lets you predict impending crashes <em>before</em> they impact users:</p><ul><li><p><em>&#8220;Our database disk usage is at <span>92%</span> and will fill up completely in <span>4 hours</span>.&#8221;</em></p></li><li><p><em>&#8220;Our thread pool queue is <span>85%</span> full, and latency will spike the moment it hits <span>100%</span>.&#8221;</em></p></li></ul><h3>Summary Checklist for System Design</h3><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{cases} \n\\mathbf{Latency} &amp; \\text{How long does a request take? (Separate success vs. failure)} \\\\ \n\\mathbf{Traffic} &amp; \\text{How much load is hitting the system? (RPS, IOPS)} \\\\ \n\\mathbf{Errors} &amp; \\text{How many requests are failing? (Explicit + Implicit)} \\\\ \n\\mathbf{Saturation} &amp; \\text{How close are we to maximum resource capacity?} \n\\end{cases}&quot;,&quot;id&quot;:&quot;PEONWLCCFC&quot;}" data-component-name="LatexBlockToDOM"></div><h1>From Anomalies to Action: Real-Time Dashboards</h1><p>For everything that doesn&#8217;t trigger a 3:00 AM page, you need highly visible transparency. Dashboards answer the fundamental operational questions about your service and should prominently feature the <strong>Four Golden Signals</strong>.</p><p>By centralizing these real-time insights onto simple, clean dashboards, engineering teams can continuously monitor their SLIs, track how fast they are burning through their Error Budget, and make data-driven architectural decisions:</p><ul><li><p><strong>Error Budgets:</strong> Eliminate corporate politics from release decisions.</p></li><li><p><strong>Golden Signals:</strong> Eliminate guesswork during active incidents.</p></li><li><p><strong>Symptom-Based Alerting:</strong> Eliminate pager burnout across the engineering team.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!rLog!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!rLog!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png 424w, /__u/substackcdn.com/image/fetch/$s_!rLog!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png 848w, /__u/substackcdn.com/image/fetch/$s_!rLog!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png 1272w, /__u/substackcdn.com/image/fetch/$s_!rLog!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!rLog!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png" width="762" height="542" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:542,&quot;width&quot;:762,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:365177,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/207676451?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!rLog!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png 424w, /__u/substackcdn.com/image/fetch/$s_!rLog!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png 848w, /__u/substackcdn.com/image/fetch/$s_!rLog!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png 1272w, /__u/substackcdn.com/image/fetch/$s_!rLog!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca40528b-a8d7-43ec-939b-0784ff3ea781_762x542.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design Horizon! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Consistent hashing: rendezvous hashing & jump consistent hash]]></title><description><![CDATA[Explore advanced alternatives to classic hash rings. Understand when highest-randomweight routing or zero-memory jump hashes outperform traditional topologies in hyperscale environments]]></description><link>https://saifhatem.substack.com/p/consistent-hashing-rendezvous-hashing</link><guid isPermaLink="false">https://saifhatem.substack.com/p/consistent-hashing-rendezvous-hashing</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Thu, 09 Jul 2026 06:35:45 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!cBZU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="pullquote"><p><strong>Note to readers:</strong> This post assumes you understand the fundamentals of consistent hashing, hash rings, and virtual nodes. If you need a refresher on those core concepts, refer to this previous post before diving into these advanced topologies.</p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;0d455031-192f-4066-9884-9f11c3e62488&quot;,&quot;caption&quot;:&quot;Introduction&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;lg&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Consistent hashing: consistent hashing &amp; virtual nodes &quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:325234248,&quot;name&quot;:&quot;Saif Hatem&quot;,&quot;bio&quot;:&quot;Welcome to my substack! I aim to conceptualize system design concepts to make it easier for you to grasp&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/972a0a07-9994-452d-b5d8-5e19fd05e989_638x638.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2026-06-29T06:52:35.079Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!kGek!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://saifhatem.substack.com/p/consistent-hashing-consistent-hashing&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:202805814,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:2,&quot;comment_count&quot;:0,&quot;publication_id&quot;:8298648,&quot;publication_name&quot;:&quot;System Design Horizon&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!9PQi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95379382-ea93-4a98-b64e-510711f1ddd8_1280x1280.png&quot;,&quot;belowTheFold&quot;:false,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div></div><h1>Advanced Consistent Hashing: Beyond the Hash Ring</h1><h2>Introduction: The Hyperscale Bottleneck of the Token Ring</h2><p>In our last post, we looked at how a classic hash ring with virtual nodes (vnodes) solves the problem of catastrophic re-sharding. By breaking physical servers into hundreds of interleaved virtual nodes, we can balance data distribution and prevent structural hotspots.</p><p>This approach works incredibly well for standard distributed clusters. But when you scale to <strong>hyperscale environments</strong> that is, managing thousands of servers processing millions of requests per second, the classic token ring introduces two major architectural bottlenecks: <strong>memory overhead</strong> and <strong>lookup latency</strong>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design Horizon! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h3>The Cost of Virtual Nodes</h3><p>To achieve a safe load imbalance (a standard deviation of 5% to 10%), a physical server typically requires 100 to 300 virtual nodes.</p><p>If your infrastructure scales to 2,000 physical storage servers/nodes, your system must map and track up to 600,000 virtual nodes (2000 x 300).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!MNH1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!MNH1!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png 424w, /__u/substackcdn.com/image/fetch/$s_!MNH1!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png 848w, /__u/substackcdn.com/image/fetch/$s_!MNH1!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png 1272w, /__u/substackcdn.com/image/fetch/$s_!MNH1!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!MNH1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png" width="1007" height="760" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:760,&quot;width&quot;:1007,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:151123,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/204566996?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="/__u/substackcdn.com/image/fetch/$s_!MNH1!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png 424w, /__u/substackcdn.com/image/fetch/$s_!MNH1!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png 848w, /__u/substackcdn.com/image/fetch/$s_!MNH1!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png 1272w, /__u/substackcdn.com/image/fetch/$s_!MNH1!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc0821de-b96e-40a0-bb15-805cd15aecd1_1007x760.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>In our example above, we have several clusters of virtual nodes.</p><p>The number of mappings the system needs to track is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Total Mappings} = (\\text{Number of Physical Clusters}) \\times (\\text{Virtual Nodes per Cluster})&quot;,&quot;id&quot;:&quot;DJWJYGUNAP&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>In the example above if we assume that we have 200 vnodes per cluster(50 per server), and we have 4 of them in our ring, then we have 4 x 200 = 800 virtual nodes or 4 x 50 x 4 = 800 mappings!<br><br>This number is prone to fast scaling, because what if we have over 1000 physical servers? and we have lets say 250 virtual nodes per server, then we would need 250,000 mappings! You can already guess where we are heading to.</p><p>At a larger scale, as depicted in the image below, the problem continues to worsen at a rapid rate!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!zl0c!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!zl0c!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png 424w, /__u/substackcdn.com/image/fetch/$s_!zl0c!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png 848w, /__u/substackcdn.com/image/fetch/$s_!zl0c!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zl0c!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!zl0c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png" width="1197" height="646" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:646,&quot;width&quot;:1197,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1138736,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/204566996?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!zl0c!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png 424w, /__u/substackcdn.com/image/fetch/$s_!zl0c!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png 848w, /__u/substackcdn.com/image/fetch/$s_!zl0c!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zl0c!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbacda5d0-72b8-4b7a-bed5-51eea904afdc_1197x646.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>The Memory and Coordination Problem</h3><p>This two-million-node layout cannot just live on a single central controller. It must be duplicated, synchronized, and held in memory across <strong>every single client machine, load balancer, and routing proxy</strong> in your architecture so they know exactly where to direct traffic.</p><p>At hyperscale, this introduces two massive problems:</p><ul><li><p><strong>The Gossip Bottleneck:</strong> Infrastructure is dynamic. Hard drives fail, network cables glitch, and servers restart. Every time a single physical server blinks, its 250 virtual nodes vanish and reappear on the ring. Propagating these continuous ring updates across thousands of routing proxies via gossip protocols creates massive network overhead, routing lag, and temporary consistency mismatches.</p></li><li><p><strong>Lookup Overhead:</strong> To route a request, a proxy must hash the key and search a balanced binary tree (like a Red-Black Tree) of, lets say, 2 million nodes to find the next clockwise server. While an <span>O(log M)</span> tree search is fast, when you are processing millions of concurrent requests per second, those CPU cycles compound rapidly. Your routing layer quickly becomes your primary performance bottleneck.</p></li></ul><p>To bypass these scaling limits entirely, hyperscale systems design <strong>cuts out the ring completely</strong>.</p><h2>Rendezvous Hashing</h2><p><strong>Rendezvous Hashing</strong> (also known as Highest Random Weight Routing) solves the scaling problem by destroying the concept of a hash ring.</p><p>Instead of forcing servers and data keys to share coordinates on a circle, Rendezvous Hashing uses a purely mathematical approach: it calculates a dynamic match score between an incoming key and every available server on the fly.</p><h3>The Core Mechanism: Weight Calculation</h3><p>When a request comes in, the routing proxy does not search a massive layout in memory. Instead, it takes the incoming data key, pairs it with a server&#8217;s unique ID, and hashes them together to generate a weight or &#8220;score.&#8221;</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Score}_{i} = \\text{Hash}(\\text{Key} + \\text{Node_ID}_{i})&quot;,&quot;id&quot;:&quot;OJNDZIGPFQ&quot;}" data-component-name="LatexBlockToDOM"></div><p>The proxy runs this calculation for every single active server in the cluster. The server that yields the <strong>highest score</strong> wins the key and processes the request.</p><p>Let&#8217;s use a concrete example. Imagine an incoming request for a data key called <code>"User_123"</code> hits your proxy, and your cluster contains three available servers: <code>"Server A"</code>, <code>"Server B"</code>, and <code>"Server C"</code>.</p><p>To find out where this key belongs, the proxy calculates a unique weight for each node:</p><ol><li><p><strong>Weight for Server A:</strong> <code>Hash("User_123" + "Server A")</code> = <code>42</code></p></li><li><p><strong>Weight for Server B:</strong> <code>Hash("User_123" + "Server B")</code> = <code>98</code></p></li><li><p><strong>Weight for Server C:</strong> <code>Hash("User_123" + "Server C")</code> = <code>17</code></p></li></ol><p>Because <code>"Server B"</code> yielded the <strong>highest weight (98)</strong>, it wins the election, and the proxy routes the request straight to it.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!T36U!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3753361-83f7-49b2-8856-060422020ebe_1212x656.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!T36U!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3753361-83f7-49b2-8856-060422020ebe_1212x656.png 424w, /__u/substackcdn.com/image/fetch/$s_!T36U!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3753361-83f7-49b2-8856-060422020ebe_1212x656.png 848w, /__u/substackcdn.com/image/fetch/$s_!T36U!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3753361-83f7-49b2-8856-060422020ebe_1212x656.png 1272w, /__u/substackcdn.com/image/fetch/$s_!T36U!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3753361-83f7-49b2-8856-060422020ebe_1212x656.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!T36U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3753361-83f7-49b2-8856-060422020ebe_1212x656.png" width="1212" height="656" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c3753361-83f7-49b2-8856-060422020ebe_1212x656.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:656,&quot;width&quot;:1212,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:482886,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/204566996?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3753361-83f7-49b2-8856-060422020ebe_1212x656.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!T36U!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3753361-83f7-49b2-8856-060422020ebe_1212x656.png 424w, /__u/substackcdn.com/image/fetch/$s_!T36U!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3753361-83f7-49b2-8856-060422020ebe_1212x656.png 848w, /__u/substackcdn.com/image/fetch/$s_!T36U!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3753361-83f7-49b2-8856-060422020ebe_1212x656.png 1272w, /__u/substackcdn.com/image/fetch/$s_!T36U!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3753361-83f7-49b2-8856-060422020ebe_1212x656.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>What does &#8220;Hash&#8221; actually mean here?</h3><p>When we say we &#8220;hash&#8221; the combined string, we aren&#8217;t just looking for a random text output like standard SHA-256 hex strings.</p><p>Instead, the proxy feeds the combined text (e.g., <code>"User_123Server_B"</code>) into a uniform hash function that outputs a large, predictable <strong>integer</strong> value.</p><p>To ensure the load is balanced perfectly over time, the hash function used must have high <strong>entropy</strong>. This means that changing a single character in the input string (like evaluating <code>"User_124"</code> instead of <code>"User_123"</code>) will yield completely different, widely distributed integer scores for the servers. This randomness guarantees that across millions of keys, every server gets its fair share of highest scores.</p><p>Also note that since hashing is deterministic, the exact combination of key value and server value would yield to route to the exact same node/server every time.</p><h3>Scaling Operations: Dynamic Handoffs</h3><p>Because there are no physical ring positions or virtual nodes to track, scaling events are cleanly isolated without requiring cluster-wide synchronization:</p><ul><li><p><strong>When a server crashes:</strong> If <code>Server B</code> goes offline, proxies simply stop including it in the score calculations. When calculating the weights for <code>"User_123"</code> among the remaining healthy nodes, <code>Server A</code> (weight <code>42</code>) is now the highest surviving score. The traffic naturally shifts to <code>Server A</code>. Only the data that lived on the dead node moves; the rest of the cluster remains completely unaffected.</p></li><li><p><strong>When a server is added:</strong> If you spin up a new node, <code>Server D</code>, proxies start calculating a 4th weight for incoming keys. <code>Server D</code> will only win a key if <code>Hash("User_123" + "Server D")</code> beats the existing highest weight (<code>98</code>). Mathematically, it will only steal its fair share of keys from the other nodes, resulting in a perfect load rebalance without needing a ring.</p><p></p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!fDGV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!fDGV!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png 424w, /__u/substackcdn.com/image/fetch/$s_!fDGV!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png 848w, /__u/substackcdn.com/image/fetch/$s_!fDGV!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png 1272w, /__u/substackcdn.com/image/fetch/$s_!fDGV!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!fDGV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png" width="1212" height="656" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:656,&quot;width&quot;:1212,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:800701,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/204566996?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!fDGV!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png 424w, /__u/substackcdn.com/image/fetch/$s_!fDGV!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png 848w, /__u/substackcdn.com/image/fetch/$s_!fDGV!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png 1272w, /__u/substackcdn.com/image/fetch/$s_!fDGV!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e034913-07d5-4103-9de5-dc610baca95f_1212x656.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h3>The Trade-off: Zero Memory vs. <span>O(N)</span> CPU Compute</h3><p>Rendezvous Hashing makes a classic systems design trade-off: it swaps CPU cycles to save memory.</p><ul><li><p><strong>The Benefit (Zero Memory Overhead):</strong> Routing proxies do not need to maintain a complex, binary tree in memory, nor do they need to sync ring topology updates. The only metadata a proxy needs to know is a simple, flat list of active server names/IPs.</p></li><li><p><strong>The Cost (<span>O(N)</span> Lookup Time):</strong> To locate where a key lives, you must calculate a hash for <strong>every single node</strong> in the cluster. If you have 3 servers, calculating 3 hashes is trivial. If your cluster scales to 5,000 servers, calculating 5,000 hashes per request for millions of concurrent requests will absolutely melt your routing proxies&#8217; CPUs.</p></li></ul><p><em>(Note: While you can optimize Rendezvous Hashing using hierarchical tree structures to reduce lookups to <span>O(log N)</span>, the raw computational overhead makes it ideal for smaller, high-throughput proxy layers rather than massive backend storage tiers.</em></p><p><em>Saving a few microseconds on lookups isn't worth the cascading CPU spikes, gossip storms, and cluster instability required to rebuild and broadcast the tree across thousands of storage nodes every time a single shard fails, which you might recall, the same problems in the ring method that we wanted to avoid.</em></p><h2>Jump Consistent Hash (Zero-Memory Hashing)</h2><p>In 2014, Google engineers published a landmark paper titled <em>&#8220;A Fast, Minimal Memory, Consistent Hash Algorithm&#8221;</em>. They introduced <strong>Jump Consistent Hash</strong>, an elegant, ultra-fast alternative that completely redefines how distributed data placement works.</p><p>If Rendezvous Hashing trades CPU cycles to save memory, Jump Consistent Hash uses pure probability math to get the best of both worlds: <strong>zero memory overhead</strong> and blazing-fast <strong><span>O(log N)</span> execution time</strong>.</p><h3>The Core Mechanism: Probabilistic Jumping</h3><p>Instead of mapping things to a geometric ring or brute-forcing scores for every node, Jump Consistent Hash answers a simple probabilistic question:</p><blockquote><p><em>&#8220;If we increase the number of available servers from <span>N</span> to <span>N + 1</span>, what is the exact probability that a given key needs to jump to the new server?&#8221;</em></p></blockquote><p>The algorithm uses an input key and a pseudo-random number generator to determine how many times a key should &#8220;jump&#8221; across a linear sequence of buckets until it exceeds the total number of available servers.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Cubn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Cubn!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png 424w, /__u/substackcdn.com/image/fetch/$s_!Cubn!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png 848w, /__u/substackcdn.com/image/fetch/$s_!Cubn!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Cubn!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Cubn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png" width="1207" height="660" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:660,&quot;width&quot;:1207,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:806015,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/204566996?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Cubn!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png 424w, /__u/substackcdn.com/image/fetch/$s_!Cubn!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png 848w, /__u/substackcdn.com/image/fetch/$s_!Cubn!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Cubn!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02a94b8c-4c8c-4312-9e3a-ea42732cdf07_1207x660.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>The code-wise core logic is as follows:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;cpp&quot;,&quot;nodeId&quot;:&quot;5263d963-5aec-4252-b70c-c474aa01d966&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-cpp">int jump_consistent_hash(uint64_t key, int num_buckets) {
    // b tracks the last valid bucket the key "jumped" into.
    // We start at -1 because the first jump will naturally move us to bucket 0.
    int64_t b = -1, j = 0;
    
    // The loop simulates jumping forward through bucket indices.
    // It terminates the moment the next calculated jump (j) exceeds our total server count.
    while (j &lt; num_buckets) {
        // Since j is still a valid bucket index, we log it as our current position (b).
        b = j;
        
        // This is a Linear Congruential Generator (LCG). 
        // It uses a massive prime multiplier to scramble the bits of the key,
        // acting as a pseudo-random number generator seeded by the key itself.
        key = key * 2862933555777941757ULL + 1;
        
        // This is the probability math. It calculates the next bucket index (j) 
        // that this specific key will "jump" to, based on a uniform distribution.
        // It uses floating-point division to figure out the exact jump distance.
        j = (b + 1) * (double)(1LL &lt;&lt; 31) / (double)((key &gt;&gt; 33) + 1);
    }
    
    // Once j jumps past the total number of buckets, the loop ends.
    // The last valid bucket index stored in b is where our key officially lives.
    return b;
}</code></pre></div><p>Instead of storing locations, the algorithm calculates a deterministic path. Because the random number generator is seeded by the <code>key</code>, the output bucket is perfectly consistent every single time you execute the function.</p><h3>Scaling Operations: The &#8220;End of the Line&#8221; Scaling Rule</h3><p>Because Jump Consistent Hash does not use server identifiers (like IP addresses or hostnames) to calculate placement, it handles scaling events under a strict geometric constraint:</p><ul><li><p><strong>When a server is added:</strong> You increment the <code>num_buckets</code> variable from                <span>N</span> to <span>N + 1</span>. The math dictates that roughly <span>1/N+1</span> of the total keys will dynamically &#8220;jump&#8221; to the newly created bucket, while the remaining keys stay exactly where they were.</p></li><li><p><strong>The Catastrophic Constraint:</strong> To make this math work, <strong>your servers must be numbered sequentially as integers (<span>0, 1, 2, &#8230;, N-1</span>)</strong>. You cannot use arbitrary names, and you <strong>cannot remove nodes from the middle of the sequence</strong>.</p></li></ul><p>If Server 2 out of 5 crashes, you cannot simply drop it; doing so would break the sequential array (<span>0, 1, 3, 4)</span>, corrupting the mathematical jumps and misrouting almost all subsequent keys.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!cBZU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!cBZU!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png 424w, /__u/substackcdn.com/image/fetch/$s_!cBZU!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png 848w, /__u/substackcdn.com/image/fetch/$s_!cBZU!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cBZU!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!cBZU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png" width="1217" height="661" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:661,&quot;width&quot;:1217,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:759847,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/204566996?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!cBZU!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png 424w, /__u/substackcdn.com/image/fetch/$s_!cBZU!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png 848w, /__u/substackcdn.com/image/fetch/$s_!cBZU!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cBZU!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf14ca34-ebd7-4802-8409-1dcf358d2214_1217x661.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>The Trade-off: Maximum Speed vs. Sequential Rigidity</h3><p>Jump Consistent Hash is the ultimate optimization for specific hyperscale architectures, but it is not a general-purpose solution.</p><ul><li><p><strong>The Benefit:</strong> It requires <strong>zero memory</strong>. It doesn&#8217;t use a ring, a token tree, a routing table, or virtual nodes. It executes at lightning speed in <span>O(log N)</span> time using basic bitwise arithmetic, making it incredibly lightweight for high-volume data streams.</p></li><li><p><strong>The Cost:</strong> It is completely inflexible regarding cluster membership. It is only viable for <strong>stateless </strong>routing nodes or architectures where backend servers are scaled up or down strictly at the end of the sequence (like expanding a massive, append-only cold storage tier).</p></li></ul><h2>The Hyperscale Architecture</h2><p>When designing a distributed system, there is no single &#8220;best&#8221; hashing algorithm. Your choice depends entirely on your cluster&#8217;s scale, memory constraints, and how predictably your hardware scales.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!-w4q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!-w4q!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png 424w, /__u/substackcdn.com/image/fetch/$s_!-w4q!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png 848w, /__u/substackcdn.com/image/fetch/$s_!-w4q!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-w4q!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!-w4q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png" width="1211" height="655" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:655,&quot;width&quot;:1211,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1134454,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/204566996?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!-w4q!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png 424w, /__u/substackcdn.com/image/fetch/$s_!-w4q!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png 848w, /__u/substackcdn.com/image/fetch/$s_!-w4q!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-w4q!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8628a5-0c46-4064-a554-fc6bb69c3db3_1211x655.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The table below summarizes the trade-offs discussed above:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!zIsI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!zIsI!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png 424w, /__u/substackcdn.com/image/fetch/$s_!zIsI!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png 848w, /__u/substackcdn.com/image/fetch/$s_!zIsI!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zIsI!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!zIsI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png" width="1211" height="657" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:657,&quot;width&quot;:1211,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1019390,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/204566996?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!zIsI!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png 424w, /__u/substackcdn.com/image/fetch/$s_!zIsI!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png 848w, /__u/substackcdn.com/image/fetch/$s_!zIsI!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zIsI!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feea96860-88d0-4ce0-8fee-4a3580e5b309_1211x657.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Production Heuristics: When to Use What in an Interview</h3><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!A8dI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a31c754-4636-45d9-a5e2-1dbcdfe9d9f7_560x548.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!A8dI!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a31c754-4636-45d9-a5e2-1dbcdfe9d9f7_560x548.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!A8dI!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a31c754-4636-45d9-a5e2-1dbcdfe9d9f7_560x548.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!A8dI!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a31c754-4636-45d9-a5e2-1dbcdfe9d9f7_560x548.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!A8dI!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a31c754-4636-45d9-a5e2-1dbcdfe9d9f7_560x548.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!A8dI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a31c754-4636-45d9-a5e2-1dbcdfe9d9f7_560x548.jpeg" width="238" height="232.9" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7a31c754-4636-45d9-a5e2-1dbcdfe9d9f7_560x548.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:548,&quot;width&quot;:560,&quot;resizeWidth&quot;:238,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Art of Empathy in Tech Interviews: Balancing Humanity with Hard Skills&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Art of Empathy in Tech Interviews: Balancing Humanity with Hard Skills" title="Art of Empathy in Tech Interviews: Balancing Humanity with Hard Skills" srcset="/__u/substackcdn.com/image/fetch/$s_!A8dI!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a31c754-4636-45d9-a5e2-1dbcdfe9d9f7_560x548.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!A8dI!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a31c754-4636-45d9-a5e2-1dbcdfe9d9f7_560x548.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!A8dI!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a31c754-4636-45d9-a5e2-1dbcdfe9d9f7_560x548.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!A8dI!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a31c754-4636-45d9-a5e2-1dbcdfe9d9f7_560x548.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>If an interviewer hands you a system design problem involving data distribution, use these strict heuristics to drop the right tool for the job:</p><ul><li><p><strong>Use a Classic Hash Ring (+ VNodes)</strong> if you are deploying general-purpose distributed databases or stateful caching tiers (like Redis, Memcached, Amazon Dynamo, or Apache Cassandra). This is the correct choice when nodes flip offline unpredictably and you need your data to safely slide clockwise to the next available machine without manual intervention.</p></li><li><p><strong>Use Rendezvous Hashing (Highest Random Weight)</strong> if you are building high-throughput edge proxy networks, API gateways, or stateless load-balancing layers. It completely eliminates the memory synchronization overhead of traditional rings, making it the perfect choice for routing traffic across smaller, fast-changing server pools where <span>O(N)</span> CPU calculations won&#8217;t hurt you.</p></li><li><p><strong>Use Jump Consistent Hash</strong> if you are operating massive, sequentially numbered storage shards (like append-only cold storage, data lakes, or massive log aggregators) where you only scale up by adding nodes to the very end of the cluster. It provides blazing-fast lookups with absolute zero memory consumption.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Consistent hashing: consistent hashing & virtual nodes ]]></title><description><![CDATA[Master the core algorithm behind decentralized data distribution. Learn how hash rings minimize data movement during node scaling, and how virtual nodes eliminate skew and hotspotting in production]]></description><link>https://saifhatem.substack.com/p/consistent-hashing-consistent-hashing</link><guid isPermaLink="false">https://saifhatem.substack.com/p/consistent-hashing-consistent-hashing</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Mon, 29 Jun 2026 06:52:35 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!kGek!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1>Introduction</h1><p>When you scale an application horizontally by adding more servers, you need a way to distribute the data evenly across them.</p><p>Without a good distribution strategy, you risk creating hotspots, that is where a single server handles a massive amount of traffic while the other nodes sit idle.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design Horizon! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>This is the problem <strong>Consistent Hashing</strong> solves. It ensures that data load is balanced properly, even when servers are added or removed from the system.<br></p><h2>The Naive Solution: Rehashing</h2><p>A standard approach to distributing data is using a hash function. You take an input key, generate its hash value, and use the modulo operator to determine which server it belongs to.</p><blockquote><p><strong>What is a Hash Value?</strong>  </p><p>A fixed-length string of characters generated by running data through an algorithm like SHA-256. It essentially turns any input into a unique, predictable number, in our case, it is a key</p></blockquote><p>If you have <em><span>n</span></em> servers, the formula looks like this:<br></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;server\\_index = hash(key) \\pmod n&quot;,&quot;id&quot;:&quot;FNDFJPAGJP&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>For example, if you have 4 servers (n = 4) and a key hashes to the number 10, the calculation is 10 % 4 = 2. The request goes to Server 2.<br><br>The below image demonstrates how keys are assigned via hashing their value, to their respective server.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!xrdS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!xrdS!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png 424w, /__u/substackcdn.com/image/fetch/$s_!xrdS!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png 848w, /__u/substackcdn.com/image/fetch/$s_!xrdS!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xrdS!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!xrdS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png" width="776" height="507" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:507,&quot;width&quot;:776,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:304811,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/202805814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!xrdS!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png 424w, /__u/substackcdn.com/image/fetch/$s_!xrdS!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png 848w, /__u/substackcdn.com/image/fetch/$s_!xrdS!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xrdS!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fdebd07-acca-41dd-bed3-7b406e5ca2fb_776x507.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h2>Why the Naive Solution Fails</h2><p>In a perfectly static environment where the number of servers <em>N</em> never changes, the modulo approach works flawlessly. Every key consistently hashes to the exact same server, traffic is evenly split, and the system is predictable.</p><p>However, production environments are never static. Servers crash, hardware fails, and engineering teams must scale the cluster up or down to handle fluctuating traffic.</p><p>The catastrophic failure happens because the entire formula depends on <span>N</span>. If you change the number of servers from <span>N</span> to <span>N + 1</span> (scaling up) or <span>N - 1</span> (a server crashes), the denominator in your modulo operation changes.</p><p>Because the math changes, <strong>several keys in your system suddenly maps to a completely different server.<br><br>In the below example, server 0 crashes, now we only have 3 servers, our n becomes 3, we use the above formula to recalculate the hash modulo for each key:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!9YrE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cd62d5e-6697-4983-b275-f771ec928913_776x537.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!9YrE!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cd62d5e-6697-4983-b275-f771ec928913_776x537.png 424w, /__u/substackcdn.com/image/fetch/$s_!9YrE!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cd62d5e-6697-4983-b275-f771ec928913_776x537.png 848w, /__u/substackcdn.com/image/fetch/$s_!9YrE!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cd62d5e-6697-4983-b275-f771ec928913_776x537.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9YrE!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cd62d5e-6697-4983-b275-f771ec928913_776x537.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!9YrE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cd62d5e-6697-4983-b275-f771ec928913_776x537.png" width="776" height="537" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6cd62d5e-6697-4983-b275-f771ec928913_776x537.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:537,&quot;width&quot;:776,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:318441,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/202805814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cd62d5e-6697-4983-b275-f771ec928913_776x537.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!9YrE!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cd62d5e-6697-4983-b275-f771ec928913_776x537.png 424w, /__u/substackcdn.com/image/fetch/$s_!9YrE!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cd62d5e-6697-4983-b275-f771ec928913_776x537.png 848w, /__u/substackcdn.com/image/fetch/$s_!9YrE!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cd62d5e-6697-4983-b275-f771ec928913_776x537.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9YrE!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cd62d5e-6697-4983-b275-f771ec928913_776x537.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>As you can see in the picture above, keys 0, 2, 3 and 5 have been reassigned, that&#8217;s a lot of reassigning and it is computationally costly!</p><p>In this demo example, 50% of the keys moved. In a real&#8209;world system with thousands of keys, changing N causes roughly N/(N+1) of your data to remap. If you scale from 9 servers to 10, 90% of your keys will suddenly point to the wrong server.</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot; \\text{% of keys Remapped} = \\frac{N}{N+1} &quot;,&quot;id&quot;:&quot;LUDHXTZWRU&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>When 90% of your keys suddenly point to the wrong location, it triggers a chain reaction of production failures:</p><ul><li><p><strong>Cache Miss Storm:</strong> Your application requests data, looks at the new server destination dictated by the new math, and finds nothing there. The cache is effectively wiped clean instantly.</p></li><li><p><strong>Database Cascading Failure:</strong> Because the cache servers return empty results, your application is forced to query your backend database for the missing data. Databases are not built to handle this sudden, massive spike in traffic and can easily crash under the load.</p></li><li><p><strong>Network Choke:</strong> If you try to prevent the cache misses by actively moving the data to its new rightful servers, you trigger a massive data migration. Moving terabytes of data across the network all at once consumes your bandwidth, spikes latency, and degrades the user experience.</p></li></ul><p>In short, a simple architecture tweak like adding a server to handle <em>more</em> traffic will ironically take your entire system offline.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!xmIK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!xmIK!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png 424w, /__u/substackcdn.com/image/fetch/$s_!xmIK!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png 848w, /__u/substackcdn.com/image/fetch/$s_!xmIK!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xmIK!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!xmIK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png" width="1456" height="1476" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1476,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1930563,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/202805814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!xmIK!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png 424w, /__u/substackcdn.com/image/fetch/$s_!xmIK!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png 848w, /__u/substackcdn.com/image/fetch/$s_!xmIK!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xmIK!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4125355d-bf3f-4551-a6ce-fc906d488b67_2160x2190.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>The Core Solution: The Hash Ring</h2><p>To solve the problem that was described above, we have to <strong>decouple data distribution from the total number of servers</strong> <span>N</span>. This is achieved through <strong>Consistent Hashing</strong>, a technique introduced in 1997 by Karger et al. at MIT.<br><br>Instead of using the modulo operator to assign keys directly to servers, Consistent Hashing uses a conceptual structure known as a <strong>Hash Ring</strong></p><h3>Creating and Wrapping the Hash Space</h3><p>A standard hash function (like SHA-1 or MD5) outputs a massive range of integer values. For example, if a hash function outputs values from <span>0</span> to <span>2^{32} - 1</span>, we take that linear line of numbers and bend it into a circle. The largest value (<span>2^{32} - 1</span>) wraps around to connect directly back to <span>0</span>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!YCfc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!YCfc!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png 424w, /__u/substackcdn.com/image/fetch/$s_!YCfc!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png 848w, /__u/substackcdn.com/image/fetch/$s_!YCfc!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png 1272w, /__u/substackcdn.com/image/fetch/$s_!YCfc!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!YCfc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png" width="1025" height="425" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:425,&quot;width&quot;:1025,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:172421,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/202805814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!YCfc!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png 424w, /__u/substackcdn.com/image/fetch/$s_!YCfc!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png 848w, /__u/substackcdn.com/image/fetch/$s_!YCfc!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png 1272w, /__u/substackcdn.com/image/fetch/$s_!YCfc!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dda8750-cfcc-427a-bf3a-97c9a1fdbab6_1025x425.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Mapping Servers and Keys Together</h3><p>In traditional hashing, you only hash the keys. In Consistent Hashing, you map <strong>both</strong> the servers and the data keys onto this exact same circular ring.</p><ol><li><p><strong>Servers:</strong> You hash a server&#8217;s unique identifier (like its IP address or host name, e.g., <code>hash("Server_A")</code>) to get a number, and place the server at that position on the ring.</p></li><li><p><strong>Keys:</strong> You hash the data keys (e.g., <code>hash("User_123")</code>) using the same hash function, placing them at their corresponding positions on the same ring.</p><p></p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!8ohn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!8ohn!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png 424w, /__u/substackcdn.com/image/fetch/$s_!8ohn!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png 848w, /__u/substackcdn.com/image/fetch/$s_!8ohn!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8ohn!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!8ohn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png" width="1077" height="460" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:460,&quot;width&quot;:1077,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:149485,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/202805814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!8ohn!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png 424w, /__u/substackcdn.com/image/fetch/$s_!8ohn!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png 848w, /__u/substackcdn.com/image/fetch/$s_!8ohn!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8ohn!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30eb8d1-78c9-45f2-9d02-92cbbf2ac962_1077x460.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>The Lookup Rule: Move Clockwise</h3><p>To determine which server owns a particular key, you locate the key on the ring and walk <strong>clockwise</strong> until you encounter the very first server. That server is responsible for storing or routing that key.<br><br>For example, if we move clockwise from key0, we encounter server2 hence key0 belongs to server 2, and key 2 belongs to server 4 and so on&#8230;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!uvjK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58c2c713-2e34-474a-8096-c1404b489598_970x837.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!uvjK!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58c2c713-2e34-474a-8096-c1404b489598_970x837.png 424w, /__u/substackcdn.com/image/fetch/$s_!uvjK!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58c2c713-2e34-474a-8096-c1404b489598_970x837.png 848w, /__u/substackcdn.com/image/fetch/$s_!uvjK!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58c2c713-2e34-474a-8096-c1404b489598_970x837.png 1272w, /__u/substackcdn.com/image/fetch/$s_!uvjK!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58c2c713-2e34-474a-8096-c1404b489598_970x837.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!uvjK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58c2c713-2e34-474a-8096-c1404b489598_970x837.png" width="970" height="837" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/58c2c713-2e34-474a-8096-c1404b489598_970x837.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:837,&quot;width&quot;:970,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:61073,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/202805814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58c2c713-2e34-474a-8096-c1404b489598_970x837.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!uvjK!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58c2c713-2e34-474a-8096-c1404b489598_970x837.png 424w, /__u/substackcdn.com/image/fetch/$s_!uvjK!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58c2c713-2e34-474a-8096-c1404b489598_970x837.png 848w, /__u/substackcdn.com/image/fetch/$s_!uvjK!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58c2c713-2e34-474a-8096-c1404b489598_970x837.png 1272w, /__u/substackcdn.com/image/fetch/$s_!uvjK!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58c2c713-2e34-474a-8096-c1404b489598_970x837.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>The brilliance of the hash ring is that it localizes the impact of topology changes. When a server is added or removed, <strong>only its immediate neighbors on the ring are affected.</strong> The rest of the system remains completely untouched.</p><ul><li><p><strong>When a server crashes:</strong> If a server goes offline, only the keys that were mapping to it are affected. Those keys simply slide clockwise to the next available server on the ring.</p></li><li><p><strong>When a server is added:</strong> If you spin up a new server, it takes a position on the ring. It only steals a subset of keys from the server immediately counter-clockwise to it.</p></li></ul><p>Mathematically, instead of moving almost 100% of your data during a scaling event, you only relocate roughly <span>K/N</span> keys (where <span>K</span> is the total number of keys and <span>N</span> is the total number of servers).</p><p>If you have 10 servers and add an 11th, you only move about <strong>10% of your data</strong>, completely eliminating the cache miss storm.</p><h2>However&#8230; it&#8217;s not without its issues</h2><p>While the hash ring elegant in theory, implementing it naively in production introduces a critical operational flaw: <strong>unequal partition sizes.</strong></p><h3>The Problem with Random Placement</h3><p>When you hash server identifiers (like IP addresses), their distribution on the ring is completely random. Because it is random, the servers will almost never be spaced out evenly.</p><p>Instead of a perfectly balanced pie, you end up with a poorly sliced one. One server might randomly be assigned a massive arc of the ring, while another server covers a tiny sliver.</p><h3>The &#8220;Hotspot&#8221; Problem</h3><p>Because a key&#8217;s destination is determined by walking clockwise to the next server, the amount of data a server manages is directly proportional to the size of the ring segment behind it.</p><p>If Server A is assigned a massive chunk of the ring, it becomes a <strong>Hotspot</strong>:</p><ul><li><p><strong>Traffic Imbalance:</strong> Server A gets crushed by a massive volume of read/write requests simply because it owns too much real estate on the ring.</p></li><li><p><strong>Resource Wastage:</strong> Meanwhile, Server B  &#8212; which sits right after a tiny segment, remains completely idle, wasting expensive compute and storage resources.</p></li><li><p><strong>The Celebrity Effect:</strong> This issue is amplified if a highly popular key (like a viral post or a celebrity profile) happens to land on an already overloaded server segment, potentially causing that specific node to crash under the pressure.</p></li></ul><p>Without a way to ensure uniform distribution across the ring, consistent hashing fails to deliver on its primary promise: a balanced load.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!kGek!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!kGek!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png 424w, /__u/substackcdn.com/image/fetch/$s_!kGek!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png 848w, /__u/substackcdn.com/image/fetch/$s_!kGek!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kGek!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!kGek!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png" width="1222" height="817" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d150348f-156a-482b-b9ac-c20480654e21_1222x817.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:817,&quot;width&quot;:1222,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:182067,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/202805814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!kGek!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png 424w, /__u/substackcdn.com/image/fetch/$s_!kGek!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png 848w, /__u/substackcdn.com/image/fetch/$s_!kGek!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kGek!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd150348f-156a-482b-b9ac-c20480654e21_1222x817.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h2>Virtual Nodes</h2><p>To fix the structural imbalance of the hash ring, we use a technique called <strong>Virtual Nodes</strong> (or vnodes).</p><h3>The Fix: Splitting Servers into Fragments</h3><p>Instead of placing a physical server (&#8221;Server A&#8221;) on the ring a single time, we hash it multiple times using different labels (e.g., <code>hash("Server_A#1")</code>, <code>hash("Server_A#2")</code>, <code>hash("Server_A#3")</code>).</p><p>Each of these hashes creates a &#8220;Virtual Node&#8221; that belongs to the same physical machine. If you give every server 100 or 200 virtual nodes, you go from having 4 massive, randomly spaced blocks on the ring to having 400 or 800 small, interleaved points scattered evenly across the entire circle.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!gAWU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!gAWU!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png 424w, /__u/substackcdn.com/image/fetch/$s_!gAWU!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png 848w, /__u/substackcdn.com/image/fetch/$s_!gAWU!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gAWU!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!gAWU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png" width="1112" height="902" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:902,&quot;width&quot;:1112,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:51908,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/202805814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!gAWU!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png 424w, /__u/substackcdn.com/image/fetch/$s_!gAWU!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png 848w, /__u/substackcdn.com/image/fetch/$s_!gAWU!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gAWU!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b73512-ce09-4056-a351-47ca14d8c62d_1112x902.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>in the example above, each server has its own virtual nodes, that greatly helps in balancing load distribution, by scattering virtual nodes across the ring, you achieve two major benefits:</p><ul><li><p><strong>Uniform Distribution:</strong> Because a physical server&#8217;s territory is broken up into hundreds of tiny slivers spread across the entire ring, the law of large numbers kicks in. The size of the total ring space managed by each physical server balances out, ensuring a uniform distribution of keys. No single server becomes a structural hotspot.</p></li><li><p><strong>Proportional Rebalancing:</strong> If a physical server fails, its virtual nodes disappear from all over the ring. The keys it held don&#8217;t all cascade onto a single downstream neighbor; instead, they are distributed evenly among all the remaining virtual nodes on the ring.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!kCjn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!kCjn!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png 424w, /__u/substackcdn.com/image/fetch/$s_!kCjn!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png 848w, /__u/substackcdn.com/image/fetch/$s_!kCjn!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kCjn!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!kCjn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png" width="1057" height="886" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:886,&quot;width&quot;:1057,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:63250,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/202805814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!kCjn!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png 424w, /__u/substackcdn.com/image/fetch/$s_!kCjn!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png 848w, /__u/substackcdn.com/image/fetch/$s_!kCjn!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kCjn!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b43ba54-d9c0-4bc6-b07c-33fe02612c4d_1057x886.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h3>The Trade-off(Interview Crucial): Balance vs. Memory</h3><p>While virtual nodes solve the distribution problem, they introduce a classic system design trade-off.</p><ul><li><p><strong>The Benefit:</strong> As you increase the number of virtual nodes per server, the data distribution becomes closer to perfectly balanced. For instance, increasing the count to 100&#8211;200 vnodes typically drops the load imbalance (standard deviation) down to a safe <strong>5% to 10%</strong>.</p><blockquote><p>In this context, <strong>standard deviation</strong> is a statistical metric used to measure <strong>how unevenly the data keys are distributed among the physical servers</strong>.</p></blockquote></li><li><p><strong>The Cost:</strong> Every single virtual node must be stored in a lookup table or a balanced binary search tree (like a Red-Black Tree) in memory so the application knows the ring&#8217;s layout. If you have 1,000 physical servers and give each 1,000 virtual nodes, your application now has to maintain and search a data structure with 1 million entries.</p></li></ul><p>In production, engineering teams must find the sweet spot, typically between 100 and 300 virtual nodes per server &#8212; where the load is balanced enough to protect the database, but small enough to fit comfortably in memory with fast <span>O(log M)</span> lookup times.</p><h2>Operations: Adding and Removing Nodes</h2><p>To understand how this works in production, think of data migration as a localized handoff between neighbors rather than a cluster-wide reset.</p><h3>Case 1: Adding a Server (Scaling Up)</h3><p>Let&#8217;s say you have an existing ring and you spin up a new server: <strong>Server 3</strong>.</p><ol><li><p><strong>Placement:</strong> You hash Server 3 (and its virtual nodes), placing them at their designated coordinates on the ring.</p></li><li><p><strong>Finding the Target Keys:</strong> To find out which keys Server 3 is now responsible for, you look <strong>counter-clockwise</strong> from Server 3&#8217;s new position until you hit the next closest server (let&#8217;s say Server 1).</p></li><li><p><strong>The Migration:</strong> The segment of the ring <em>between</em> Server 1 and Server 3 used to belong to whatever node was clockwise of Server 1. Now, Server 3 owns it. Your system walks that specific segment, grabs only those keys, and copies them over the network to Server 3.</p></li></ol><p>The rest of the servers on the ring keep handling traffic normally without losing a single byte of data.</p><h3>Case 2: Removing a Server (Scale-Down or Crash)</h3><p>Now, imagine <strong>Server 2</strong> unexpectedly crashes or you deliberately shut it down to save costs.</p><ol><li><p><strong>Deletions:</strong> Server 2&#8217;s positions are instantly deleted from the ring.</p></li><li><p><strong>The Orphaned Keys:</strong> All the keys that were sitting just behind Server 2 (counter-clockwise to it) are now &#8220;orphaned.&#8221;</p></li><li><p><strong>The Handover:</strong> Because Server 2 is gone, any request looking for those keys will automatically keep traveling <strong>clockwise</strong> right past Server 2&#8217;s old spot until it hits the next available node (Server 1).</p></li><li><p><strong>Re-routing:</strong> Server 4 naturally absorbs that traffic. If this is a caching layer, Server 4 will experience a minor, localized cache miss for just that segment, fetch the fresh data from the database, and write it to its own storage.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!kMNz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!kMNz!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png 424w, /__u/substackcdn.com/image/fetch/$s_!kMNz!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png 848w, /__u/substackcdn.com/image/fetch/$s_!kMNz!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kMNz!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!kMNz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png" width="1087" height="855" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:855,&quot;width&quot;:1087,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:66633,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/202805814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!kMNz!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png 424w, /__u/substackcdn.com/image/fetch/$s_!kMNz!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png 848w, /__u/substackcdn.com/image/fetch/$s_!kMNz!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kMNz!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F001f983b-dd3f-478a-819c-79e7287e8bd6_1087x855.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Summary of Operations</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!QqZE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae517293-7a84-4e35-a575-561670c92007_900x567.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!QqZE!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae517293-7a84-4e35-a575-561670c92007_900x567.png 424w, /__u/substackcdn.com/image/fetch/$s_!QqZE!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae517293-7a84-4e35-a575-561670c92007_900x567.png 848w, /__u/substackcdn.com/image/fetch/$s_!QqZE!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae517293-7a84-4e35-a575-561670c92007_900x567.png 1272w, /__u/substackcdn.com/image/fetch/$s_!QqZE!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae517293-7a84-4e35-a575-561670c92007_900x567.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!QqZE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae517293-7a84-4e35-a575-561670c92007_900x567.png" width="900" height="567" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ae517293-7a84-4e35-a575-561670c92007_900x567.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:567,&quot;width&quot;:900,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:118547,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/202805814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae517293-7a84-4e35-a575-561670c92007_900x567.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!QqZE!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae517293-7a84-4e35-a575-561670c92007_900x567.png 424w, /__u/substackcdn.com/image/fetch/$s_!QqZE!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae517293-7a84-4e35-a575-561670c92007_900x567.png 848w, /__u/substackcdn.com/image/fetch/$s_!QqZE!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae517293-7a84-4e35-a575-561670c92007_900x567.png 1272w, /__u/substackcdn.com/image/fetch/$s_!QqZE!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae517293-7a84-4e35-a575-561670c92007_900x567.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Bonus: Going beyond!</h2><p><strong>Please note that some of the concepts here are advanced and would be discussed in later down the roadmap! </strong><br><br>To close out, here are the real-world trade-offs and advanced architectural use cases that separate textbook knowledge from actual production experience.</p><h3>1. Where It Is Used in Production</h3><p>Consistent Hashing is not an academic theory; it is the core routing backbone for some of the most resilient distributed infrastructure on the planet:</p><ul><li><p><strong>Distributed Databases:</strong> Both <strong>Amazon Dynamo</strong> and <strong>Apache Cassandra</strong> use a hash ring partition strategy to determine which storage node owns a specific row of data. (WILL DISCUSS THIS LATER ON IN DATABASES)</p></li><li><p><strong>Content Delivery Networks (CDNs):</strong> CDNs like <strong>Akamai</strong> use consistent hashing to cache edge assets. It ensures that media files map to the same edge server nearest to the user, maximizing cache hit ratios globally.</p></li></ul><h3>2. Network Load Balancing (The Google SRE Approach)</h3><p>A common misconception is that consistent hashing is only for database rows or cache keys. In reality, Google&#8217;s Site Reliability Engineering (SRE) teams use it at the network layer to distribute raw TCP/UDP connections across a pool of backend microservices.</p><p>If a standard round-robin load balancer loses a backend server, the remaining connections can be violently disrupted or reset as traffic re-shuffles. By using consistent hashing for connection state routing, a backend failure only impacts the active users mapped to that specific node. The rest of the network&#8217;s user sessions remain active, connected, and completely undisturbed.</p><h3>3. The DDIA Critique: Is True Consistent Hashing Overrated?</h3><p>If you are designing a <strong>stateful database</strong> cluster today, you might not actually want a true Karger-style hash ring. As Martin Kleppmann points out in <em>Designing Data-Intensive Applications (DDIA)</em>, the term &#8220;consistent hashing&#8221; is frequently misused by engineers.</p><p>The original MIT design was built for internet-wide web caches (like CDNs) where servers are constantly joining and leaving a highly unpredictable global network.</p><p>Modern databases like <strong>Couchbase</strong> or <strong>Elasticsearch</strong> live in tightly controlled, internal data centers. For these systems, a <strong>Fixed-Number Partition Hashing</strong> strategy is often vastly superior to a true ring:</p><ul><li><p><strong>How it works:</strong> The cluster creates a fixed number of logical partitions (e.g., exactly 1,024 slots) on day one.</p></li><li><p><strong>The Benefit:</strong> Instead of dealing with the randomness of virtual nodes floating around a circle, the engineering team can explicitly assign and move these 1,024 static buckets between physical servers. This makes operational rebalancing deterministic, predictable, and significantly easier to monitor and control.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[How the Internet Actually Works: The OSI Model and Your Troubleshooting Cheat Sheet]]></title><description><![CDATA[OSI vs TCP/IP, layer responsibilities, key protocols per layer and Troubleshooting Framework]]></description><link>https://saifhatem.substack.com/p/how-the-internet-actually-works-the</link><guid isPermaLink="false">https://saifhatem.substack.com/p/how-the-internet-actually-works-the</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Sat, 30 May 2026 16:01:44 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!bvEh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every time you send a message, load a website, or stream a video, your data travels across a invisible chain of technologies. That chain has a name: the <strong>network stack</strong>.</p><p>Two models explain how it works.</p><p>The <strong>OSI Model</strong> (7 layers) is the theoretical blueprint which is great for learning and troubleshooting. <br>The <strong>TCP/IP Stack</strong> (4 layers) is what the internet actually runs on.</p><p>Most engineers memorize both. You don&#8217;t need to. You just need to understand one thing: <strong>data moves down the stack on the way out, and up the stack on the way in</strong>. Each layer has one job. That&#8217;s it.</p><p>In this article, we&#8217;ll walk through both models layer by layer. By the end, you&#8217;ll know exactly where &#8220;the internet broke&#8221; next time it happens.</p><h2><strong>The OSI Model</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!bvEh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!bvEh!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png 424w, /__u/substackcdn.com/image/fetch/$s_!bvEh!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png 848w, /__u/substackcdn.com/image/fetch/$s_!bvEh!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bvEh!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!bvEh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png" width="643" height="412.9129593810445" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:332,&quot;width&quot;:517,&quot;resizeWidth&quot;:643,&quot;bytes&quot;:106823,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/199736208?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!bvEh!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png 424w, /__u/substackcdn.com/image/fetch/$s_!bvEh!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png 848w, /__u/substackcdn.com/image/fetch/$s_!bvEh!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bvEh!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F970bd9d7-3544-4688-a6be-57ba7122ec0c_517x332.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>Layer 7: Application</strong></h3><p><strong>Job:</strong> Interface between the network and the software you actually use.</p><p>This is the layer you see, every protocol your browser and apps speak lives here. When you type a URL and press Enter, the browser is operating at Layer 7.</p><p>Key protocols: <code>HTTP/HTTPS</code>, <code>DNS</code>, <code>SMTP</code>, <code>FTP</code>, <code>WebSocket</code>, <code>gRPC</code></p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!mkgf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb76fffa-40c9-494a-a88f-ee8ea25860d7_5667x1642.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!mkgf!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb76fffa-40c9-494a-a88f-ee8ea25860d7_5667x1642.png 424w, /__u/substackcdn.com/image/fetch/$s_!mkgf!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb76fffa-40c9-494a-a88f-ee8ea25860d7_5667x1642.png 848w, /__u/substackcdn.com/image/fetch/$s_!mkgf!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb76fffa-40c9-494a-a88f-ee8ea25860d7_5667x1642.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mkgf!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb76fffa-40c9-494a-a88f-ee8ea25860d7_5667x1642.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!mkgf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb76fffa-40c9-494a-a88f-ee8ea25860d7_5667x1642.png" width="1456" height="422" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fb76fffa-40c9-494a-a88f-ee8ea25860d7_5667x1642.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:422,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;OSI Model: Layer 7 &#8212; The Application Layer | by Walid ...&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="OSI Model: Layer 7 &#8212; The Application Layer | by Walid ..." title="OSI Model: Layer 7 &#8212; The Application Layer | by Walid ..." srcset="/__u/substackcdn.com/image/fetch/$s_!mkgf!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb76fffa-40c9-494a-a88f-ee8ea25860d7_5667x1642.png 424w, /__u/substackcdn.com/image/fetch/$s_!mkgf!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb76fffa-40c9-494a-a88f-ee8ea25860d7_5667x1642.png 848w, /__u/substackcdn.com/image/fetch/$s_!mkgf!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb76fffa-40c9-494a-a88f-ee8ea25860d7_5667x1642.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mkgf!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb76fffa-40c9-494a-a88f-ee8ea25860d7_5667x1642.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>A common confusion: <strong>Layer 7 doesn&#8217;t know about IP addresses or ports</strong>. It just knows &#8220;I need to GET this resource.&#8221; The layers below handle the routing.</p><blockquote><p><strong>Troubleshooting tip:</strong> If a site loads but specific content fails, you&#8217;re looking at a Layer 7 problem like a bad endpoint, broken API, wrong headers.</p></blockquote><p></p><h3><strong>Layer 6: Presentation</strong></h3><p><strong>Job:</strong> Translate data into a format both sides(upper and lower layers) understand.</p><p>Its three responsibilities are encryption, encoding, and compression.</p><ul><li><p><strong>Encryption/Decryption</strong> &#8594; TLS/SSL lives here conceptually (though in practice it straddles 5 and 6)</p></li><li><p><strong>Encoding</strong> &#8594; UTF-8, ASCII, JPEG, MP4</p></li><li><p><strong>Compression</strong> &#8594; gzip, Brotli</p></li></ul><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!RubQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc6234d5-c002-4596-9b7d-9132d604ef15_594x239.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!RubQ!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc6234d5-c002-4596-9b7d-9132d604ef15_594x239.png 424w, /__u/substackcdn.com/image/fetch/$s_!RubQ!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc6234d5-c002-4596-9b7d-9132d604ef15_594x239.png 848w, /__u/substackcdn.com/image/fetch/$s_!RubQ!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc6234d5-c002-4596-9b7d-9132d604ef15_594x239.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RubQ!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc6234d5-c002-4596-9b7d-9132d604ef15_594x239.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!RubQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc6234d5-c002-4596-9b7d-9132d604ef15_594x239.png" width="594" height="239" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fc6234d5-c002-4596-9b7d-9132d604ef15_594x239.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:239,&quot;width&quot;:594,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;What is OSI Model | 7 Layers Explained | Imperva&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="What is OSI Model | 7 Layers Explained | Imperva" title="What is OSI Model | 7 Layers Explained | Imperva" srcset="/__u/substackcdn.com/image/fetch/$s_!RubQ!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc6234d5-c002-4596-9b7d-9132d604ef15_594x239.png 424w, /__u/substackcdn.com/image/fetch/$s_!RubQ!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc6234d5-c002-4596-9b7d-9132d604ef15_594x239.png 848w, /__u/substackcdn.com/image/fetch/$s_!RubQ!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc6234d5-c002-4596-9b7d-9132d604ef15_594x239.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RubQ!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc6234d5-c002-4596-9b7d-9132d604ef15_594x239.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>When your browser negotiates HTTPS and both sides agree on TLS 1.3, that handshake is a Layer 6 concern <strong>at heart</strong> even if modern implementations blur the lines.</p><h3><strong>Layer 5: Session<br></strong></h3><p><strong>Job:</strong> Manage the lifecycle of a conversation between two systems.</p><p>A <em>session</em> is the setup, maintenance, and teardown of a <strong>communication channel</strong>. Think of it as the call manager it dials, keeps the line open, and hangs up cleanly.</p><p>Key concerns: session authentication, reconnection, full-duplex vs. half-duplex, session tokens.<br><br>Below is a diagram of a session (lifecycle, from when a session is requested until its closure).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!WKmN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!WKmN!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png 424w, /__u/substackcdn.com/image/fetch/$s_!WKmN!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png 848w, /__u/substackcdn.com/image/fetch/$s_!WKmN!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png 1272w, /__u/substackcdn.com/image/fetch/$s_!WKmN!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!WKmN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png" width="342" height="578" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:578,&quot;width&quot;:342,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:26160,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/199736208?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!WKmN!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png 424w, /__u/substackcdn.com/image/fetch/$s_!WKmN!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png 848w, /__u/substackcdn.com/image/fetch/$s_!WKmN!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png 1272w, /__u/substackcdn.com/image/fetch/$s_!WKmN!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcdef727-5314-4a8a-ae80-01ffcc0e0173_342x578.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>In web terms: when you log into an app and stay logged in across<strong> page refreshes</strong>, a session layer mechanism (cookie, JWT, session ID) is doing that work.</p><blockquote><p><strong>Note:</strong> In TCP/IP(later in the article), Sessions 5, Presentation 6, and Application 7 are all collapsed into one &#8220;Application&#8221; layer. Real implementations don&#8217;t enforce clean separations here. The OSI labels are useful for <em>reasoning</em>, not for counting actual modules in code.</p></blockquote><p>With that being said, it is important to understand the difference between <strong>duplex controls, </strong>the diagram below illustrates such differences.<br></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!jgH9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc3b1f83-f6e3-4f82-82b1-d240ed28780e_272x185.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!jgH9!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc3b1f83-f6e3-4f82-82b1-d240ed28780e_272x185.png 424w, /__u/substackcdn.com/image/fetch/$s_!jgH9!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc3b1f83-f6e3-4f82-82b1-d240ed28780e_272x185.png 848w, /__u/substackcdn.com/image/fetch/$s_!jgH9!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc3b1f83-f6e3-4f82-82b1-d240ed28780e_272x185.png 1272w, /__u/substackcdn.com/image/fetch/$s_!jgH9!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc3b1f83-f6e3-4f82-82b1-d240ed28780e_272x185.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!jgH9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc3b1f83-f6e3-4f82-82b1-d240ed28780e_272x185.png" width="404" height="274.77941176470586" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bc3b1f83-f6e3-4f82-82b1-d240ed28780e_272x185.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:185,&quot;width&quot;:272,&quot;resizeWidth&quot;:404,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;OSI: Session Layer - Layer 5 (Part 4)&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="OSI: Session Layer - Layer 5 (Part 4)" title="OSI: Session Layer - Layer 5 (Part 4)" srcset="/__u/substackcdn.com/image/fetch/$s_!jgH9!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc3b1f83-f6e3-4f82-82b1-d240ed28780e_272x185.png 424w, /__u/substackcdn.com/image/fetch/$s_!jgH9!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc3b1f83-f6e3-4f82-82b1-d240ed28780e_272x185.png 848w, /__u/substackcdn.com/image/fetch/$s_!jgH9!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc3b1f83-f6e3-4f82-82b1-d240ed28780e_272x185.png 1272w, /__u/substackcdn.com/image/fetch/$s_!jgH9!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc3b1f83-f6e3-4f82-82b1-d240ed28780e_272x185.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Simplex</strong> is one-way communication only (like a TV broadcast). <strong>Half-duplex</strong> allows two-way communication but not at the same time, devices take turns, like a walkie-talkie. <strong>Full-duplex</strong> allows two-way simultaneous communication, like a phone call or modern Ethernet. In networking, <strong>full-duplex</strong> is the standard for speed and efficiency, half-duplex is legacy or wireless collision-prone, and simplex is rarely used except for one-directional data feeds, such as monitoring.</p><h3><strong>Layer 4: Transport</strong></h3><p><strong>Job:</strong> Reliable (or fast) delivery of data between two endpoints.</p><p>This is where two of the most important protocols in networking live: <strong>TCP</strong> and <strong>UDP</strong>. And the <strong>difference between them is the single most important tradeoff in network engineering and system design</strong></p><p>Here&#8217;s the simplest way to think about it:</p><p><strong>TCP</strong> is like a registered letter. You get a receipt. You know it arrived. If it doesn&#8217;t, someone sends it again. Everything shows up in order, exactly once. The cost? It&#8217;s slower and requires a conversation before anything happens.</p><p><strong>UDP</strong> is like tossing a postcard into a mailbox. You have no idea if it arrives. There&#8217;s no receipt, no confirmation, no retry. But it&#8217;s fast. Really fast. And you don&#8217;t waste time shaking hands before sending.</p><p>That&#8217;s the tradeoff: <strong>reliability vs. speed.</strong></p><p><strong>TCP</strong> (Transmission Control Protocol):</p><ul><li><p><strong>Three-way handshake</strong> before any data moves</p></li><li><p>Segments are numbered, lost ones are retransmitted</p></li><li><p>In-order delivery guaranteed</p></li><li><p>Used by: HTTP/HTTPS, SMTP, SSH</p></li><li><p>Handles segmentation and reassembly of data</p></li><li><p>Provides flow control (sliding window)</p></li><li><p>Ensures error recovery and end-to-end communication</p></li></ul><p>The diagram below shows how TCP works, see below diagram for more explanation.</p><p>TCP is a reliable, connection-oriented protocol. It ensures every byte of data is delivered in the correct order. If data is lost, TCP resends it automatically.</p><blockquote><p><strong>Use TCP for:</strong> Web browsing (HTTP), email (SMTP), file transfers (FTP), SSH &#8212; anything <strong>where data loss is unacceptable</strong>.</p></blockquote><p><strong>UDP</strong> (User Datagram Protocol):</p><p><strong>Overview</strong><br>UDP is a simple, fast, connectionless protocol. It sends datagrams without any setup, acknowledgments, or retransmissions. It provides <strong>no guarantees</strong>, data may be lost, duplicated, or arrive out of order.</p><blockquote><p><strong>Use UDP for:</strong> Live video streaming, VoIP calls, online gaming, DNS queries  situations where speed matters more than perfect reliability, and occasional loss is acceptable.</p></blockquote><p>The rule of thumb: <strong>if losing a packet matters, use TCP. If losing a packet is cheaper than the delay of retrying, use UDP.</strong></p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!4vvf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F917e5c92-d770-4670-bd7d-50de5a1fa8bd_609x393.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!4vvf!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F917e5c92-d770-4670-bd7d-50de5a1fa8bd_609x393.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!4vvf!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F917e5c92-d770-4670-bd7d-50de5a1fa8bd_609x393.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!4vvf!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F917e5c92-d770-4670-bd7d-50de5a1fa8bd_609x393.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!4vvf!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F917e5c92-d770-4670-bd7d-50de5a1fa8bd_609x393.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!4vvf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F917e5c92-d770-4670-bd7d-50de5a1fa8bd_609x393.jpeg" width="609" height="393" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/917e5c92-d770-4670-bd7d-50de5a1fa8bd_609x393.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:393,&quot;width&quot;:609,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;TCP vs. UDP &#8212; What's the Difference and Which Protocol is Faster?&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="TCP vs. UDP &#8212; What's the Difference and Which Protocol is Faster?" title="TCP vs. UDP &#8212; What's the Difference and Which Protocol is Faster?" srcset="/__u/substackcdn.com/image/fetch/$s_!4vvf!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F917e5c92-d770-4670-bd7d-50de5a1fa8bd_609x393.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!4vvf!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F917e5c92-d770-4670-bd7d-50de5a1fa8bd_609x393.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!4vvf!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F917e5c92-d770-4670-bd7d-50de5a1fa8bd_609x393.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!4vvf!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F917e5c92-d770-4670-bd7d-50de5a1fa8bd_609x393.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!4l9F!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!4l9F!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png 424w, /__u/substackcdn.com/image/fetch/$s_!4l9F!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png 848w, /__u/substackcdn.com/image/fetch/$s_!4l9F!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4l9F!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!4l9F!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png" width="943" height="340" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:340,&quot;width&quot;:943,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:34045,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/199736208?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!4l9F!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png 424w, /__u/substackcdn.com/image/fetch/$s_!4l9F!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png 848w, /__u/substackcdn.com/image/fetch/$s_!4l9F!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4l9F!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84868935-30e1-42bb-a391-b5a8c67e1739_943x340.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="callout-block" data-callout="true"><p>Ordering means the bytes are sent in the correct sequence, this ensures that if there was a packet dropped in the middle of the connection, it would be able to know that such an event occurred and hence retransmits the dropped byte</p><p><em>This was a simplified view on both protocols, I will do deep dive in a later article. </em></p></div><p></p><p>Layer 4 also introduces <strong>ports</strong>  the mechanism that lets one machine run multiple network services simultaneously. Port 80 is HTTP. Port 443 is HTTPS. Port 22 is SSH. A port is just a number (0&#8211;65535) that the OS uses to route an incoming packet to the right process.</p><blockquote><p><strong>Troubleshooting tip:</strong> &#8220;Connection refused&#8221; is a Layer 4 message, the host is reachable but nothing is listening on that port. &#8220;Connection timed out&#8221; usually means Layer 3 or a firewall dropped the packet before it got there. (next layer in the article)</p></blockquote><h3><strong>Layer 3: Network </strong></h3><p><strong>Job:</strong> Route packets from source to destination across multiple networks.</p><p>This is the IP layer. Every device on the internet has an IP address, and Layer 3 is responsible for taking a packet and figuring out the path it needs to travel to get from one IP to another.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!sgOI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2482da39-6629-4043-9c95-0e658df7a357_1146x627.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!sgOI!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2482da39-6629-4043-9c95-0e658df7a357_1146x627.png 424w, /__u/substackcdn.com/image/fetch/$s_!sgOI!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2482da39-6629-4043-9c95-0e658df7a357_1146x627.png 848w, /__u/substackcdn.com/image/fetch/$s_!sgOI!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2482da39-6629-4043-9c95-0e658df7a357_1146x627.png 1272w, /__u/substackcdn.com/image/fetch/$s_!sgOI!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2482da39-6629-4043-9c95-0e658df7a357_1146x627.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!sgOI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2482da39-6629-4043-9c95-0e658df7a357_1146x627.png" width="1146" height="627" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2482da39-6629-4043-9c95-0e658df7a357_1146x627.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:627,&quot;width&quot;:1146,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:672437,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/199736208?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2482da39-6629-4043-9c95-0e658df7a357_1146x627.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!sgOI!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2482da39-6629-4043-9c95-0e658df7a357_1146x627.png 424w, /__u/substackcdn.com/image/fetch/$s_!sgOI!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2482da39-6629-4043-9c95-0e658df7a357_1146x627.png 848w, /__u/substackcdn.com/image/fetch/$s_!sgOI!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2482da39-6629-4043-9c95-0e658df7a357_1146x627.png 1272w, /__u/substackcdn.com/image/fetch/$s_!sgOI!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2482da39-6629-4043-9c95-0e658df7a357_1146x627.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>Key protocols: <code>IP (v4/v6)</code>, <code>ICMP</code> (used by <code>ping</code>), <code>OSPF</code>, <code>BGP</code></p><p><strong>IP addresses</strong> identify <em>where</em> a device is on the network &#8212; specifically, which network and which host within it. <strong>Routers</strong> operate at Layer 3. Their entire job is to read the destination IP on a packet and decide which direction to send it next.</p><p><strong>IP is unreliable by design.</strong> It doesn&#8217;t guarantee delivery, doesn&#8217;t guarantee order, doesn&#8217;t track whether packets arrived. That&#8217;s Layer 4&#8217;s problem. IP just routes.</p><blockquote><p><strong>Troubleshooting tip:</strong> <code>ping</code> uses ICMP, a Layer 3 protocol. If <code>ping</code> fails, you have a routing or IP-level problem. If <code>ping</code> succeeds but TCP connections fail, the issue is at Layer 4 or above.</p></blockquote><h3><strong>Layer 2: Data link </strong></h3><p><strong>Job:</strong> Transfer data between two <em>directly connected</em> nodes on the same network.</p><p>Where Layer 3 handles routing across the internet, Layer 2 handles the hop-to-hop transfer within a local network. Your laptop to your router? Layer 2. Two servers in the same datacenter rack? Layer 2.</p><p>This layer introduces <strong>MAC addresses</strong>, hardware-level identifiers burned into every network interface card. While IP addresses are logical and can change, MAC addresses are (in theory) fixed to the device.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Y38H!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52383a9-14dd-473c-80bd-758f05b623dd_996x482.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Y38H!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52383a9-14dd-473c-80bd-758f05b623dd_996x482.png 424w, /__u/substackcdn.com/image/fetch/$s_!Y38H!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52383a9-14dd-473c-80bd-758f05b623dd_996x482.png 848w, /__u/substackcdn.com/image/fetch/$s_!Y38H!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52383a9-14dd-473c-80bd-758f05b623dd_996x482.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Y38H!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52383a9-14dd-473c-80bd-758f05b623dd_996x482.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Y38H!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52383a9-14dd-473c-80bd-758f05b623dd_996x482.png" width="996" height="482" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d52383a9-14dd-473c-80bd-758f05b623dd_996x482.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:482,&quot;width&quot;:996,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:484956,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/199736208?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52383a9-14dd-473c-80bd-758f05b623dd_996x482.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Y38H!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52383a9-14dd-473c-80bd-758f05b623dd_996x482.png 424w, /__u/substackcdn.com/image/fetch/$s_!Y38H!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52383a9-14dd-473c-80bd-758f05b623dd_996x482.png 848w, /__u/substackcdn.com/image/fetch/$s_!Y38H!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52383a9-14dd-473c-80bd-758f05b623dd_996x482.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Y38H!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52383a9-14dd-473c-80bd-758f05b623dd_996x482.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>Key protocols: <code>Ethernet</code>, <code>Wi-Fi (802.11)</code>, <code>ARP</code></p><p><strong>ARP (Address Resolution Protocol)</strong> is the bridge between Layer 2 and Layer 3, it answers the question &#8220;I have an IP address, what&#8217;s the MAC address I need to actually deliver this frame?&#8221; It broadcasts on the local network and the device with that IP responds with its MAC.</p><p><strong>Error handling:</strong><br>Layer 2 can detect corrupted frames using a checksum (CRC). If a frame is bad, it gets discarded. But Layer 2 doesn't fix the error, that's up to higher layers (like TCP) to notice something's missing and ask for a retransmit.</p><h3><strong>Layer 1: Physical</strong></h3><p>Job: Transmit raw bits over a physical medium.</p><p>Voltage levels on copper cable. Light pulses on fiber optic. Radio waves through air. This layer doesn&#8217;t know about frames, packets, or addresses. It just knows: <em>0</em> and <em>1</em>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!MXP5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F239efee4-812a-4251-8fe7-70808e7c7708_800x401.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!MXP5!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F239efee4-812a-4251-8fe7-70808e7c7708_800x401.webp 424w, /__u/substackcdn.com/image/fetch/$s_!MXP5!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F239efee4-812a-4251-8fe7-70808e7c7708_800x401.webp 848w, /__u/substackcdn.com/image/fetch/$s_!MXP5!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F239efee4-812a-4251-8fe7-70808e7c7708_800x401.webp 1272w, /__u/substackcdn.com/image/fetch/$s_!MXP5!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F239efee4-812a-4251-8fe7-70808e7c7708_800x401.webp 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!MXP5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F239efee4-812a-4251-8fe7-70808e7c7708_800x401.webp" width="800" height="401" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/239efee4-812a-4251-8fe7-70808e7c7708_800x401.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:401,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Layers of OSI Model - GeeksforGeeks&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Layers of OSI Model - GeeksforGeeks" title="Layers of OSI Model - GeeksforGeeks" srcset="/__u/substackcdn.com/image/fetch/$s_!MXP5!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F239efee4-812a-4251-8fe7-70808e7c7708_800x401.webp 424w, /__u/substackcdn.com/image/fetch/$s_!MXP5!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F239efee4-812a-4251-8fe7-70808e7c7708_800x401.webp 848w, /__u/substackcdn.com/image/fetch/$s_!MXP5!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F239efee4-812a-4251-8fe7-70808e7c7708_800x401.webp 1272w, /__u/substackcdn.com/image/fetch/$s_!MXP5!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F239efee4-812a-4251-8fe7-70808e7c7708_800x401.webp 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Key hardware: cables, hubs, repeaters, fiber transceivers, antennas.</p><p>This is where physical reality intersects with software. Every abstraction above this layer ultimately reduces to electrons moving down wire.<strong> </strong></p><h3><strong>The TCP/IP Model vs OSI</strong></h3><p>You&#8217;ve just walked through the <strong>OSI Model</strong> (7 layers). It&#8217;s perfect for learning, layer-by-layer logic.</p><p>The <strong>TCP/IP Stack</strong> (4 layers) is what your laptop, phone, and every server actually run. It collapses OSI&#8217;s top three (Application, Presentation, Session) into a single <strong>Application Layer</strong>. Below that, it keeps Transport, Network, and Link/Physical. (Called Network Interface)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!qXiP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20964a99-ba27-4fa5-9178-636f180ffb5f_651x372.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!qXiP!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20964a99-ba27-4fa5-9178-636f180ffb5f_651x372.png 424w, /__u/substackcdn.com/image/fetch/$s_!qXiP!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20964a99-ba27-4fa5-9178-636f180ffb5f_651x372.png 848w, /__u/substackcdn.com/image/fetch/$s_!qXiP!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20964a99-ba27-4fa5-9178-636f180ffb5f_651x372.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qXiP!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20964a99-ba27-4fa5-9178-636f180ffb5f_651x372.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!qXiP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20964a99-ba27-4fa5-9178-636f180ffb5f_651x372.png" width="651" height="372" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/20964a99-ba27-4fa5-9178-636f180ffb5f_651x372.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:372,&quot;width&quot;:651,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;TCP/IP Network Model &#8211; Techprodezza&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="TCP/IP Network Model &#8211; Techprodezza" title="TCP/IP Network Model &#8211; Techprodezza" srcset="/__u/substackcdn.com/image/fetch/$s_!qXiP!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20964a99-ba27-4fa5-9178-636f180ffb5f_651x372.png 424w, /__u/substackcdn.com/image/fetch/$s_!qXiP!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20964a99-ba27-4fa5-9178-636f180ffb5f_651x372.png 848w, /__u/substackcdn.com/image/fetch/$s_!qXiP!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20964a99-ba27-4fa5-9178-636f180ffb5f_651x372.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qXiP!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20964a99-ba27-4fa5-9178-636f180ffb5f_651x372.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Why this matters for troubleshooting:</strong><br>In OSI, you can blame Layer 6 (encryption) or Layer 5 (session). In TCP/IP, those both just become &#8220;the application layer.&#8221; Real debug tools (like <code>curl</code>, <code>openssl</code>, browser devtools) still distinguish them but the running stack doesn&#8217;t enforce a clean split.</p><h3><strong>Outbound vs. Inbound Paths</strong></h3><p>Regardless of which model you use, remember this:</p><ul><li><p><strong>Outbound data (sending):</strong><br>Data moves <strong>down</strong> the stack.<br><em>Browser &#8594; HTTP (L7) &#8594; TLS (L6) &#8594; session cookies (L5) &#8594; TCP (L4) &#8594; IP (L3) &#8594; Ethernet (L2) &#8594; wire (L1)</em></p></li><li><p><strong>Inbound data (receiving):</strong><br>Data moves <strong>up</strong> the stack.<br><em>Wire &#8594; L1 &#8594; L2 (checks MAC) &#8594; L3 (checks IP) &#8594; L4 (checks port) &#8594; L5&#8211;7 (reassembles request)</em></p></li></ul><p>Each layer on the way <strong>out</strong> adds its own header (encapsulation).<br>Each layer on the way <strong>in</strong> strips its header and passes the rest upward.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!hgHe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff08273dc-fdbb-4291-9687-29e744bbe349_1200x855.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!hgHe!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff08273dc-fdbb-4291-9687-29e744bbe349_1200x855.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!hgHe!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff08273dc-fdbb-4291-9687-29e744bbe349_1200x855.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!hgHe!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff08273dc-fdbb-4291-9687-29e744bbe349_1200x855.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!hgHe!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff08273dc-fdbb-4291-9687-29e744bbe349_1200x855.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!hgHe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff08273dc-fdbb-4291-9687-29e744bbe349_1200x855.jpeg" width="1200" height="855" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f08273dc-fdbb-4291-9687-29e744bbe349_1200x855.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:855,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Inbound vs Outbound Traffic in Cloud Computing: A Complete Guide | by Rohan  Mistry | DevOps.dev&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Inbound vs Outbound Traffic in Cloud Computing: A Complete Guide | by Rohan  Mistry | DevOps.dev" title="Inbound vs Outbound Traffic in Cloud Computing: A Complete Guide | by Rohan  Mistry | DevOps.dev" srcset="/__u/substackcdn.com/image/fetch/$s_!hgHe!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff08273dc-fdbb-4291-9687-29e744bbe349_1200x855.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!hgHe!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff08273dc-fdbb-4291-9687-29e744bbe349_1200x855.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!hgHe!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff08273dc-fdbb-4291-9687-29e744bbe349_1200x855.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!hgHe!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff08273dc-fdbb-4291-9687-29e744bbe349_1200x855.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Where this saves you:</strong><br>If a webpage loads but images are broken &#8594; data got up to L7, but the application layer is missing something (wrong URL, bad API call).<br>If <code>ping</code> works but <code>curl</code> fails &#8594; data made it up to L3, but failed at L4 (port closed) or above.</p><p>You don&#8217;t need to memorize all seven layers cold. You just need to know: <em>start at the symptom, ask which layer handles that job, then move up or down from there.</em></p><h2><strong>The Troubleshooting Framework</strong></h2><p>Now we&#8217;ve went through<strong> </strong>each layer in detail, its time to take a look on how one can diagnose a failing connection/program, there are many ways to do so, but I prefer a structured framework to help facilitate the process, especially in system design interviews.</p><p>So what are the steps? The framework drills down layer by layer, each question ruling out everything below it.</p><p><strong>Entry point: &#8220;System is broken&#8221;</strong> You have a failure. You know nothing else yet. First move is always <code>ping</code>.</p><p><strong>Q1: Can you ping the host?</strong></p><p><code>ping</code> sends an ICMP packet, a pure Layer 3 probe. It bypasses TCP, TLS, sessions, everything. If it fails, your problem is L3 or below. If it succeeds, your problem is L4 or above. <strong>This single question cuts the stack in half.</strong></p><p><strong>Ping fails: climb down to find the floor</strong></p><p><strong>Q2: Is the NIC(Network Interface Card) up?</strong> Run <code>ip link</code> or <code>ifconfig</code>. If the interface shows DOWN or doesn&#8217;t appear at all, you never left the machine. This is a Layer 1 / Physical failure: dead NIC, bad driver, unplugged cable, dead switch port. Nothing network-related works until hardware is fixed.</p><p><strong>Q3 (if NIC is up): Does ARP resolve?</strong> Run <code>arp -n</code> or <code>arping</code>. ARP maps an IP address to a MAC address, it&#8217;s the handshake between Layer 3 (IP) and Layer 2 (Ethernet). If ARP fails, your packet can&#8217;t get addressed for the next hop. This is a Layer 2 / Data Link failure: misconfigured switch, wrong VLAN, MAC table poisoned, broadcast domain issue.</p><p><strong>Q4 (if ARP resolves): Does a route exist?</strong> Run <code>traceroute</code> or <code>route -n</code>. If the routing table has no path to the destination, or <code>traceroute</code> dies at a specific hop, packets are being dropped mid-journey. This is a Layer 3 / Network failure: missing route, misconfigured gateway, firewall dropping packets at the IP level, wrong subnet mask.</p><p><strong>Ping succeeds: climb up from L4</strong></p><p>Routing is fine. The problem is in the handshake, session, or application layer.</p><p><strong>Q5: Does TCP connect?</strong> Run <code>telnet &lt;host&gt; &lt;port&gt;</code>, <code>nc</code>, or <code>curl -v</code>. If you get &#8220;Connection refused&#8221;, the <strong>host is reachable but nothing is listening on that port</strong>. If you get &#8220;Connection timed out&#8221;, a firewall is silently dropping the packet (distinct from a routing drop, which would have failed ping). Both are Layer 4 / Transport failures: process not started, wrong port, firewall rule, security group blocking the port.</p><p><strong>Q6 (if TCP connects): Does TLS handshake succeed?</strong> Run <code>openssl s_client -connect host:443</code>. If the handshake fails: expired certificate, hostname mismatch, client doesn&#8217;t support the server&#8217;s cipher suite, self-signed cert not trusted. This is a Layer 6 / Presentation failure. The TCP connection opened fine; the encryption negotiation broke.</p><p><strong>Q7 (if TLS ok): Is the session / auth token valid?</strong> Inspect via <code>jwt.io</code>, browser cookie inspector, or server logs. If the token is expired, malformed, or never issued, requests get rejected before touching business logic. This is a Layer 5 / Session failure: session timeout, logout race condition, token not persisted, SSO misconfiguration.</p><p><strong>Q8 (if token valid): Is the HTTP status 2xx?</strong> Run <code>curl -I</code> or check browser devtools. A 4xx or 5xx response means TCP connected, TLS succeeded, session authenticated, but the application rejected the request. This is a Layer 7 / Application failure: wrong endpoint, missing required header, malformed request body, backend crash, rate limiting, bad API version.</p><p><strong>All layers pass: check app logic</strong></p><p>If you get a 200 but the data is wrong or behavior is unexpected, you&#8217;re past the network stack entirely. Now you&#8217;re in observability territory: logs, distributed traces (Jaeger, Zipkin), metrics (Prometheus), database query results. Not a network problem at all.</p><p><strong>Cases the diagram doesn&#8217;t explicitly show but matter:</strong></p><p><strong>Intermittent failures:</strong> if ping sometimes fails, suspect L1/L2: flapping interface, bad cable showing marginal signal, overloaded switch dropping packets under load. Consistent failures are easier to diagnose than flapping ones.</p><p><strong>DNS failure:</strong> sits at L7 conceptually (DNS is an application protocol) but feels like a routing failure because the hostname never resolves to an IP. <code>nslookup</code> or <code>dig</code> isolates this before ping even runs. If <code>ping 8.8.8.8</code> works but <code>ping google.com</code> fails, DNS, not routing.</p><p><strong>Asymmetric routing:</strong> ping succeeds outbound but response never returns. Packets reach the host but the return path is broken. <code>traceroute</code> from both ends reveals it.</p><p><strong>MTU(Maximum Transmission Unit) mismatch:</strong> small packets (ping) succeed, large packets (HTTP with full payload) fail silently or get fragmented badly. Classic symptom: site loads but large file transfers hang. <code>ping -s 1472</code> tests this.</p><p><strong>TCP state exhaustion:</strong> port is open, SYN sent, server never responds with SYN-ACK. Not a firewall drop (that gives timeout immediately), the server&#8217;s <strong>TCP accept queue is full</strong>. <code>ss -s</code> on the server shows the overflow.</p><p><strong>Half-open TLS:</strong> TCP connects, TLS starts negotiating, then hangs. Usually a load balancer or proxy terminating TLS but the backend is misconfigured.</p><blockquote><p>The interview answer that always lands: &#8220;<em>I start at ping to bisect the stack. Ping fails means L3 or below, I work downward. Ping succeeds means L4 or above, I work upward. Each tool I reach for corresponds to exactly one layer.</em>&#8221;</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!IpdC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!IpdC!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png 424w, /__u/substackcdn.com/image/fetch/$s_!IpdC!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png 848w, /__u/substackcdn.com/image/fetch/$s_!IpdC!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png 1272w, /__u/substackcdn.com/image/fetch/$s_!IpdC!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!IpdC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png" width="728" height="396.6870095902354" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:625,&quot;width&quot;:1147,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:622683,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/199736208?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!IpdC!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png 424w, /__u/substackcdn.com/image/fetch/$s_!IpdC!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png 848w, /__u/substackcdn.com/image/fetch/$s_!IpdC!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png 1272w, /__u/substackcdn.com/image/fetch/$s_!IpdC!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6c419e0-8e15-4b36-a3a6-4dbb0879e49d_1147x625.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p>]]></content:encoded></item><item><title><![CDATA[CAP & PACELC: what the theorems actually say]]></title><description><![CDATA[A clear conceptual primer. What they actually claim vs what interviewers think they claim, and how PACELC extends CAP.]]></description><link>https://saifhatem.substack.com/p/cap-and-pacelc-what-the-theorems</link><guid isPermaLink="false">https://saifhatem.substack.com/p/cap-and-pacelc-what-the-theorems</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Wed, 06 May 2026 21:16:24 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!wV6J!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2><strong>Introduction</strong></h2><p>The CAP theorem is one of the most cited concepts in distributed systems. It is also one of the most frequently paraphrased incorrectly. Many engineers have heard the phrase &#8220;<em>pick two out of three: Consistency, Availability, and Partition Tolerance.</em>&#8221; That shorthand, while memorable, <strong>omits important context</strong>.</p><p>The PACELC theorem extends CAP by addressing a question the original theorem does not answer: what trade-offs exist when the network is working normally?</p><p>This article walks through each pillar of CAP one by one, explains what the theorem actually claims, and then introduces PACELC as a natural extension. </p><p></p><h2><strong>What is CAP?</strong></h2><p>The core definition of CAP:</p><blockquote><p>In the presence of a network partition (P), a distributed system cannot simultaneously guarantee both <strong>Consistency (C)</strong> and <strong>Availability (A)</strong> for all requests.</p></blockquote><p>Or more explicitly:</p><ul><li><p>When a <strong>partition occurs</strong>, the system must choose to either:</p><ul><li><p><strong>sacrifice availability</strong> (some requests may fail or time out) to preserve consistency, or</p></li><li><p><strong>sacrifice consistency</strong> (allow divergent or stale reads) to preserve availability.</p></li></ul></li></ul><p>The picture below shows network partitioning, servers are split to clusters(groups) and communication between servers in different clusters is cut off.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!wV6J!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!wV6J!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png 424w, /__u/substackcdn.com/image/fetch/$s_!wV6J!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png 848w, /__u/substackcdn.com/image/fetch/$s_!wV6J!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wV6J!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!wV6J!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png" width="581" height="514.8101265822785" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:910,&quot;width&quot;:1027,&quot;resizeWidth&quot;:581,&quot;bytes&quot;:107015,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/195706994?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!wV6J!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png 424w, /__u/substackcdn.com/image/fetch/$s_!wV6J!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png 848w, /__u/substackcdn.com/image/fetch/$s_!wV6J!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wV6J!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2868c131-756a-4165-b6ec-fd3fa066b2c9_1027x910.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h2><strong>The Three Pillars of CAP</strong></h2><p>Before discussing trade-offs, it is necessary to define each pillar precisely.</p><h3><strong>Consistency (C)</strong></h3><p>Consistency guarantees that every read receives the most recent write or an error.</p><p>In a consistent system, all nodes return the same data at the same time. If a client writes a value to one node, any subsequent read from any node will return that value. The system behaves as if there is only one copy of the data, even though multiple replicas exist.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!0ZUu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!0ZUu!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png 424w, /__u/substackcdn.com/image/fetch/$s_!0ZUu!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png 848w, /__u/substackcdn.com/image/fetch/$s_!0ZUu!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png 1272w, /__u/substackcdn.com/image/fetch/$s_!0ZUu!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!0ZUu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png" width="624" height="610.0714285714286" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:657,&quot;width&quot;:672,&quot;resizeWidth&quot;:624,&quot;bytes&quot;:35355,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/195706994?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!0ZUu!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png 424w, /__u/substackcdn.com/image/fetch/$s_!0ZUu!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png 848w, /__u/substackcdn.com/image/fetch/$s_!0ZUu!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png 1272w, /__u/substackcdn.com/image/fetch/$s_!0ZUu!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bc0bd71-7374-44d2-9385-a5b4ebd79a25_672x657.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p><strong>Practical Example:</strong> A banking system. After a customer deposits money, an ATM at any branch must reflect the new balance immediately. If the ATM showed the old balance, the customer might incorrectly believe they have less money than they actually do.</p><h3><strong>Availability (A)</strong></h3><p>Availability guarantees that every request (read or write) receives a non-error response. The response does not need to contain the most recent write. It can be stale.</p><p>Two details matter here. First, every request receives a response&#8212;not 99.9% of requests. Second, the system does not promise that the response is up to date. It only promises that the system responds.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!GYq1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!GYq1!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png 424w, /__u/substackcdn.com/image/fetch/$s_!GYq1!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png 848w, /__u/substackcdn.com/image/fetch/$s_!GYq1!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png 1272w, /__u/substackcdn.com/image/fetch/$s_!GYq1!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!GYq1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png" width="610" height="597.1771771771772" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:652,&quot;width&quot;:666,&quot;resizeWidth&quot;:610,&quot;bytes&quot;:38020,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/195706994?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!GYq1!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png 424w, /__u/substackcdn.com/image/fetch/$s_!GYq1!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png 848w, /__u/substackcdn.com/image/fetch/$s_!GYq1!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png 1272w, /__u/substackcdn.com/image/fetch/$s_!GYq1!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b44933-4b64-47dd-ba73-24f5fc75e1d9_666x652.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p><strong>Practical Example:</strong> An e-commerce shopping cart. During high traffic or minor network issues, the system should always accept items added to the cart. If two devices show slightly different cart contents for a few seconds, that is acceptable. But showing an error page is not acceptable.</p><h3><strong>Partition Tolerance (P)</strong></h3><p>Partition tolerance means the system continues to operate despite an arbitrary number of messages being dropped or delayed by the network between nodes.</p><p>A network partition occurs when two groups of nodes cannot communicate with each other. The servers themselves may be running perfectly. The network between them has failed.</p><p>For any distributed system with two or more nodes communicating over a network, partitions are inevitable. Networks drop packets. Cables fail. Switches misbehave. Partition tolerance is not optional in a distributed system&#8212;it is a requirement.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!3lg7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!3lg7!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png 424w, /__u/substackcdn.com/image/fetch/$s_!3lg7!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png 848w, /__u/substackcdn.com/image/fetch/$s_!3lg7!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png 1272w, /__u/substackcdn.com/image/fetch/$s_!3lg7!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!3lg7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png" width="622" height="589.6041666666666" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:637,&quot;width&quot;:672,&quot;resizeWidth&quot;:622,&quot;bytes&quot;:46095,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/195706994?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!3lg7!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png 424w, /__u/substackcdn.com/image/fetch/$s_!3lg7!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png 848w, /__u/substackcdn.com/image/fetch/$s_!3lg7!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png 1272w, /__u/substackcdn.com/image/fetch/$s_!3lg7!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ac8ad66-bd30-4d04-86c3-b2f1033aec7b_672x637.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p><strong>Example:</strong> A database with replicas in two data centers. If the fiber connection between those data centers is cut, a partition-tolerant system keeps both sides running independently. A non-partition-tolerant system would shut down entirely.</p><h3><strong>CAP choice</strong></h3><p>With that being said, partitioning in distributed systems is must, and you must be able to decide between consistency and availability. The diagram below illustrates the general idea behind each choice</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!jq7q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!jq7q!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png 424w, /__u/substackcdn.com/image/fetch/$s_!jq7q!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png 848w, /__u/substackcdn.com/image/fetch/$s_!jq7q!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png 1272w, /__u/substackcdn.com/image/fetch/$s_!jq7q!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!jq7q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png" width="568" height="648.3601286173633" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:710,&quot;width&quot;:622,&quot;resizeWidth&quot;:568,&quot;bytes&quot;:40852,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/195706994?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!jq7q!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png 424w, /__u/substackcdn.com/image/fetch/$s_!jq7q!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png 848w, /__u/substackcdn.com/image/fetch/$s_!jq7q!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png 1272w, /__u/substackcdn.com/image/fetch/$s_!jq7q!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1069b49-ca12-43dd-ba94-10e48961d55e_622x710.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>The Three System Classifications (CP, AP, CA)</strong></h3><h3><strong> </strong></h3><p>Below is a Venn diagram which depicts on the characteristics of each pillar, you will notice that at exactly two you end up with three possibilities, CP, AP and CA.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!4GGH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d6cd8fc-a97a-47d7-b936-a5a91effc1a0_850x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!4GGH!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d6cd8fc-a97a-47d7-b936-a5a91effc1a0_850x768.png 424w, /__u/substackcdn.com/image/fetch/$s_!4GGH!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d6cd8fc-a97a-47d7-b936-a5a91effc1a0_850x768.png 848w, /__u/substackcdn.com/image/fetch/$s_!4GGH!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d6cd8fc-a97a-47d7-b936-a5a91effc1a0_850x768.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4GGH!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d6cd8fc-a97a-47d7-b936-a5a91effc1a0_850x768.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!4GGH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d6cd8fc-a97a-47d7-b936-a5a91effc1a0_850x768.png" width="528" height="477.0635294117647" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7d6cd8fc-a97a-47d7-b936-a5a91effc1a0_850x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:850,&quot;resizeWidth&quot;:528,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Understanding CAP theorem. What is the CAP theorem? | by Nader Medhat |  Nerd For Tech | Medium&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Understanding CAP theorem. What is the CAP theorem? | by Nader Medhat |  Nerd For Tech | Medium" title="Understanding CAP theorem. What is the CAP theorem? | by Nader Medhat |  Nerd For Tech | Medium" srcset="/__u/substackcdn.com/image/fetch/$s_!4GGH!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d6cd8fc-a97a-47d7-b936-a5a91effc1a0_850x768.png 424w, /__u/substackcdn.com/image/fetch/$s_!4GGH!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d6cd8fc-a97a-47d7-b936-a5a91effc1a0_850x768.png 848w, /__u/substackcdn.com/image/fetch/$s_!4GGH!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d6cd8fc-a97a-47d7-b936-a5a91effc1a0_850x768.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4GGH!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d6cd8fc-a97a-47d7-b936-a5a91effc1a0_850x768.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Based on the CAP theorem, distributed systems are often classified into three categories. These labels describe the system's behavior during a partition</p><h3><strong>CP System (Consistency + Partition Tolerance)</strong></h3><p>During a partition, a CP system prioritizes Consistency over Availability. It may reject requests to ensure that no node returns stale data.</p><p><strong>Examples:</strong> HBase, MongoDB (with strong consistency settings), ZooKeeper, most traditional relational databases in distributed configurations.</p><p><strong>Typical use case:</strong> Financial systems where data correctness is more important than immediate availability.</p><h3><strong>AP System (Availability + Partition Tolerance)</strong></h3><p>During a partition, an AP system prioritizes Availability over Consistency. It accepts requests on all sides of the partition, even if that means different clients see different data.</p><p><strong>Examples:</strong> Cassandra, DynamoDB (default settings), CouchDB.</p><p><strong>Typical use case:</strong> Social media feeds, shopping carts, DNS systems where stale data is acceptable and uptime is critical.</p><h3><strong>CA System (Consistency + Availability)</strong></h3><p>A CA system would provide both Consistency and Availability while not tolerating partitions. In practice, this is only possible on a single node or on a network that never experiences partitions. Since network partitions are inevitable in distributed systems, a true CA distributed system does not exist.</p><p>If a system claims to be CA in a distributed environment, it either runs on a single node or it sacrifices one of the guarantees silently during partitions.</p><h3><strong>What about the mid-intersection in the Venn Diagram?</strong></h3><p>This implies that there is a system which is C-A-P, holding all three characteristics at once, while it could be some<strong> ignorant&#8217;s manager expectations</strong>, it&#8217;s simply not possible, as partitioning forces you to pick either A or C as we discussed well above</p><h2><strong>Where CAP Stops Short</strong></h2><p>The CAP theorem addresses a specific scenario: network partitions. It does not address what happens when the <strong>network is healthy</strong>, which is the majority of the time for most systems.</p><p>Consider two databases, both classified as AP under CAP. During a partition, both prefer Availability. But what about normal operation?</p><ul><li><p>One database might return stale reads even when the network is perfectly healthy because it prioritizes low latency.</p></li><li><p>Another database might wait for confirmation from multiple replicas on every read, increasing latency but guaranteeing strong consistency.</p></li></ul><p>CAP does not distinguish between these two designs. It offers no guidance for the non-partitioned state.</p><p>This gap led to the PACELC theorem.</p><h2><strong>Introducing PACELC</strong></h2><p>The PACELC theorem, proposed by Daniel Abadi in 2010, extends CAP by addressing the trade-offs that exist in normal operation.</p><h3><strong>The PACELC Acronym</strong></h3><p>PACELC stands for:</p><ul><li><p><strong>P</strong>artition</p></li><li><p><strong>A</strong>vailability vs <strong>C</strong>onsistency (the CAP trade-off)</p></li><li><p><strong>E</strong>lse (no partition)</p></li><li><p><strong>L</strong>atency vs <strong>C</strong>onsistency</p></li></ul><h3><strong>What PACELC Adds That CAP Misses</strong></h3><p>The full PACELC statement is:</p><blockquote><p>If there is a partition (P), the system must choose between Availability and Consistency (A vs C).</p><p>Else (E), when there is no partition, <strong>the system must choose between Latency and Consistency (L vs C)</strong>.</p></blockquote><p>PACELC acknowledges that even in a healthy network, trade-offs exist. Strong consistency requires nodes to communicate and agree. Synchronous replication costs time. If a system waits for multiple replicas to confirm a write before responding, latency increases. If a system prioritizes low latency, it may serve stale data.</p><p>No distributed system can have both low latency and strong consistency. PACELC makes this explicit.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!uuzh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!uuzh!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png 424w, /__u/substackcdn.com/image/fetch/$s_!uuzh!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png 848w, /__u/substackcdn.com/image/fetch/$s_!uuzh!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png 1272w, /__u/substackcdn.com/image/fetch/$s_!uuzh!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!uuzh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png" width="976" height="611" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:611,&quot;width&quot;:976,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:114893,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/195706994?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!uuzh!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png 424w, /__u/substackcdn.com/image/fetch/$s_!uuzh!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png 848w, /__u/substackcdn.com/image/fetch/$s_!uuzh!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png 1272w, /__u/substackcdn.com/image/fetch/$s_!uuzh!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0b4a09b-266c-45ce-b0a3-2702983721d2_976x611.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>Hence, we can imply that CAP is a subset of PACELC, just that the bottom line difference is that PACELC addresses the trade-offs during no partitioning.</p><h2><strong>PACELC in Practice: Real-World Examples</strong></h2><p>To understand PACELC, it helps to see how real systems make different choices. Remember that PACELC asks two separate questions:</p><ol><li><p><strong>During a partition (P):</strong> Does the system choose Availability (A) or Consistency (C)?</p></li><li><p><strong>During normal operation (E):</strong> Does the system choose Latency (L) or Consistency (C)?</p></li></ol><p>Different systems answer these questions differently. Here are several examples.</p><h3><strong>Example 1: A Traditional SQL Database (Single Server)</strong></h3><p>A single MySQL or PostgreSQL database running on one machine is the simplest case.</p><ul><li><p><strong>Partition scenario:</strong> With only one machine, there is no network between nodes. A partition cannot occur. So the first question does not apply.</p></li><li><p><strong>Normal operation:</strong> The database returns the most recent write on every read. There is no network delay because everything is local. So it achieves both low latency and strong consistency.</p></li></ul><p><strong>PACELC classification:</strong> Not applicable (single node) or N/A.</p><p><strong>Key insight:</strong> The only way to avoid the L vs C trade-off is to have no network coordination at all. That means a single machine.</p><h3><strong>Example 2: Amazon&#8217;s Shopping Cart (DynamoDB)</strong></h3><p>Amazon&#8217;s shopping cart is designed to always accept items, even during network problems.</p><ul><li><p><strong>During a partition:</strong> If the network splits, the shopping cart continues working on both sides. You can add items on your phone and your laptop separately. The system does not refuse any request. Later, when the network heals, the system merges the carts. This is <strong>AP</strong> (choosing Availability over Consistency during a partition).</p></li><li><p><strong>Normal operation:</strong> When the network is healthy, the system still prioritizes speed. If you add an item on your phone, it might take a few seconds to appear on your laptop. The system does not wait to confirm that all nodes have the update. It returns fast responses, even if some reads are slightly stale. This is <strong>EL</strong> (choosing Latency over Consistency in normal operation).</p></li></ul><p><strong>PACELC classification:</strong> PA/EL (Partition &#8594; Availability, Else &#8594; Latency)</p><p><strong>Why this makes sense:</strong> A shopping cart can tolerate stale data for a few seconds. But a slow or unavailable cart loses sales.</p><h3><strong>Example 3: A Bank Account Database</strong></h3><p>A bank cannot tolerate stale data. If you deposit money, that balance must be correct immediately everywhere.</p><ul><li><p><strong>During a partition:</strong> If the network splits, the bank would rather refuse a withdrawal than let you overdraw. The system may return an error or tell you to try again later. This is <strong>CP</strong> (choosing Consistency over Availability during a partition).</p></li><li><p><strong>Normal operation:</strong> When the network is healthy, the bank still prioritizes correctness. After you deposit money, the system waits to confirm that all replicas have received the update before responding. This takes more time&#8212;perhaps a few hundred milliseconds&#8212;but the data is guaranteed correct. This is <strong>EC</strong> (choosing Consistency over Latency in normal operation).</p></li></ul><p><strong>PACELC classification:</strong> PC/EC (Partition &#8594; Consistency, Else &#8594; Consistency)</p><p><strong>Why this makes sense:</strong> Being slow is frustrating. Being wrong is catastrophic. The bank accepts higher latency to ensure correctness.</p><div><hr></div><h3><strong>Example 4: Google Spanner</strong></h3><p>Google Spanner is a globally distributed database. It is known for providing strong consistency even across continents.</p><ul><li><p><strong>During a partition:</strong> Spanner chooses Consistency. If a partition occurs, it will reject requests rather than serve stale data. This is <strong>CP</strong>.</p></li><li><p><strong>Normal operation:</strong> Even when the network is healthy, Spanner waits for consensus across multiple data centers before committing a write. This adds significant latency&#8212;hundreds of milliseconds for a write across oceans. But the guarantee is that every read, anywhere in the world, sees the latest write. This is <strong>EC</strong>.</p></li></ul><p><strong>PACELC classification:</strong> PC/EC (same as the bank example, but with much higher latency due to global scale)</p><p><strong>Why this makes sense:</strong> Google uses Spanner for critical systems like Google Ads, where incorrect data costs real money. Consistency is worth the latency.</p><div><hr></div><h3><strong>Example 5: DNS (Domain Name System)</strong></h3><p>DNS is the system that turns a website name like <code>example.com</code> into an IP address.</p><ul><li><p><strong>During a partition:</strong> DNS servers continue answering queries even if they cannot talk to each other. If a partition occurs, each server returns the data it has locally. This may be outdated, but the user gets an answer. This is <strong>AP</strong>.</p></li><li><p><strong>Normal operation:</strong> DNS is designed to be fast. Changes to a domain (like updating a website&#8217;s IP address) can take minutes or hours to propagate globally. The system does not wait for all servers to confirm an update. It prioritizes lookup speed over immediate consistency. This is <strong>EL</strong>.</p></li></ul><h2><strong>Special Cases: The Rare PACELC Combinations</strong></h2><p>You might have caught the pattern above, it is that most distributed systems fall into two common patterns:</p><ul><li><p><strong>PC/EC</strong> (Consistency during partitions, Consistency over latency normally) &#8211; Example: Banks, Google Spanner</p></li><li><p><strong>PA/EL</strong> (Availability during partitions, Latency over consistency normally) &#8211; Example: Shopping carts, DNS, Cassandra</p></li></ul><p>However, two other combinations are possible but rare. They are worth understanding because they reveal interesting design trade-offs.</p><h3><strong>Rare Combination 1: PC/EL</strong></h3><p><strong>Definition:</strong></p><ul><li><p><strong>During a partition (P):</strong> Choose Consistency (CP) &#8211; reject requests to avoid stale data</p></li><li><p><strong>During normal operation (E):</strong> Choose Latency over Consistency (EL) &#8211; accept stale reads for speed</p></li></ul><p><strong>Why this is rare:</strong></p><p>If a system rejects requests during partitions to preserve consistency, it signals that consistency is very important. Yet PC/EL chooses low latency and potentially stale reads during normal operation. This is philosophically inconsistent. Most systems that care about consistency enforce it all the time.</p><p><strong>When it might be used:</strong></p><ul><li><p><strong>Read-heavy analytics caches</strong> &#8211; Writes must be consistent to avoid data corruption. But reads can be slightly stale because analytics queries tolerate old data. During a partition, the system rejects writes (CP) to protect data integrity. Reads continue serving cached, possibly stale data with low latency (EL).</p></li><li><p><strong>Content delivery network (CDN) control plane</strong> &#8211; Configuration updates must be consistent (no partial updates). But edge nodes can serve slightly stale configurations for performance.</p></li></ul><p><strong>Example system:</strong> A real-time dashboard that shows stock prices. Writes (price updates) must be consistent to avoid displaying impossible values. Reads can be a few seconds stale without harming the user experience. During a network partition, the system rejects price updates to prevent inconsistencies, but continues serving cached prices to viewers.</p><h3><strong>Rare Combination 2: PA/EC</strong></h3><p><strong>Definition:</strong></p><ul><li><p><strong>During a partition (P):</strong> Choose Availability (AP) &#8211; accept all requests, even if stale or conflicting</p></li><li><p><strong>During normal operation (E):</strong> Choose Consistency over Latency (EC) &#8211; wait for strong consistency</p></li></ul><p><strong>Why this is rare:</strong></p><p>If a system accepts stale data and conflicts during partitions, it is already tolerating inconsistency. Enforcing strong consistency during normal operation adds complexity and latency. Most systems pick one philosophy (always consistency or always availability) and stick with it. PA/EC requires building two completely different behavior modes and a conflict resolution mechanism for when partitions heal.</p><p><strong>When it might be used:</strong></p><ul><li><p><strong>Airline seat booking</strong> &#8211; During a network partition, each data center continues selling seats locally (availability). This may cause double-booking. When the partition heals, the system detects conflicts and contacts affected passengers. During normal operation, the system enforces strong consistency to prevent double-booking.</p></li><li><p><strong>Ride-hailing dispatch (Uber/Lyft)</strong> &#8211; During a partition, drivers can accept ride requests locally (availability). This may assign two drivers to the same passenger. When the partition heals, the system resolves conflicts. During normal operation, strong consistency ensures a passenger is only matched with one driver.</p></li></ul><p><strong>Example system:</strong> An event ticketing platform. Normal operation: strong consistency prevents selling the same seat twice (EC). During a network partition: each venue&#8217;s local box office continues selling tickets (AP). Some double-selling may occur. When the partition heals, the system identifies conflicts and offers refunds or alternative seats.</p><h2><strong>Common Misunderstandings (And Clarifications)</strong></h2><p>Several misunderstandings about CAP appear regularly in interviews and technical discussions.</p><p><strong>Misunderstanding 1: &#8220;A system can be permanently CA, CP, or AP.&#8221;</strong></p><p>Clarification: The CAP trade-off applies only during partitions. In normal operation, a system can provide both Consistency and Availability.</p><p><strong>Misunderstanding 2: &#8220;CA systems are a valid distributed system choice.&#8221;</strong></p><p>Clarification: A distributed CA system is impossible because partitions are inevitable. CA is only possible on a single node.</p><p><strong>Misunderstanding 3: &#8220;Consistency in CAP means ACID.&#8221;</strong></p><p>Clarification: In CAP, Consistency means linearizability(covered in depth during database chapter) - every read sees the most recent write. This is one aspect of ACID, but ACID includes additional guarantees such as atomicity and isolation.</p><p><strong>Misunderstanding 4: &#8220;Availability in CAP means 99.9% uptime.&#8221;</strong></p><p>Clarification: CAP availability requires that every request receives a response, not a statistical percentage. It is a stricter definition than typical service level agreements.</p><p><strong>Misunderstanding 5: &#8220;PACELC replaces CAP.&#8221;</strong></p><p>Clarification: PACELC extends CAP. It includes the CAP trade-off (P &#8594; A vs C) and adds the trade-off for normal operation (E &#8594; L vs C).</p><h2><strong>A Simple Decision Framework</strong></h2><p>When designing a distributed system, these questions can guide CAP and PACELC choices.</p><p><strong>Question 1: Is strong consistency a hard requirement?</strong></p><ul><li><p>Yes (banking, inventory, payments) &#8594; Choose CP during partitions (PC). Choose Consistency over Latency in normal operation (EC).</p></li><li><p>No &#8594; Proceed to Question 2.</p></li></ul><p><strong>Question 2: Can the system become unavailable during network issues?</strong></p><ul><li><p>No (shopping cart, login service) &#8594; Choose AP during partitions (PA). Choose Latency over Consistency in normal operation (EL).</p></li><li><p>Yes (ATM network, stock trading) &#8594; Choose CP during partitions (PC). Choose Consistency over Latency in normal operation (EC).</p></li></ul><p><strong>Question 3: Does latency matter more than consistency in normal operation?</strong></p><ul><li><p>Latency matters more (real-time recommendations, user feeds) &#8594; EL (Latency over Consistency)</p></li><li><p>Consistency matters more (reporting, analytics) &#8594; EC (Consistency over Latency)</p></li></ul><p>No single answer applies to an entire system. Different components may make different choices.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Xbnm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Xbnm!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png 424w, /__u/substackcdn.com/image/fetch/$s_!Xbnm!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png 848w, /__u/substackcdn.com/image/fetch/$s_!Xbnm!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Xbnm!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Xbnm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png" width="928" height="632" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:632,&quot;width&quot;:928,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:57404,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/195706994?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Xbnm!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png 424w, /__u/substackcdn.com/image/fetch/$s_!Xbnm!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png 848w, /__u/substackcdn.com/image/fetch/$s_!Xbnm!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Xbnm!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e1012-bbdc-4b26-90c9-fdfd7f9bbf01_928x632.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[System dependability: availability, reliability, durability & MTBF/MTTR]]></title><description><![CDATA[The vocabulary of dependable systems. How to calculate availability, what fault tolerance actually requires, and the MTBF/MTTR mental model.]]></description><link>https://saifhatem.substack.com/p/system-dependability-availability</link><guid isPermaLink="false">https://saifhatem.substack.com/p/system-dependability-availability</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Sat, 25 Apr 2026 15:04:26 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!R3VK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="callout-block" data-callout="true"><p><em>Before reading this article, please note that there is a good amount of unfamiliar terms you might come across with, because this topic is introductory and generic, it would span a wide range of different domains within system design, the important point is to grasp a basic idea before the deeper dive in later articles</em></p></div><p>Many software engineers often say "available," "reliable," and "durable" like they mean the same thing. They don't. Mixing them up leads to building the wrong thing. This post gives you clear definitions, simple math, and practical ways to achieve each one.</p><h3><strong>Availability</strong></h3><p><strong>Availability</strong> is the percentage of time your system is working and can handle requests.</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Availability} = \\frac{\\text{Uptime}}{\\text{Uptime} + \\text{Downtime}}&quot;,&quot;id&quot;:&quot;QCYJGFEAMS&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>It&#8217;s a time-based measurement. A system down for 8.76 hours per year has 99.9% availability, no matter <em>why</em> it went down.</p><p>Here&#8217;s what &#8220;nines&#8221; mean in real downtime:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Tnj8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Tnj8!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png 424w, /__u/substackcdn.com/image/fetch/$s_!Tnj8!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png 848w, /__u/substackcdn.com/image/fetch/$s_!Tnj8!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Tnj8!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Tnj8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png" width="762" height="235" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:235,&quot;width&quot;:762,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:28472,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/195272568?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Tnj8!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png 424w, /__u/substackcdn.com/image/fetch/$s_!Tnj8!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png 848w, /__u/substackcdn.com/image/fetch/$s_!Tnj8!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Tnj8!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc40c5042-dc53-418b-8072-452cd2a44fe8_762x235.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Important:</strong> Availability is about the whole system from the user&#8217;s view. A working database doesn&#8217;t matter if the load balancer in front of it is dead.</p><h4><strong>Why availability matters</strong></h4><p>Downtime has a clear cost. An e-commerce site making $1M/day loses about $700 per minute of downtime. For SaaS products, long outages mean paying penalties and losing customers. For internal tools, downtime blocks every team that depends on you. Beyond money, repeated outages destroy user trust and trust is much harder to rebuild than uptime.</p><p>The hidden cost: every minute your system is down is a minute your competitors are up.</p><h4><strong>How to get high availability</strong></h4><p>You have two levers: fail less often (increase MTBF) or recover faster (decrease MTTR). These techniques help with one or both.</p><p><strong>Remove single points of failure (SPOF).</strong> Any component with no backup is an SPOF. Find them and add redundancy.</p><p><strong>Run multiple copies.</strong> Deploy several instances of stateless services behind a load balancer. If one dies, traffic goes to the others.</p><p><strong>Use active-passive or active-active replication.</strong> For databases, keep standby copies. Active-passive has a warm backup ready to take over. Active-active runs multiple copies handling writes at once, harder to set up, but higher availability.</p><p><strong>Add health checks and auto-failover.</strong> Redundancy is useless if you don&#8217;t detect failures. Load balancers must constantly check health and route around bad instances automatically. Humans are too slow.</p><p><strong>Deploy without downtime.</strong> Use rolling updates, blue-green, or canary releases. Deployments are a <strong>major cause</strong> of availability incidents.</p><p><strong>Use circuit breakers.</strong> When a downstream service starts failing, the circuit breaker trips and returns a quick fallback instead of waiting for a timeout. This stops one slow service from killing your whole system.</p><p><strong>Degrade gracefully.</strong> Design the system to still work (with fewer features) when non-critical services are down. A search page without recommendations is better than a 500 error.</p><p><strong>Spread across regions.</strong> Put systems in multiple geographic locations to survive a cloud outage or datacenter failure. Route traffic to the healthiest region.</p><h3><strong>Reliability</strong></h3><p><strong>Reliability</strong> is the chance your system runs <em>without any failure</em> for a specific amount of time under normal conditions.</p><p>Availability asks &#8220;how much total uptime?&#8221; Reliability asks &#8220;what&#8217;s the chance it hasn&#8217;t broken yet by time T?&#8221;</p><p>A system can have high availability but low reliability. Example: a service crashes every 30 minutes but restarts in 30 seconds. Availability is about 97%, but reliability (chance of surviving 30 minutes without a crash) is near zero. On the flip side, a system designed for long runs has high reliability.</p><p><strong>When reliability matters most:</strong> workloads where a failure mid-operation is a disaster, financial transactions, batch ETL jobs, firmware updates. Availability matters most for interactive work where quick restarts are fine.</p><h4><strong>The simple reliability formula</strong></h4><p>Given a constant failure rate (average failures per hour), the chance a system survives to time <em>t </em>without failure is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;R(t) = e^{-\\lambda t}&quot;,&quot;id&quot;:&quot;GMTJMGBHEA&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>Where &#955; is the failure rate. It&#8217;s just 1 divided by MTBF (mean time between failures):</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\lambda = \\frac{1}{\\text{MTBF}}&quot;,&quot;id&quot;:&quot;QSPSYSHWLQ&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p><strong>Example:</strong> A service fails on average every 500 hours (MTBF = 500). What&#8217;s the chance it runs for 100 hours without failing?</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;R(100) = e^{-100/500} = e^{-0.2} \\approx 0.819&quot;,&quot;id&quot;:&quot;IWCSFDNALM&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>About 82% chance. For 500 hours:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;R(500) = e^{-500/500} = e^{-1} \\approx 0.368&quot;,&quot;id&quot;:&quot;EGLWXOBQWW&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>Only 37% &#8212; which makes sense because MTBF is an <em>average</em>, not a promise. Half of all failures happen before you reach the MTBF.</p><h4><strong>How to get high reliability</strong></h4><p><strong>Make operations idempotent.</strong> Design operations so you can safely retry them without side effects. A payment endpoint that checks for duplicate transaction IDs before charging means retries are safe.</p><p><strong>Use transactions.</strong> Database transactions make sure operations either finish completely or roll back fully. For distributed systems, patterns like Saga with compensating transactions give similar guarantees.</p><p><strong>Add checkpoints to long jobs.</strong> Save progress at regular intervals so a failure can resume from the last checkpoint instead of starting over. Critical for ETL pipelines.</p><p><strong>Test thoroughly.</strong> Unit tests catch logic errors. Integration tests catch interaction bugs. Chaos engineering (intentionally breaking things in production or staging) tests if your system behaves correctly during real failures.</p><p><strong>Use immutable infrastructure.</strong> Instead of patching running servers (which creates unknown states), replace them with fresh copies from a known-good image. Removes a whole class of reliability bugs.</p><p><strong>Pin dependency versions.</strong> Uncontrolled updates are a common source of reliability problems. Pin versions, test upgrades carefully, and roll out changes gradually with canary deployments.</p><h3><strong>Fault Tolerance</strong></h3><p><strong>Fault tolerance</strong> is a system&#8217;s ability to keep working correctly when some components fail.</p><p>A fault-tolerant system <em>hides</em> failures &#8212; the user never sees an error. This is stricter than high availability, which allows brief degradation.</p><p>Fault tolerance requires three things:</p><ol><li><p><strong>Redundancy</strong> &#8212; multiple copies doing the same job.</p></li><li><p><strong>Failure detection</strong> &#8212; the system knows when something fails (heartbeats, health checks).</p></li><li><p><strong>Failover</strong> &#8212; traffic moves to a healthy component automatically.</p></li></ol><p>Redundancy alone isn&#8217;t fault tolerance. If your backup database needs a human to switch over, that&#8217;s high availability, not fault tolerance.</p><h4><strong>Why fault tolerance matters</strong></h4><p>At large scale, component failure is routine &#8212; not an exception. Google and Amazon lose multiple hard drives every day. Netflix runs Chaos Monkey to randomly kill production instances. The design philosophy: assume failure will happen, design so it doesn&#8217;t matter.</p><p>For strict SLAs(See definition below) &#8212; finance, emergency services, telecom &#8212; even brief downtime has legal, financial, or safety consequences. Fault tolerance is what makes an outage a non-event.</p><blockquote><p><br><strong>SLA (Service Level Agreement)</strong> &#8212; A formal contract between a service provider and a customer that defines the minimum level of service the provider must deliver, along with penalties for failing to meet those commitments.<br></p></blockquote><h4><strong>How to get fault tolerance</strong></h4><p>The techniques are similar to high availability, but applied more strictly with zero downtime required.</p><p><strong>Use consensus protocols.</strong> Distributed systems use algorithms like Raft or Paxos to agree on state even when some nodes fail. As long as a majority (quorum) of nodes is reachable, the system keeps working and stays consistent.</p><p><strong>Use bulkheads.</strong> Isolate components into separate resource pools so one failure can&#8217;t exhaust resources for everything else. If your recommendation service hangs but shares a thread pool with checkout, checkout hangs too. Bulkheads prevent this.</p><p><strong>Set timeouts and retry with backoff.</strong> Never block forever on a downstream call. Set explicit timeouts. Retry transient failures with exponential backoff and jitter to avoid all retrying at once when the service recovers.</p><p><strong>Design services to be stateless.</strong> Stateless services can be replaced instantly without coordination &#8212; any instance works. Stateful services need data migration or leader election on failover, which takes time and adds failure modes.</p><h2><strong>MTBF and MTTR</strong></h2><p>These two numbers are your practical handles for availability.</p><h3><strong>MTBF &#8212; Mean Time Between Failures</strong></h3><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{MTBF} = \\frac{\\text{Total operational time}}{\\text{Number of failures}}&quot;,&quot;id&quot;:&quot;IXSFWERXLG&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>MTBF is how long your system runs on average between failures. It depends on hardware quality, software stability, load, and environment.</p><p>Higher MTBF means failures are rare. You raise MTBF by building more reliable components, reducing complexity, and removing single points of failure.</p><div><hr></div><h3><strong>MTTR &#8212; Mean Time To Recovery</strong></h3><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{MTTR} = \\frac{\\text{Total downtime}}{\\text{Number of failures}}&quot;,&quot;id&quot;:&quot;QMZBOTTHXZ&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>MTTR is how long it takes on average to get back online after a failure. It includes everything from detection &#8594; diagnosis &#8594; fix &#8594; verification.</p><p>MTTR breaks down into:</p><ul><li><p><strong>Time to detect</strong> &#8594; from failure happening to your team knowing about it</p></li><li><p><strong>Time to diagnose</strong> &#8594; from knowing to finding the root cause</p></li><li><p><strong>Time to fix</strong> &#8594; from root cause to deployed fix</p></li></ul><p>Most teams don&#8217;t know which phase takes the longest. Measuring each separately tells you where to invest: long detection time? Fix alerting. Long diagnosis? Add tracing and better logs. Long fix time? Automate deployments.</p><p>You lower MTTR with better monitoring, automated failover, runbooks, on-call tooling, and deployment automation. A system with mediocre MTBF can still hit four-nines availability if MTTR is low enough.</p><div><hr></div><h3><strong>How MTBF and MTTR Drive Availability</strong></h3><p>These two metrics directly give you availability:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Availability} = \\frac{\\text{MTBF}}{\\text{MTBF} + \\text{MTTR}}&quot;,&quot;id&quot;:&quot;ZBFPMCHEKE&quot;}" data-component-name="LatexBlockToDOM"></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!sRML!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb01eea72-adb1-48a7-9445-16f01f6159f5_1701x1043.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!sRML!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb01eea72-adb1-48a7-9445-16f01f6159f5_1701x1043.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!sRML!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb01eea72-adb1-48a7-9445-16f01f6159f5_1701x1043.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!sRML!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb01eea72-adb1-48a7-9445-16f01f6159f5_1701x1043.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!sRML!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb01eea72-adb1-48a7-9445-16f01f6159f5_1701x1043.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!sRML!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb01eea72-adb1-48a7-9445-16f01f6159f5_1701x1043.jpeg" width="1456" height="893" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b01eea72-adb1-48a7-9445-16f01f6159f5_1701x1043.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:893,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;What is Mean Time to Repair (MTTR)?&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="What is Mean Time to Repair (MTTR)?" title="What is Mean Time to Repair (MTTR)?" srcset="/__u/substackcdn.com/image/fetch/$s_!sRML!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb01eea72-adb1-48a7-9445-16f01f6159f5_1701x1043.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!sRML!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb01eea72-adb1-48a7-9445-16f01f6159f5_1701x1043.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!sRML!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb01eea72-adb1-48a7-9445-16f01f6159f5_1701x1043.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!sRML!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb01eea72-adb1-48a7-9445-16f01f6159f5_1701x1043.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>This is your core mental model.</p><p><strong>Example:</strong> A service fails once every 200 hours (MTBF = 200 h). Each failure takes 2 hours to recover from (MTTR = 2 h). Availability = 200 / (200 + 2) = <strong>99.01%</strong></p><p>Now add automation and cut MTTR to 0.2 hours (12 minutes):</p><p>Availability = 200 / (200 + 0.2) = <strong>99.9%</strong></p><p>Same failure rate. Lowering recovery time by 10x added a whole nine. In real systems, <strong>MTTR is often the easier lever</strong> because it&#8217;s about tooling and automation, not waiting for hardware to get better.</p><div><hr></div><h2><strong>Planned vs. Unplanned Downtime</strong></h2><p>Not all downtime is the same.</p><p><strong>Unplanned downtime</strong> comes from failures: hardware breaks, software bugs, networks split, attacks. This is what MTBF and MTTR model. You want it rare (high MTBF) and short (low MTTR).</p><p><strong>Planned downtime</strong> is intentional: maintenance windows, schema changes, deployments, upgrades. Many companies exclude planned downtime from SLAs &#8212; but users experience both. A system that&#8217;s &#8220;up&#8221; 99.99% of the time but has a 4-hour maintenance window every month is really 99.45% available to users.</p><p><strong>Total downtime against an SLA:</strong></p><p></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Total Downtime} = \\text{Planned Downtime} + \\text{Unplanned Downtime}&quot;,&quot;id&quot;:&quot;HZNDCQBOMD&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\text{Unplanned Downtime Budget} = \\text{Total SLA Budget} - \\text{Planned Downtime}&quot;,&quot;id&quot;:&quot;YNLQIBWVXL&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>If your SLA allows 8.76 hours/year (99.9%) and you have two 2-hour maintenance windows, your unplanned budget is only 4.76 hours &#8212; about 28 minutes per month.</p><p><strong>Goal:</strong> Eliminate planned downtime wherever possible.</p><ul><li><p>Schema migrations should be <strong>backward-compatible</strong> and run without locking tables. Use tools like <code>pt-online-schema-change</code>.</p></li><li><p>Deployments should have zero downtime via rolling or blue-green updates.</p></li><li><p>Infrastructure upgrades should roll out in place or replace in parallel &#8212; never take down and replace.</p></li></ul><p>The less planned downtime you have, the more budget you keep for the unplanned kind.</p><div><hr></div><h2><strong>Availability in Systems with Multiple Parts</strong></h2><p>Real systems are chains of components. If every component must be up for the system to work(Series), you multiply their availabilities:</p><p></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;A_{\\text{system}} = A_1 \\times A_2 \\times \\cdots \\times A_n&quot;,&quot;id&quot;:&quot;QEZVRZEYJF&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!h5lM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!h5lM!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png 424w, /__u/substackcdn.com/image/fetch/$s_!h5lM!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png 848w, /__u/substackcdn.com/image/fetch/$s_!h5lM!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png 1272w, /__u/substackcdn.com/image/fetch/$s_!h5lM!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!h5lM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png" width="572" height="417" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:417,&quot;width&quot;:572,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:58022,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/195272568?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!h5lM!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png 424w, /__u/substackcdn.com/image/fetch/$s_!h5lM!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png 848w, /__u/substackcdn.com/image/fetch/$s_!h5lM!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png 1272w, /__u/substackcdn.com/image/fetch/$s_!h5lM!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb5a6ee3-287b-4df5-9f3e-8bb82d607751_572x417.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>&#8203;</p><p>This adds up fast. Two components at 99.9% each give you 99.8% overall. Add a third and you&#8217;re at 99.7%. Every dependency on the critical path chips away at your budget.</p><p><strong>How to fight this:</strong></p><ul><li><p><strong>Add redundancy (parallel components):</strong> If either of two components can handle a request, availability becomes </p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;A_{\\text{parallel}} = 1 - (1 - A)^2&quot;,&quot;id&quot;:&quot;OBPTWEQKUC&quot;}" data-component-name="LatexBlockToDOM"></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!1h8w!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb589164e-6286-48e0-8eb9-edb944386d49_472x665.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!1h8w!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb589164e-6286-48e0-8eb9-edb944386d49_472x665.png 424w, /__u/substackcdn.com/image/fetch/$s_!1h8w!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb589164e-6286-48e0-8eb9-edb944386d49_472x665.png 848w, /__u/substackcdn.com/image/fetch/$s_!1h8w!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb589164e-6286-48e0-8eb9-edb944386d49_472x665.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1h8w!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb589164e-6286-48e0-8eb9-edb944386d49_472x665.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!1h8w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb589164e-6286-48e0-8eb9-edb944386d49_472x665.png" width="288" height="405.76271186440675" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b589164e-6286-48e0-8eb9-edb944386d49_472x665.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:665,&quot;width&quot;:472,&quot;resizeWidth&quot;:288,&quot;bytes&quot;:50035,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/195272568?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb589164e-6286-48e0-8eb9-edb944386d49_472x665.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!1h8w!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb589164e-6286-48e0-8eb9-edb944386d49_472x665.png 424w, /__u/substackcdn.com/image/fetch/$s_!1h8w!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb589164e-6286-48e0-8eb9-edb944386d49_472x665.png 848w, /__u/substackcdn.com/image/fetch/$s_!1h8w!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb589164e-6286-48e0-8eb9-edb944386d49_472x665.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1h8w!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb589164e-6286-48e0-8eb9-edb944386d49_472x665.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p></li><li><p> Two 99% components in parallel give you 99.99%, we had three components we would raise the power to three and so on. In the equation above, <strong>homogeneity in availability is assumed</strong> </p></li><li><p><strong>Degrade gracefully:</strong> Keep the system working (even with fewer features) when non-critical dependencies fail. This removes them from the critical path.</p></li><li><p><strong>Use caching and bulkheads:</strong> Isolate failures so one broken component doesn&#8217;t take down everything.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!R3VK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!R3VK!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png 424w, /__u/substackcdn.com/image/fetch/$s_!R3VK!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png 848w, /__u/substackcdn.com/image/fetch/$s_!R3VK!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png 1272w, /__u/substackcdn.com/image/fetch/$s_!R3VK!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!R3VK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png" width="1058" height="757" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:757,&quot;width&quot;:1058,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:124656,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/195272568?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!R3VK!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png 424w, /__u/substackcdn.com/image/fetch/$s_!R3VK!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png 848w, /__u/substackcdn.com/image/fetch/$s_!R3VK!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png 1272w, /__u/substackcdn.com/image/fetch/$s_!R3VK!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b037eca-2b27-4f4c-a17c-7d35bceb16f6_1058x757.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div></li></ul><div><hr></div><h2><strong>Practical Design Takeaways</strong></h2><p><strong>1. Know your SLA before you build.</strong><br>Four nines gives you 52 minutes of downtime per year &#8212; maybe 6&#8211;10 deployments with rolling restarts. Five nines gives you 5 minutes &#8212; one bad deploy blows the whole budget. Your uptime target directly limits how you release software.</p><p><strong>2. Separate durability from availability.</strong><br>Replication across zones helps both, but they need different investments. Durability is about storage: replication factor, write acknowledgment, backups. Availability is about traffic routing: load balancers, health checks, failover automation.</p><p><strong>3. Use fault tolerance only where it matters.</strong><br>Full fault tolerance is expensive. Use it where downtime directly costs revenue or loses data. Accept lower guarantees at the edges.</p><p><strong>4. Build for low MTTR from day one.</strong><br>Structured logs, distributed tracing, alerting on symptoms (not just infrastructure metrics), and automated recovery runbooks all pay off. Teams that skip this learn why it matters during a 2 AM outage with no context.</p><p><strong>5. Count planned downtime in your SLA.</strong><br>If your SLA tracks wall-clock time, planned downtime counts. Design deployments and maintenance to be zero-downtime from the start, not as an afterthought.</p>]]></content:encoded></item><item><title><![CDATA[Performance theory: latency, throughput, bandwidth, parallelism vs concurrency & Little's Law]]></title><description><![CDATA[Understand latency(P50/P95/P99/P999), throughput, bandwidth, load, capacity, utilization, service time, response time, queueing, concurrency vs parallelism, percentiles, tail latency & Little's Law]]></description><link>https://saifhatem.substack.com/p/performance-theory-latency-throughput</link><guid isPermaLink="false">https://saifhatem.substack.com/p/performance-theory-latency-throughput</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Tue, 21 Apr 2026 16:19:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!antM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2><strong>Latency and Throughput</strong></h2><p>These two metrics are often confused. They measure different things.</p><p><strong>Latency</strong> is the time between sending a request and receiving a response. It is measured in time units: milliseconds, microseconds, seconds. Low latency means the system responds quickly.</p><p><strong>Throughput</strong> is the number of requests a system can process per unit of time. It is measured in operations per second: QPS (queries per second), RPS (requests per second), TPS (transactions per second). High throughput means the system does a lot of work.</p><p>The relationship is not fixed. A system can have low latency and low throughput. It can have high latency and high throughput. Batch processing systems often have high latency (minutes per job) and very high throughput (millions of records per second). Real-time APIs have low latency (tens of milliseconds) and moderate throughput.</p><p>The confusion arises because increasing throughput often increases latency. When a system handles more requests simultaneously, those requests wait in queues. <strong>Queueing adds latency</strong>.</p><h2><strong>Bandwidth</strong></h2><p>Bandwidth is the maximum amount of data that can be transferred per unit of time. It is measured in bits or bytes per second: Mbps, Gbps, MB/s.</p><p>Bandwidth and throughput are related but distinct. <strong>Bandwidth is a capacity limit. Throughput is actual usage</strong>. A 1 Gbps network link has 1 Gbps of bandwidth. If you send 200 Mbps through it, your throughput is 200 Mbps and your bandwidth is 1 Gbps. If you try to send 2 Gbps, your throughput will cap at 1 Gbps and packets will be dropped or delayed.</p><p>For system design, bandwidth matters when moving large amounts of data. Streaming video, transferring database backups, and serving large files are bandwidth-bound. API calls with small payloads are rarely bandwidth-bound; they are latency-bound or CPU-bound.</p><p>This diagram illustrates the conceptual difference between the three metrics</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!o9I9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3fee79-a509-46b4-a7dd-6aa7883cb9b9_1417x846.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!o9I9!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3fee79-a509-46b4-a7dd-6aa7883cb9b9_1417x846.png 424w, /__u/substackcdn.com/image/fetch/$s_!o9I9!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3fee79-a509-46b4-a7dd-6aa7883cb9b9_1417x846.png 848w, /__u/substackcdn.com/image/fetch/$s_!o9I9!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3fee79-a509-46b4-a7dd-6aa7883cb9b9_1417x846.png 1272w, /__u/substackcdn.com/image/fetch/$s_!o9I9!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3fee79-a509-46b4-a7dd-6aa7883cb9b9_1417x846.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!o9I9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3fee79-a509-46b4-a7dd-6aa7883cb9b9_1417x846.png" width="1417" height="846" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8e3fee79-a509-46b4-a7dd-6aa7883cb9b9_1417x846.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:846,&quot;width&quot;:1417,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Bandwidth, Latency and Throughput | NetworkAcademy.IO&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Bandwidth, Latency and Throughput | NetworkAcademy.IO" title="Bandwidth, Latency and Throughput | NetworkAcademy.IO" srcset="/__u/substackcdn.com/image/fetch/$s_!o9I9!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3fee79-a509-46b4-a7dd-6aa7883cb9b9_1417x846.png 424w, /__u/substackcdn.com/image/fetch/$s_!o9I9!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3fee79-a509-46b4-a7dd-6aa7883cb9b9_1417x846.png 848w, /__u/substackcdn.com/image/fetch/$s_!o9I9!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3fee79-a509-46b4-a7dd-6aa7883cb9b9_1417x846.png 1272w, /__u/substackcdn.com/image/fetch/$s_!o9I9!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3fee79-a509-46b4-a7dd-6aa7883cb9b9_1417x846.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2><strong>Load, Capacity, and Utilization</strong></h2><p>These three concepts form the foundation of capacity planning.</p><p><strong>Load</strong> is the rate at which work arrives at the system. It is measured in requests per second. It is often denoted by the Greek letter lambda (&#955;).</p><p><strong>Capacity</strong> is the maximum rate at which the system can process work. It is measured in the same units as load: requests per second. It is often denoted by mu (&#956;).</p><p><strong>Utilization</strong> is the fraction of capacity being used. It is calculated as:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\rho = \\frac{\\lambda}{\\mu}\n\\quad \\text{where} \\quad\n\\begin{aligned}\n\\rho &amp;= \\text{utilization (dimensionless, } 0 \\text{ to } 1\\text{)} \\\\\n\\lambda &amp;= \\text{load (arrival rate, requests/sec)} \\\\\n\\mu &amp;= \\text{capacity (maximum service rate, requests/sec)}\n\\end{aligned}&quot;,&quot;id&quot;:&quot;BXNPOCCONQ&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>A system with a capacity of 100 requests per second receiving 70 requests per second has 70% utilization. A system receiving 120 requests per second has 120% utilization. It is overloaded.</p><p>The critical insight is that utilization cannot exceed 100% in steady state. When it approaches 100%, queueing delays grow rapidly. A system at 90% utilization has significantly higher latency than the same system at 50% utilization, even though both are processing the same number of requests per second. This is why production systems aim to keep utilization below 70-80%. The remaining capacity is headroom for traffic spikes.</p><h2><strong>Service Time and Response Time</strong></h2><p>These two are often used interchangeably. They should not be.</p><p><strong>Service time</strong> is the time the system actively spends processing a request. It includes CPU time, disk I/O time, and any computation. It does not include waiting.</p><p><strong>Response time</strong> is the total time from request arrival to response departure. It includes service time plus all waiting time.</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;T_{\\text{response}} = T_{\\text{service}} + T_{\\text{queue}} + T_{\\text{network}}\n\\quad \\text{where} \\quad\n\\begin{aligned}\nT_{\\text{response}} &amp;= \\text{response time (total request duration)} \\\\\nT_{\\text{service}} &amp;= \\text{service time (active processing time)} \\\\\nT_{\\text{queue}} &amp;= \\text{queue time (time waiting for resources)} \\\\\nT_{\\text{network}} &amp;= \\text{network latency (round-trip propagation)}\n\\end{aligned}&quot;,&quot;id&quot;:&quot;ENJKMDFYQE&quot;}" data-component-name="LatexBlockToDOM"></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Ft_O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Ft_O!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ft_O!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ft_O!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ft_O!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Ft_O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png" width="1067" height="738" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:738,&quot;width&quot;:1067,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:111727,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194900139?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Ft_O!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ft_O!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ft_O!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ft_O!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9cf9fd69-4112-41d1-89fb-212d0696cc15_1067x738.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The distinction matters because it tells you where to look for problems. If response time is high but service time is low, the request spent most of its life waiting. The bottleneck is queueing somewhere: a saturated CPU scheduler, a full connection pool, a lock contention. If service time is high, the work itself is slow. The fix is optimization or vertical scaling.</p><p>Without measuring both, you cannot tell the difference. Most monitoring systems measure response time. Few measure service time. This is a common blind spot.</p><h2><strong>Queueing and Little&#8217;s Law</strong></h2><p>Queueing is the reason systems slow down under load. When requests arrive faster than they can be processed, they form a queue. The queue adds waiting time to every request.</p><p><strong>Little&#8217;s Law (L = lambda * reponse time(avg))</strong> is the fundamental relationship that governs queueing systems:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;   L = \\lambda \\times W\n\\quad \\text{where} \\quad\n\\begin{aligned}\nL &amp;= \\text{average number of requests in the system (queue + processing)} \\\\\n\\lambda &amp;= \\text{arrival rate (requests/sec)} \\\\\nW &amp;= \\text{average response time (sec)}\n\\end{aligned}&quot;,&quot;id&quot;:&quot;QFDWRKXJDO&quot;}" data-component-name="LatexBlockToDOM"></div><p>This law holds for any <strong>stable system</strong>, regardless of the distribution of arrivals or service times. It is one of the few universal truths in performance analysis.</p><p>For example, if 50 requests arrive per second (&#955; = 50) and each request takes 0.1 seconds on average (W = 0.1), then the average number of requests in the system is L = 50 &#215; 0.1 = 5. Five requests are either being processed or waiting.</p><p>For a simple single-server queue (M/M/1 model), the average queueing time can be calculated:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;T_{\\text{queue}} = \\left( \\frac{\\rho}{1 - \\rho} \\right) \\times T_{\\text{service}}\n\\quad \\text{where} \\quad\n\\begin{aligned}\nT_{\\text{queue}} &amp;= \\text{average queue time} \\\\\n\\rho &amp;= \\text{utilization (fraction of capacity used)} \\\\\nT_{\\text{service}} &amp;= \\text{average service time}\n\\end{aligned}&quot;,&quot;id&quot;:&quot;UVTZEWBLQZ&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>This formula reveals why utilization matters so much. At 50% utilization, queue time equals service time. Response time is twice service time. At 80% utilization, queue time is four times service time. Response time is five times service time. At 90% utilization, queue time is nine times service time. Response time is ten times service time. Latency explodes long before the system reaches 100% utilization.</p><h2><strong>Concurrency vs Parallelism</strong></h2><p>These terms are often used as synonyms. They are not the same. The distinction matters because it determines how you structure your code and how you reason about throughput.</p><h3><strong>Concurrency</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!LhX2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F275619b2-8c5d-4259-b689-afc37702fb69_792x525.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!LhX2!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F275619b2-8c5d-4259-b689-afc37702fb69_792x525.png 424w, /__u/substackcdn.com/image/fetch/$s_!LhX2!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F275619b2-8c5d-4259-b689-afc37702fb69_792x525.png 848w, /__u/substackcdn.com/image/fetch/$s_!LhX2!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F275619b2-8c5d-4259-b689-afc37702fb69_792x525.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LhX2!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F275619b2-8c5d-4259-b689-afc37702fb69_792x525.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!LhX2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F275619b2-8c5d-4259-b689-afc37702fb69_792x525.png" width="564" height="373.8636363636364" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/275619b2-8c5d-4259-b689-afc37702fb69_792x525.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:525,&quot;width&quot;:792,&quot;resizeWidth&quot;:564,&quot;bytes&quot;:47730,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194900139?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F275619b2-8c5d-4259-b689-afc37702fb69_792x525.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!LhX2!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F275619b2-8c5d-4259-b689-afc37702fb69_792x525.png 424w, /__u/substackcdn.com/image/fetch/$s_!LhX2!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F275619b2-8c5d-4259-b689-afc37702fb69_792x525.png 848w, /__u/substackcdn.com/image/fetch/$s_!LhX2!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F275619b2-8c5d-4259-b689-afc37702fb69_792x525.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LhX2!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F275619b2-8c5d-4259-b689-afc37702fb69_792x525.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>Concurrency means a system makes progress on multiple tasks during the same time period, but not necessarily at the same instant. On a single CPU core, concurrency is achieved by rapidly switching between tasks. The CPU works on task A for a few milliseconds, saves its state, switches to task B, then to task C, and back to task A. The switching happens so quickly that tasks appear to run simultaneously.</p><p>The primary goal of concurrency is to maximize CPU utilization by minimizing idle time. When one thread waits for I/O, a database query, or a network response, the CPU can switch to another thread and do useful work instead of sitting idle.</p><p><strong>How it works:</strong> The CPU performs context switching. It saves the current task&#8217;s state (program counter, registers) into memory, then loads the saved state of the next task and resumes execution. Context switching has overhead. Each switch consumes time and flushes CPU caches. Excessive switching degrades performance.</p><p><strong>Java example &#8212; concurrent task execution:</strong></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;java&quot;,&quot;nodeId&quot;:&quot;4a793754-5ffa-4f34-b981-27432f707bdc&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-java">public class ConcurrencyExample {
    public static void main(String[] args) {
        Thread taskA = new Thread(() -&gt; {
            for (int i = 1; i &lt;= 3; i++) {
                System.out.println(&#8221;Task A - Step &#8220; + i);
                try { Thread.sleep(100); } catch (InterruptedException e) {}
            }
        });
        
        Thread taskB = new Thread(() -&gt; {
            for (int i = 1; i &lt;= 3; i++) {
                System.out.println(&#8221;Task B - Step &#8220; + i);
                try { Thread.sleep(100); } catch (InterruptedException e) {}
            }
        });
        
        taskA.start();
        taskB.start();
    }
}</code></pre></div><p><strong>Sample output (interleaved):</strong></p><p>text</p><pre><code>Task A - Step 1
Task B - Step 1
Task A - Step 2
Task B - Step 2
Task A - Step 3
Task B - Step 3</code></pre><p>The tasks <strong>do not run simultaneously</strong>. The CPU interleaves them. On a single-core machine, only one thread executes at any given instant. On a multi-core machine, threads may also run in parallel, but the code above does not guarantee parallelism.</p><p><strong>Real-world examples of concurrency:</strong></p><ul><li><p>Web browsers rendering a page while downloading images and responding to scroll events</p></li><li><p>Web servers (Apache, Nginx) handling thousands of client connections with fewer threads than connections</p></li><li><p>Chat applications processing incoming messages while updating the UI</p></li><li><p>Video games rendering graphics, processing input, and playing audio in overlapping time windows</p></li></ul><h3><strong>Parallelism</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!cxDs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!cxDs!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png 424w, /__u/substackcdn.com/image/fetch/$s_!cxDs!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png 848w, /__u/substackcdn.com/image/fetch/$s_!cxDs!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cxDs!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!cxDs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png" width="467" height="392.94884910485933" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:658,&quot;width&quot;:782,&quot;resizeWidth&quot;:467,&quot;bytes&quot;:62672,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194900139?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!cxDs!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png 424w, /__u/substackcdn.com/image/fetch/$s_!cxDs!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png 848w, /__u/substackcdn.com/image/fetch/$s_!cxDs!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cxDs!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a6b58e4-c586-4632-b77c-1f9894e7bff0_782x658.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>Parallelism means multiple tasks execute at exactly the same instant. This requires multiple CPU cores or multiple machines. A task is divided into smaller independent subtasks, and each subtask runs simultaneously on a separate processing unit.</p><p>The primary goal of parallelism is to increase throughput by doing more work per unit of time. If a task takes 10 seconds on one core, splitting it into 10 equal subtasks across 10 cores can theoretically complete in 1 second.</p><p><strong>How it works:</strong> The problem is divided into independent subtasks. Each subtask is assigned to a separate core. All cores execute simultaneously. Results are combined at the end.</p><p><strong>Java example &#8212; parallel computation using ForkJoinPool:</strong></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;java&quot;,&quot;nodeId&quot;:&quot;ef3ad958-d9da-4325-abbf-0318e5a4d739&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-java">import java.util.concurrent.RecursiveTask;
import java.util.concurrent.ForkJoinPool;

public class ParallelismExample extends RecursiveTask&lt;Long&gt; {
    private static final int THRESHOLD = 10_000;
    private final int[] array;
    private final int start;
    private final int end;
    
    public ParallelismExample(int[] array, int start, int end) {
        this.array = array;
        this.start = start;
        this.end = end;
    }
    
    @Override
    protected Long compute() {
        int length = end - start;
        if (length &lt;= THRESHOLD) {
            // Sequential computation for small chunks
            long sum = 0;
            for (int i = start; i &lt; end; i++) {
                sum += array[i];
            }
            return sum;
        } else {
            // Split and run in parallel
            int mid = start + length / 2;
            ParallelismExample left = new ParallelismExample(array, start, mid);
            ParallelismExample right = new ParallelismExample(array, mid, end);
            
            left.fork();  // Run left task asynchronously
            long rightResult = right.compute();  // Compute right task
            long leftResult = left.join();       // Wait for left task
            
            return leftResult + rightResult;
        }
    }
    
    public static void main(String[] args) {
        int[] array = new int[100_000];
        // Initialize array...
        
        ForkJoinPool pool = new ForkJoinPool();
        long sum = pool.invoke(new ParallelismExample(array, 0, array.length));
        System.out.println(&#8221;Sum: &#8220; + sum);
    }
}</code></pre></div><p><strong>Real-world examples of parallelism:</strong></p><ul><li><p>Machine learning training: datasets divided into batches, processed simultaneously across multiple GPUs</p></li><li><p>Video rendering: each frame rendered independently on a different core</p></li><li><p>Web crawlers: URL list split into chunks, fetched in parallel from multiple websites</p></li><li><p>Big data frameworks (Apache Spark): large datasets distributed across clusters for simultaneous processing</p></li><li><p>Scientific simulations: weather modeling, molecular dynamics divided across thousands of cores</p></li></ul><h3><strong>The Four Combinations</strong></h3><p>A system can be concurrent, parallel, both, or neither.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!1KdZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!1KdZ!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png 424w, /__u/substackcdn.com/image/fetch/$s_!1KdZ!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png 848w, /__u/substackcdn.com/image/fetch/$s_!1KdZ!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1KdZ!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!1KdZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png" width="1053" height="260" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:260,&quot;width&quot;:1053,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:34986,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194900139?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!1KdZ!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png 424w, /__u/substackcdn.com/image/fetch/$s_!1KdZ!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png 848w, /__u/substackcdn.com/image/fetch/$s_!1KdZ!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1KdZ!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c692b12-a718-405c-a0a0-60cecb22b375_1053x260.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><p><strong>Concurrent, not parallel:</strong> A single-core CPU running a web browser. The browser handles network requests, rendering, and user input by switching rapidly between tasks. Only one task executes at any instant, but progress is made on all of them.</p><p><strong>Parallel, not concurrent:</strong> A video rendering job divided into 8 frames, processed on 8 cores simultaneously. The system works on only one logical task (rendering the video), but that task is broken into parallel subtasks.</p><p><strong>Neither concurrent nor parallel:</strong> A batch script that reads a file, processes it line by line, and writes output. One thing happens at a time. No overlapping progress. No simultaneous execution.</p><p><strong>Concurrent and parallel:</strong> A multi-core web server handling thousands of client connections. Each connection is managed concurrently via threads or async I/O. Within each connection, work may also be parallelized across cores. This is the most common pattern in modern high-performance systems. The diagram below illustrates this</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Qkju!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Qkju!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png 424w, /__u/substackcdn.com/image/fetch/$s_!Qkju!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png 848w, /__u/substackcdn.com/image/fetch/$s_!Qkju!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Qkju!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Qkju!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png" width="451" height="492.4014687882497" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:892,&quot;width&quot;:817,&quot;resizeWidth&quot;:451,&quot;bytes&quot;:88883,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194900139?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Qkju!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png 424w, /__u/substackcdn.com/image/fetch/$s_!Qkju!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png 848w, /__u/substackcdn.com/image/fetch/$s_!Qkju!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Qkju!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c34d74-2f71-4d2d-8385-a9629579bf74_817x892.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!antM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!antM!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png 424w, /__u/substackcdn.com/image/fetch/$s_!antM!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png 848w, /__u/substackcdn.com/image/fetch/$s_!antM!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png 1272w, /__u/substackcdn.com/image/fetch/$s_!antM!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!antM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png" width="621" height="497.8056680161943" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cca7cf71-0633-4733-958c-6156743b33e4_988x792.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:792,&quot;width&quot;:988,&quot;resizeWidth&quot;:621,&quot;bytes&quot;:99957,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194900139?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!antM!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png 424w, /__u/substackcdn.com/image/fetch/$s_!antM!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png 848w, /__u/substackcdn.com/image/fetch/$s_!antM!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png 1272w, /__u/substackcdn.com/image/fetch/$s_!antM!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca7cf71-0633-4733-958c-6156743b33e4_988x792.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h3><strong>The Practical Takeaway</strong></h3><p>Concurrency is about structure. It is a way to write code that deals with multiple things at once without blocking. Parallelism is about execution. It is a way to use hardware to do more work per second.</p><p>You need concurrency when your system waits for I/O. You need parallelism when your system does heavy computation. Many systems need both. The Java examples above show the difference: threads for concurrency, ForkJoinPool for parallelism.</p><p>In system design interviews, using these terms correctly signals that you understand the difference. Describing a web server as &#8220;parallel&#8221; is wrong. It is concurrent. Describing a batch processing job as &#8220;concurrent&#8221; misses the point. It is parallel. Precision matters.</p><h2><strong>Percentiles and Tail Latency</strong></h2><p>Most people think about latency in terms of averages. The average is the sum of all request latencies divided by the number of requests. This single number hides almost everything that matters.</p><h3><strong>Why Average Latency Is Misleading</strong></h3><p>Take 100 API requests. 99 of them finish in 10 milliseconds. 1 request takes 10 seconds (10,000 milliseconds).</p><p>The average latency is:</p><p>text</p><pre><code>(99 &#215; 10ms + 1 &#215; 10,000ms) / 100 = 10,990ms / 100 = 109.9ms</code></pre><p>The average is about 110 milliseconds. That looks excellent. But one out of every hundred users just waited ten seconds. That user will not return. The average told you the system is fast. The user experienced a slow system. The average was useless.</p><h3><strong>What Percentiles Actually Measure</strong></h3><p></p><p>A percentile tells you: &#8220;X percent of requests are faster than this value.&#8221;</p><p><strong>P50 (the median):</strong> 50% of requests are faster than this. 50% are slower. Half your users experience latency below P50. Half experience latency above P50.</p><p><strong>P95:</strong> 95% of requests are faster than this. 5% of requests are slower. One out of every twenty users experiences latency above P95.</p><p><strong>P99:</strong> 99% of requests are faster than this. 1% of requests are slower. One out of every hundred users experiences latency above P99.</p><p><strong>P999:</strong> 99.9% of requests are faster than this. 0.1% of requests are slower. One out of every thousand users experiences latency above P999.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!8WQN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!8WQN!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png 424w, /__u/substackcdn.com/image/fetch/$s_!8WQN!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png 848w, /__u/substackcdn.com/image/fetch/$s_!8WQN!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8WQN!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!8WQN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png" width="1002" height="307" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:307,&quot;width&quot;:1002,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:29006,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194900139?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!8WQN!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png 424w, /__u/substackcdn.com/image/fetch/$s_!8WQN!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png 848w, /__u/substackcdn.com/image/fetch/$s_!8WQN!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8WQN!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64700c10-901a-4966-8607-5601b6ea13fa_1002x307.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h3><strong>The Same Example with Percentiles</strong></h3><p>The same 100 requests: 99 at 10ms, 1 at 10,000ms.</p><ul><li><p><strong>Average:</strong> 110ms (misleadingly good)</p></li><li><p><strong>P50:</strong> 10ms (half of requests are 10ms or faster)</p></li><li><p><strong>P95:</strong> 10ms (95% of requests are 10ms or faster)</p></li><li><p><strong>P99:</strong> 10,000ms (99% of requests are 10,000ms or faster)</p></li></ul><p>P99 tells the truth. One percent of requests take ten seconds. That is the number that matters.</p><p>Visualized graph with different numbers but same concept</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!SKvm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f92ed14-8c2c-471d-8bc3-2d746b0f0c4d_1600x800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!SKvm!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f92ed14-8c2c-471d-8bc3-2d746b0f0c4d_1600x800.png 424w, /__u/substackcdn.com/image/fetch/$s_!SKvm!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f92ed14-8c2c-471d-8bc3-2d746b0f0c4d_1600x800.png 848w, /__u/substackcdn.com/image/fetch/$s_!SKvm!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f92ed14-8c2c-471d-8bc3-2d746b0f0c4d_1600x800.png 1272w, /__u/substackcdn.com/image/fetch/$s_!SKvm!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f92ed14-8c2c-471d-8bc3-2d746b0f0c4d_1600x800.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!SKvm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f92ed14-8c2c-471d-8bc3-2d746b0f0c4d_1600x800.png" width="1456" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4f92ed14-8c2c-471d-8bc3-2d746b0f0c4d_1600x800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:728,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Long-tail Latency: Causes and Solutions&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Long-tail Latency: Causes and Solutions" title="Long-tail Latency: Causes and Solutions" srcset="/__u/substackcdn.com/image/fetch/$s_!SKvm!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f92ed14-8c2c-471d-8bc3-2d746b0f0c4d_1600x800.png 424w, /__u/substackcdn.com/image/fetch/$s_!SKvm!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f92ed14-8c2c-471d-8bc3-2d746b0f0c4d_1600x800.png 848w, /__u/substackcdn.com/image/fetch/$s_!SKvm!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f92ed14-8c2c-471d-8bc3-2d746b0f0c4d_1600x800.png 1272w, /__u/substackcdn.com/image/fetch/$s_!SKvm!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f92ed14-8c2c-471d-8bc3-2d746b0f0c4d_1600x800.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>Tail Latency</strong></h3><p>Tail latency means the high percentiles: P99, P999, and beyond. These represent the slowest requests, the ones at the far end of the distribution.</p><p>Why does tail latency matter more in distributed systems than in single services?</p><p>Imagine one request fans out to 100 different services in parallel. Each service has P99 = 100ms. That means each service has a 1% chance of being slower than 100ms.</p><p>The chance that all 100 services are faster than 100ms is:</p><p>text</p><pre><code>0.99 ^ 100 &#8776; 0.37</code></pre><p>That is 37%. The chance that at least one service is slower than 100ms is 63%.</p><p>Even though each individual service is fast 99% of the time, the overall request experiences tail latency 63% of the time. Tail latency multiplies.</p><h3><strong>So which measure to use for what?</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!twKX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!twKX!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png 424w, /__u/substackcdn.com/image/fetch/$s_!twKX!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png 848w, /__u/substackcdn.com/image/fetch/$s_!twKX!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png 1272w, /__u/substackcdn.com/image/fetch/$s_!twKX!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!twKX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png" width="1025" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:362,&quot;width&quot;:1025,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:45028,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194900139?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!twKX!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png 424w, /__u/substackcdn.com/image/fetch/$s_!twKX!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png 848w, /__u/substackcdn.com/image/fetch/$s_!twKX!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png 1272w, /__u/substackcdn.com/image/fetch/$s_!twKX!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa76f9e31-2bf7-4593-bb63-e056f9681995_1025x362.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Average latency tells you about the center of your distribution. But users do not experience the center. Each user experiences a single request. If that request is slow, the system is slow for that user. Percentiles measure what users actually feel.<br><br></p><p></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Stateful vs Stateless Architecture]]></title><description><![CDATA[Definition, know when to use what and the trade-offs]]></description><link>https://saifhatem.substack.com/p/stateful-vs-stateless-architecture</link><guid isPermaLink="false">https://saifhatem.substack.com/p/stateful-vs-stateless-architecture</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Mon, 20 Apr 2026 23:14:28 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!-_lj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1><strong>Stateful vs Stateless Architecture</strong></h1><p>Every backend system either remembers data across requests or it does not. This single distinction determines how you scale, how you deploy, and how much operational complexity you accept.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!-_lj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!-_lj!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png 424w, /__u/substackcdn.com/image/fetch/$s_!-_lj!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png 848w, /__u/substackcdn.com/image/fetch/$s_!-_lj!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-_lj!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!-_lj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:120226,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194851876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!-_lj!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png 424w, /__u/substackcdn.com/image/fetch/$s_!-_lj!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png 848w, /__u/substackcdn.com/image/fetch/$s_!-_lj!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-_lj!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b53e606-6795-43b0-b660-6f7a6338aebe_1200x630.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2><strong>Stateless Architecture</strong></h2><p>A stateless system retains no information between requests. Each request is handled entirely on its own, using only the data contained in that request plus whatever external storage the system queries. The server does not remember the client from one request to the next.</p><p>Consider a REST API that receives a request for <code>/users/42</code>. The request includes an authentication token. The server verifies the token, queries a database for the user, formats the response, and sends it back. The server then forgets everything. If the same client makes another request one second later, the server treats it as a completely new interaction.</p><p>This property enables perfect horizontal scaling. You can run ten identical copies behind a load balancer. Any copy can handle any request because no copy holds unique information. To handle more traffic, you add copies. To save money during quiet periods, you remove copies. The system does not care which copy receives which request.</p><p><strong>Examples of stateless systems:</strong></p><ul><li><p>RESTful APIs and web servers</p></li><li><p>Authentication services using JWTs or client-side tokens</p></li><li><p>Serverless functions (Lambda, Cloud Functions)</p></li><li><p>Most microservices in a well-designed architecture</p></li></ul><p><strong>Benefits:</strong></p><ul><li><p><em>High scalability:</em> Easily handles large numbers of requests without session management overhead.</p></li><li><p><em>Fault tolerance:</em> Each request is independent. A server failure affects only requests in flight, not persistent sessions.</p></li><li><p><em>Simplified load balancing:</em> Any server can handle any request. No sticky sessions required.</p></li><li><p><em>Better performance:</em> No session lookup overhead. Lower latency per request.</p></li><li><p><em>Simpler deployment:</em> No session state to synchronize during rolling updates.</p></li></ul><p><strong>The limitation:</strong> Stateless systems cannot do anything useful on their own. They process data but do not store it. Every stateless service depends on an external stateful system&#8212;a database, a cache, or an object store.</p><p>Here is an example of logging in to a stateless system with session-based authentication</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!DtqD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d83823-454e-4e56-af04-656361f87c12_493x687.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!DtqD!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d83823-454e-4e56-af04-656361f87c12_493x687.png 424w, /__u/substackcdn.com/image/fetch/$s_!DtqD!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d83823-454e-4e56-af04-656361f87c12_493x687.png 848w, /__u/substackcdn.com/image/fetch/$s_!DtqD!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d83823-454e-4e56-af04-656361f87c12_493x687.png 1272w, /__u/substackcdn.com/image/fetch/$s_!DtqD!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d83823-454e-4e56-af04-656361f87c12_493x687.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!DtqD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d83823-454e-4e56-af04-656361f87c12_493x687.png" width="493" height="687" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/96d83823-454e-4e56-af04-656361f87c12_493x687.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:687,&quot;width&quot;:493,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:38893,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194851876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d83823-454e-4e56-af04-656361f87c12_493x687.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!DtqD!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d83823-454e-4e56-af04-656361f87c12_493x687.png 424w, /__u/substackcdn.com/image/fetch/$s_!DtqD!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d83823-454e-4e56-af04-656361f87c12_493x687.png 848w, /__u/substackcdn.com/image/fetch/$s_!DtqD!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d83823-454e-4e56-af04-656361f87c12_493x687.png 1272w, /__u/substackcdn.com/image/fetch/$s_!DtqD!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d83823-454e-4e56-af04-656361f87c12_493x687.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h2><strong>Stateful Architecture</strong></h2><p>A stateful system retains information across requests. It maintains client-specific state that future requests depend on. If the system crashes, that state may be lost or corrupted.</p><p>Consider a traditional web application where a user logs in, adds items to a shopping cart, and proceeds to checkout. The server stores the login session and cart contents in memory. Subsequent requests assume the server remembers this context.</p><p>A database is the canonical(standard) stateful system. You write a record, and you expect to read it later. A cache is stateful. You store a computed value, and you expect subsequent requests to find it. A message queue is stateful. You send a message, and you expect it to be delivered even if the consumer crashes at that exact moment.</p><p><strong>Examples of stateful systems:</strong></p><ul><li><p>Databases (PostgreSQL, MySQL, MongoDB, DynamoDB)</p></li><li><p>Caches (Redis, Memcached)</p></li><li><p>Message queues (Kafka, RabbitMQ, SQS)</p></li><li><p>Any service that stores session data in local memory</p></li></ul><p><strong>Benefits:</strong></p><ul><li><p><em>Session persistence:</em> Maintains user context across multiple requests or devices.</p></li><li><p><em>Personalization:</em> Uses past interactions to deliver tailored experiences.</p></li><li><p><em>Centralized security:</em> Session management supports consistent authentication and authorization.</p></li></ul><p><strong>The difficulty:</strong> Stateful systems resist horizontal scaling. You cannot simply run ten copies of PostgreSQL behind a load balancer. Each copy would have different data. A write to copy A would not appear on copy B. Consistency would break.</p><h2><strong>Scaling Stateful Systems</strong></h2><p>When a stateful system becomes overloaded, you have four options.</p><p><strong>Vertical scaling</strong> means buying a bigger machine. More RAM, faster CPU, faster storage. This is simple and preserves consistency. It works until you hit the maximum size your cloud provider offers. A server with double the capacity often costs more than double the price.</p><p><strong>Read replicas</strong> create read-only copies of your data. Writes go to a single primary node. Reads can be distributed across many replicas. This works well for read-heavy workloads. It does nothing for write-heavy workloads. Replication lag means a write may take tens or hundreds of milliseconds to appear on replicas.</p><p><strong>Sharding</strong> splits data across many nodes by a key&#8212;user ID, region, tenant ID. Each node owns a subset of the data. This scales writes horizontally. It also adds enormous complexity. Queries that span multiple shards become slow or impossible. Rebalancing data when you add or remove nodes is a major operation. Transactions across shards are extremely difficult.</p><p><strong>Consistent hashing</strong> is a more sophisticated form of sharding that handles node changes more gracefully. It reduces rebalancing work but does not eliminate the fundamental complexity of distributed state.</p><p>Here is an example of logging in to a stateful system with session-based authentication</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!vfjz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!vfjz!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png 424w, /__u/substackcdn.com/image/fetch/$s_!vfjz!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png 848w, /__u/substackcdn.com/image/fetch/$s_!vfjz!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png 1272w, /__u/substackcdn.com/image/fetch/$s_!vfjz!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!vfjz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png" width="608" height="742" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:742,&quot;width&quot;:608,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:50895,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194851876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!vfjz!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png 424w, /__u/substackcdn.com/image/fetch/$s_!vfjz!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png 848w, /__u/substackcdn.com/image/fetch/$s_!vfjz!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png 1272w, /__u/substackcdn.com/image/fetch/$s_!vfjz!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c46f60e-875f-49d7-836f-642738b1fbe1_608x742.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h2><strong>The Shared-Nothing Fallacy</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Uzq_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F198baf36-225e-4787-bf55-9d5528833f24_735x322.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Uzq_!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F198baf36-225e-4787-bf55-9d5528833f24_735x322.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!Uzq_!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F198baf36-225e-4787-bf55-9d5528833f24_735x322.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!Uzq_!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F198baf36-225e-4787-bf55-9d5528833f24_735x322.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!Uzq_!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F198baf36-225e-4787-bf55-9d5528833f24_735x322.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Uzq_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F198baf36-225e-4787-bf55-9d5528833f24_735x322.jpeg" width="735" height="322" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/198baf36-225e-4787-bf55-9d5528833f24_735x322.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:322,&quot;width&quot;:735,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Shared Nothing v.s. Shared Disk Architectures: An Independent View | Ben  Stopford&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Shared Nothing v.s. Shared Disk Architectures: An Independent View | Ben  Stopford" title="Shared Nothing v.s. Shared Disk Architectures: An Independent View | Ben  Stopford" srcset="/__u/substackcdn.com/image/fetch/$s_!Uzq_!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F198baf36-225e-4787-bf55-9d5528833f24_735x322.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!Uzq_!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F198baf36-225e-4787-bf55-9d5528833f24_735x322.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!Uzq_!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F198baf36-225e-4787-bf55-9d5528833f24_735x322.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!Uzq_!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F198baf36-225e-4787-bf55-9d5528833f24_735x322.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Some architects claim to build &#8220;shared-nothing&#8221; stateful systems where each node owns its data and nodes do not communicate. This works for very specific workloads like map-reduce jobs that partition data and never need to join across partitions.</p><p>For most applications, shared-nothing is a trap. You will eventually need a query that touches multiple partitions. You will eventually need a transaction that updates two records on different nodes. You will eventually need to rebalance data because some nodes are hot and others are cold. Each of these requirements forces cross-node communication, and cross-node communication is where distributed systems become nightmares.</p><p>Start with a single stateful node. Scale it vertically as far as reasonable. Add read replicas when reads become the bottleneck. Only consider sharding when you have exhausted vertical scaling and replicas and have no other choice.</p><h2><strong>The Practical Rule</strong></h2><p>Make your services stateless by default. Push state into dedicated stateful systems designed to handle it.</p><p>The most common mistake is building stateful services. A web server that stores user sessions in local memory. A worker that tracks progress in a local file. A cron job that assumes it runs on the same machine each time. These patterns work during development and break the moment you try to scale horizontally.</p><p>State belongs in databases. Stateless logic belongs in your code.</p><h2><strong>When Stateful Services Make Sense</strong></h2><p>There are legitimate reasons to build a stateful service instead of using a database.</p><p><strong>You need single-digit microsecond latency.</strong> A database adds network hops. An in-memory stateful service on the same machine does not.</p><p><strong>You are doing complex event processing or stream processing.</strong> Systems like Apache Flink maintain operator state locally for performance reasons. They also implement exactly-once semantics and checkpointing to recover that state after failures. This is sophisticated and rarely necessary for typical applications.</p><p><strong>You are building a real-time collaborative application.</strong> Figma or Google Docs cannot push every keystroke through a database without unacceptable latency. They maintain state in memory on the server handling that session.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!budg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffc50c0c-b6d0-4fc6-9a38-ac323800e694_810x456.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!budg!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffc50c0c-b6d0-4fc6-9a38-ac323800e694_810x456.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!budg!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffc50c0c-b6d0-4fc6-9a38-ac323800e694_810x456.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!budg!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffc50c0c-b6d0-4fc6-9a38-ac323800e694_810x456.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!budg!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffc50c0c-b6d0-4fc6-9a38-ac323800e694_810x456.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!budg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffc50c0c-b6d0-4fc6-9a38-ac323800e694_810x456.jpeg" width="352" height="198.16296296296295" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ffc50c0c-b6d0-4fc6-9a38-ac323800e694_810x456.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:456,&quot;width&quot;:810,&quot;resizeWidth&quot;:352,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Google Docs, Sheets, and Slides Review: Simple, Free, and  Collaboration-Friendly | PCMag&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Google Docs, Sheets, and Slides Review: Simple, Free, and  Collaboration-Friendly | PCMag" title="Google Docs, Sheets, and Slides Review: Simple, Free, and  Collaboration-Friendly | PCMag" srcset="/__u/substackcdn.com/image/fetch/$s_!budg!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffc50c0c-b6d0-4fc6-9a38-ac323800e694_810x456.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!budg!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffc50c0c-b6d0-4fc6-9a38-ac323800e694_810x456.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!budg!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffc50c0c-b6d0-4fc6-9a38-ac323800e694_810x456.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!budg!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffc50c0c-b6d0-4fc6-9a38-ac323800e694_810x456.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>For everyone else, use a database.</p><h2><strong>Comparison Summary</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Ek9o!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Ek9o!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ek9o!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ek9o!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ek9o!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Ek9o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png" width="840" height="333" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:333,&quot;width&quot;:840,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:39528,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194851876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Ek9o!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ek9o!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ek9o!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ek9o!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12cc1bf7-b4eb-46ae-bb9d-827ee91cffc8_840x333.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Scalability 101: horizontal vs vertical, elasticity & bottlenecks]]></title><description><![CDATA[When to scale out vs up, how to spot a bottleneck, and capacity planning intuition you can apply immediately]]></description><link>https://saifhatem.substack.com/p/scalability-101-horizontal-vs-vertical</link><guid isPermaLink="false">https://saifhatem.substack.com/p/scalability-101-horizontal-vs-vertical</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Sun, 19 Apr 2026 19:57:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!a771!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Most systems don't fail because the code is wrong. They fail because the scaling strategy was mismatched to the problem. This is a practical guide to getting that strategy right.</p><h2><strong>The Two Fundamental Scaling Directions</strong></h2><p>When your system needs to handle more load, you have exactly two levers.<br></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!a771!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!a771!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png 424w, /__u/substackcdn.com/image/fetch/$s_!a771!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png 848w, /__u/substackcdn.com/image/fetch/$s_!a771!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png 1272w, /__u/substackcdn.com/image/fetch/$s_!a771!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!a771!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png" width="885" height="606" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:606,&quot;width&quot;:885,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:27128,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://saifhatem.substack.com/i/194720906?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!a771!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png 424w, /__u/substackcdn.com/image/fetch/$s_!a771!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png 848w, /__u/substackcdn.com/image/fetch/$s_!a771!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png 1272w, /__u/substackcdn.com/image/fetch/$s_!a771!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff112aa26-654b-4e5d-b960-1eb765f8e7ea_885x606.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p><strong>Vertical scaling (scale up)</strong> means making the existing machine more powerful. More RAM, faster CPU, bigger SSD. The main advantage is simplicity. Your architecture doesn&#8217;t change. The same database, the same application code, just running on a bigger instance.</p><p>The disadvantage is physics. There is a maximum size for any server. And even before you hit that limit, costs grow non-linearly. A server with twice the RAM might cost four times as much. Vertical scaling works until it doesn&#8217;t, and then you have no next step.</p><p><strong>Horizontal scaling (scale out)</strong> means adding more machines. Instead of one big server, you run ten smaller ones behind a load balancer. This is how Google and Amazon handle billions of requests. The theoretical limit is nearly infinite.</p><p>The disadvantage is complexity. Your service must be stateless, or you must manage distributed state. You need a load balancer. You need to handle partial failures. You need to think about consistency.</p><p>Most teams should start vertical, then move horizontal when vertical stops being economical.</p><h2><strong>Stateless vs Stateful</strong></h2><p>The single most important distinction in scaling is whether your service remembers things.</p><p><strong>Stateless services</strong> (web servers, API gateways, most microservices) are trivial to scale horizontally. Each request is independent. Add ten more servers, and you handle ten times the traffic. Remove five, and nothing breaks. This is where you want to be.</p><p><strong>Stateful services</strong> (databases, caches, message queues) remember data across requests. You cannot simply add more servers, because the new server doesn&#8217;t have the data. For these, you have options: read replicas (for read-heavy workloads), sharding (splitting data across servers), or vertical scaling (just buy a bigger database instance).</p><p>The practical rule: make everything stateless if you can. Push state to dedicated systems designed to handle it.<br></p><h2><br><strong>Elasticity</strong></h2><p>Elasticity is automatic horizontal scaling. The system adds capacity when demand rises and removes it when demand falls. This matters because traffic is rarely flat.</p><p>A typical SaaS product might see 10x traffic at 9 AM compared to 3 AM. If you provision for peak, you waste money for 18 hours a day. If you provision for average, you crash every morning.</p><p>Elasticity solves this. You set a metric (CPU utilization, queue depth, requests per second) and a target (keep CPU below 70%). When the metric exceeds the target, add servers. When it falls below, remove servers.</p><p>Most cloud providers offer this. AWS Auto Scaling Groups, Kubernetes Horizontal Pod Autoscaler, Azure Scale Sets. The hard part is choosing the right metric and avoiding oscillation (adding and removing the same server repeatedly).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!SG6y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19b1d49c-597f-49d8-a8bf-39b2dc722eb6_1280x720.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!SG6y!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19b1d49c-597f-49d8-a8bf-39b2dc722eb6_1280x720.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!SG6y!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19b1d49c-597f-49d8-a8bf-39b2dc722eb6_1280x720.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!SG6y!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19b1d49c-597f-49d8-a8bf-39b2dc722eb6_1280x720.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!SG6y!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19b1d49c-597f-49d8-a8bf-39b2dc722eb6_1280x720.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!SG6y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19b1d49c-597f-49d8-a8bf-39b2dc722eb6_1280x720.jpeg" width="1280" height="720" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/19b1d49c-597f-49d8-a8bf-39b2dc722eb6_1280x720.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:720,&quot;width&quot;:1280,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Amazon EC2 Auto Scaling Getting Started&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Amazon EC2 Auto Scaling Getting Started" title="Amazon EC2 Auto Scaling Getting Started" srcset="/__u/substackcdn.com/image/fetch/$s_!SG6y!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19b1d49c-597f-49d8-a8bf-39b2dc722eb6_1280x720.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!SG6y!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19b1d49c-597f-49d8-a8bf-39b2dc722eb6_1280x720.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!SG6y!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19b1d49c-597f-49d8-a8bf-39b2dc722eb6_1280x720.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!SG6y!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19b1d49c-597f-49d8-a8bf-39b2dc722eb6_1280x720.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h2><strong>Finding the Bottleneck</strong></h2><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!yNka!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8b7f9b-9907-420e-abf4-e7cd0bb77609_264x191.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!yNka!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8b7f9b-9907-420e-abf4-e7cd0bb77609_264x191.png 424w, /__u/substackcdn.com/image/fetch/$s_!yNka!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8b7f9b-9907-420e-abf4-e7cd0bb77609_264x191.png 848w, /__u/substackcdn.com/image/fetch/$s_!yNka!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8b7f9b-9907-420e-abf4-e7cd0bb77609_264x191.png 1272w, /__u/substackcdn.com/image/fetch/$s_!yNka!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8b7f9b-9907-420e-abf4-e7cd0bb77609_264x191.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!yNka!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8b7f9b-9907-420e-abf4-e7cd0bb77609_264x191.png" width="264" height="191" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5d8b7f9b-9907-420e-abf4-e7cd0bb77609_264x191.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:191,&quot;width&quot;:264,&quot;resizeWidth&quot;:264,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Techniques for Performance Bottleneck Analysis&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="Techniques for Performance Bottleneck Analysis" title="Techniques for Performance Bottleneck Analysis" srcset="/__u/substackcdn.com/image/fetch/$s_!yNka!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8b7f9b-9907-420e-abf4-e7cd0bb77609_264x191.png 424w, /__u/substackcdn.com/image/fetch/$s_!yNka!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8b7f9b-9907-420e-abf4-e7cd0bb77609_264x191.png 848w, /__u/substackcdn.com/image/fetch/$s_!yNka!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8b7f9b-9907-420e-abf4-e7cd0bb77609_264x191.png 1272w, /__u/substackcdn.com/image/fetch/$s_!yNka!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8b7f9b-9907-420e-abf4-e7cd0bb77609_264x191.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Every system has a weakest link. Finding it requires looking at the four basic resources.</p><p><strong>CPU</strong> is the easiest. If utilization is consistently above 70-80%, you are CPU-bound. Check load average against core count. On Linux, if load average is 8 on a 4-core machine, you have a queue.</p><p><strong>Memory</strong> is trickier. High utilization alone is fine (unused RAM is wasted RAM). Problems appear as swapping, OOM kills, or garbage collection overhead. Watch for swap usage above zero and for memory that grows forever (that&#8217;s a leak).</p><p><strong>Disk I/O</strong> shows up as high <code>io wait</code> in <code>top</code>. If the CPU is idle but processes are waiting, your disk is the problem. This is common with databases on spinning disks or with insufficient IOPS (Input/Output Operations per second).</p><p><strong>Network</strong> problems look like retransmitted packets, connection timeouts, or unexpectedly low throughput. Often this is not your code but your load balancer, firewall, or ISP.</p><p>The bottleneck is whichever resource hits 100% first while the others have room. Fix that one.</p><h2></h2><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://saifhatem.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Monolith, modular monolith, microservices — when does the split make sense?]]></title><description><![CDATA[monolith, modular monolith, microservices, SOA, stateful vs stateless, How to split correctly.]]></description><link>https://saifhatem.substack.com/p/monolith-modular-monolith-microservices</link><guid isPermaLink="false">https://saifhatem.substack.com/p/monolith-modular-monolith-microservices</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Sun, 15 Mar 2026 01:06:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Mf-n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Architecture decisions should revolve around your actual constraints.</strong> For a decade, microservices were sold as the destination. Netflix did it. Uber did it. So should you, right?</p><p>Not anymore. Amazon Prime Video <em>moved back</em> to a monolith for specific services. The modular monolith is now a serious contender.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!AIjb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff51241fc-59e8-4e02-959d-11e494007824_960x296.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!AIjb!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff51241fc-59e8-4e02-959d-11e494007824_960x296.png 424w, /__u/substackcdn.com/image/fetch/$s_!AIjb!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff51241fc-59e8-4e02-959d-11e494007824_960x296.png 848w, /__u/substackcdn.com/image/fetch/$s_!AIjb!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff51241fc-59e8-4e02-959d-11e494007824_960x296.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AIjb!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff51241fc-59e8-4e02-959d-11e494007824_960x296.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!AIjb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff51241fc-59e8-4e02-959d-11e494007824_960x296.png" width="960" height="296" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f51241fc-59e8-4e02-959d-11e494007824_960x296.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:296,&quot;width&quot;:960,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&#1605;&#1604;&#1601;:Amazon Prime Video logo.svg - &#1608;&#1610;&#1603;&#1610;&#1576;&#1610;&#1583;&#1610;&#1575;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="&#1605;&#1604;&#1601;:Amazon Prime Video logo.svg - &#1608;&#1610;&#1603;&#1610;&#1576;&#1610;&#1583;&#1610;&#1575;" title="&#1605;&#1604;&#1601;:Amazon Prime Video logo.svg - &#1608;&#1610;&#1603;&#1610;&#1576;&#1610;&#1583;&#1610;&#1575;" srcset="/__u/substackcdn.com/image/fetch/$s_!AIjb!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff51241fc-59e8-4e02-959d-11e494007824_960x296.png 424w, /__u/substackcdn.com/image/fetch/$s_!AIjb!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff51241fc-59e8-4e02-959d-11e494007824_960x296.png 848w, /__u/substackcdn.com/image/fetch/$s_!AIjb!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff51241fc-59e8-4e02-959d-11e494007824_960x296.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AIjb!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff51241fc-59e8-4e02-959d-11e494007824_960x296.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The real question: when does splitting actually make sense?</p><p></p><h2><strong>The Starting Point: The Monolith</strong></h2><p>A monolithic architecture is the traditional model. It is a single, unified codebase where the UI, business logic, and data access layer are all developed, deployed, and scaled together .</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!E9pa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae8c7d0-6b29-4621-9ee0-5c4d023448bf_1600x1187.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!E9pa!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae8c7d0-6b29-4621-9ee0-5c4d023448bf_1600x1187.png 424w, /__u/substackcdn.com/image/fetch/$s_!E9pa!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae8c7d0-6b29-4621-9ee0-5c4d023448bf_1600x1187.png 848w, /__u/substackcdn.com/image/fetch/$s_!E9pa!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae8c7d0-6b29-4621-9ee0-5c4d023448bf_1600x1187.png 1272w, /__u/substackcdn.com/image/fetch/$s_!E9pa!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae8c7d0-6b29-4621-9ee0-5c4d023448bf_1600x1187.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!E9pa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae8c7d0-6b29-4621-9ee0-5c4d023448bf_1600x1187.png" width="1456" height="1080" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0ae8c7d0-6b29-4621-9ee0-5c4d023448bf_1600x1187.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1080,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Monolith vs Microservices vs Modular Monoliths: What's the Right Choice&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Monolith vs Microservices vs Modular Monoliths: What's the Right Choice" title="Monolith vs Microservices vs Modular Monoliths: What's the Right Choice" srcset="/__u/substackcdn.com/image/fetch/$s_!E9pa!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae8c7d0-6b29-4621-9ee0-5c4d023448bf_1600x1187.png 424w, /__u/substackcdn.com/image/fetch/$s_!E9pa!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae8c7d0-6b29-4621-9ee0-5c4d023448bf_1600x1187.png 848w, /__u/substackcdn.com/image/fetch/$s_!E9pa!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae8c7d0-6b29-4621-9ee0-5c4d023448bf_1600x1187.png 1272w, /__u/substackcdn.com/image/fetch/$s_!E9pa!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae8c7d0-6b29-4621-9ee0-5c4d023448bf_1600x1187.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>For early-stage products or small teams, this is often ideal. You have simplicity in development, ease of deployment (one build, one deploy), and straightforward debugging since everything runs in a single process . As Basecamp and the early years of Shopify have proven, you can get quite far with this model .</p><p>However, as the application grows, the &#8220;big ball of mud&#8221; risk appears. Components become tightly coupled. Scaling becomes an &#8220;all-or-nothing&#8221; proposition&#8212;you have to scale the entire app even if only one feature is overloaded.</p><h2><strong>The Middle Ground: The Modular Monolith</strong></h2><p>This is where the <strong>Modular Monolith</strong> comes in. It is the most underrated architecture in software today.</p><p>A modular monolith is still a single deployable unit, but it is internally structured into distinct, independent modules. Each module is responsible for a specific business domain (like Payments or Inventory) and communicates with others through well-defined, internal APIs .</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!4r9g!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19137daf-7220-413c-a0b5-e0931f11f044_693x386.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!4r9g!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19137daf-7220-413c-a0b5-e0931f11f044_693x386.png 424w, /__u/substackcdn.com/image/fetch/$s_!4r9g!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19137daf-7220-413c-a0b5-e0931f11f044_693x386.png 848w, /__u/substackcdn.com/image/fetch/$s_!4r9g!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19137daf-7220-413c-a0b5-e0931f11f044_693x386.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4r9g!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19137daf-7220-413c-a0b5-e0931f11f044_693x386.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!4r9g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19137daf-7220-413c-a0b5-e0931f11f044_693x386.png" width="693" height="386" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/19137daf-7220-413c-a0b5-e0931f11f044_693x386.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:386,&quot;width&quot;:693,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Microservices Killer: Modular Monolithic Architecture | by Mehmet Ozkaya |  Design Microservices Architecture with Patterns &amp; Principles | Medium&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Microservices Killer: Modular Monolithic Architecture | by Mehmet Ozkaya |  Design Microservices Architecture with Patterns &amp; Principles | Medium" title="Microservices Killer: Modular Monolithic Architecture | by Mehmet Ozkaya |  Design Microservices Architecture with Patterns &amp; Principles | Medium" srcset="/__u/substackcdn.com/image/fetch/$s_!4r9g!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19137daf-7220-413c-a0b5-e0931f11f044_693x386.png 424w, /__u/substackcdn.com/image/fetch/$s_!4r9g!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19137daf-7220-413c-a0b5-e0931f11f044_693x386.png 848w, /__u/substackcdn.com/image/fetch/$s_!4r9g!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19137daf-7220-413c-a0b5-e0931f11f044_693x386.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4r9g!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19137daf-7220-413c-a0b5-e0931f11f044_693x386.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>Why choose this?</strong></h3><p>It offers the best of both worlds: the operational simplicity of a monolith with the logical separation of microservices.</p><ul><li><p><strong>Future Flexibility:</strong> If you design your boundaries well, you have a clear migration path. You can extract a module into a full-blown microservice later without a rewrite .</p></li><li><p><strong>Team Scaling:</strong> Different teams can own different modules with minimal interference, as long as they respect the internal API contracts .</p></li><li><p><strong>Cost:</strong> It avoids the massive infrastructure costs of Kubernetes clusters, API gateways, and service meshes .</p></li></ul><p>A modular monolith is usually the answer for teams of 10&#8211;50 developers. It gives you structure without the distributed systems headache .</p><h2><strong>The Destination (When Necessary): Microservices</strong></h2><p>Microservices take modularity and push it to the network. Each service is independently deployable, has its own database, and scales independently .</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!imlH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1122cad5-0d66-473e-b2ae-ef569ff64a10_937x537.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!imlH!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1122cad5-0d66-473e-b2ae-ef569ff64a10_937x537.png 424w, /__u/substackcdn.com/image/fetch/$s_!imlH!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1122cad5-0d66-473e-b2ae-ef569ff64a10_937x537.png 848w, /__u/substackcdn.com/image/fetch/$s_!imlH!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1122cad5-0d66-473e-b2ae-ef569ff64a10_937x537.png 1272w, /__u/substackcdn.com/image/fetch/$s_!imlH!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1122cad5-0d66-473e-b2ae-ef569ff64a10_937x537.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!imlH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1122cad5-0d66-473e-b2ae-ef569ff64a10_937x537.png" width="937" height="537" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1122cad5-0d66-473e-b2ae-ef569ff64a10_937x537.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:537,&quot;width&quot;:937,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Microservices Architecture for Enterprise Large-Scaled Application | by  Mehmet Ozkaya | Design Microservices Architecture with Patterns &amp;  Principles | Medium&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Microservices Architecture for Enterprise Large-Scaled Application | by  Mehmet Ozkaya | Design Microservices Architecture with Patterns &amp;  Principles | Medium" title="Microservices Architecture for Enterprise Large-Scaled Application | by  Mehmet Ozkaya | Design Microservices Architecture with Patterns &amp;  Principles | Medium" srcset="/__u/substackcdn.com/image/fetch/$s_!imlH!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1122cad5-0d66-473e-b2ae-ef569ff64a10_937x537.png 424w, /__u/substackcdn.com/image/fetch/$s_!imlH!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1122cad5-0d66-473e-b2ae-ef569ff64a10_937x537.png 848w, /__u/substackcdn.com/image/fetch/$s_!imlH!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1122cad5-0d66-473e-b2ae-ef569ff64a10_937x537.png 1272w, /__u/substackcdn.com/image/fetch/$s_!imlH!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1122cad5-0d66-473e-b2ae-ef569ff64a10_937x537.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Think of the API Gateway as a director to what service the request should go to for now, this will be discussed in detail later.</p><p>The benefits are real, but they only appear once you cross a specific threshold of complexity.</p><ul><li><p><strong>Granular Scaling:</strong> Your payment service gets hammered during the holidays? Scale just that service .</p></li><li><p><strong>Team Autonomy:</strong> Large organizations can have teams working independently on different services without stepping on each other&#8217;s toes .</p></li><li><p><strong>Technology Diversity:</strong> You can use Python for ML services and Go for the low-latency API gateway .</p></li></ul><p>However, the disadvantages are significant. You trade simple code complexity for operational complexity. You now need to manage network latency, distributed tracing, and service discovery</p><h2><strong>SOA and The State Conversation</strong></h2><p>You can&#8217;t have this discussion without mentioning <strong>Service-Oriented Architecture (SOA)</strong> . Microservices are essentially a refinement of SOA. While SOA often focused on sharing a database and coarse-grained services communicating through an Enterprise Service Bus (ESB), microservices aim for finer granularity and decentralized data management .</p><p><br>Note: Enterprise Service Bus is the <strong>central nervous system of SOA</strong>, allowing services to communicate smoothly, transform data, and integrate diverse applications without tight coupling</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Zib0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28faa492-411c-47c7-8b52-cb4595050970_1600x900.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Zib0!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28faa492-411c-47c7-8b52-cb4595050970_1600x900.png 424w, /__u/substackcdn.com/image/fetch/$s_!Zib0!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28faa492-411c-47c7-8b52-cb4595050970_1600x900.png 848w, /__u/substackcdn.com/image/fetch/$s_!Zib0!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28faa492-411c-47c7-8b52-cb4595050970_1600x900.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Zib0!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28faa492-411c-47c7-8b52-cb4595050970_1600x900.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Zib0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28faa492-411c-47c7-8b52-cb4595050970_1600x900.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/28faa492-411c-47c7-8b52-cb4595050970_1600x900.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;5 Misconceptions about Microservices - mobileLIVE&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="5 Misconceptions about Microservices - mobileLIVE" title="5 Misconceptions about Microservices - mobileLIVE" srcset="/__u/substackcdn.com/image/fetch/$s_!Zib0!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28faa492-411c-47c7-8b52-cb4595050970_1600x900.png 424w, /__u/substackcdn.com/image/fetch/$s_!Zib0!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28faa492-411c-47c7-8b52-cb4595050970_1600x900.png 848w, /__u/substackcdn.com/image/fetch/$s_!Zib0!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28faa492-411c-47c7-8b52-cb4595050970_1600x900.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Zib0!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28faa492-411c-47c7-8b52-cb4595050970_1600x900.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>This leads to the critical distinction between <strong>Stateful vs. Stateless</strong>.</p><ul><li><p><strong>Stateless Services</strong> treat each request as an independent unit. They are ideal for distributed systems because stateless components can easily be replaced or scaled horizontally without worrying about where the session data went .</p></li><li><p><strong>Stateful Services</strong> retain session information. If you are building an online banking system, you need to know the history of transactions. The service must remember the &#8220;state&#8221; of the conversation .</p></li></ul><p>When you split a monolith, you are often forced to break apart stateful processes. This is hard. If you split incorrectly, you end up with a <strong>&#8220;Distributed Monolith&#8221;</strong> &#8212;where services are still tightly coupled through synchronous calls or shared databases, giving you all the pain of distribution with none of the agility</p><p></p><p></p><h2><strong>What to choose?</strong></h2><p>Most discussions present architecture as a straight line: you start with a monolith, and as you grow, you "graduate" to microservices.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Mf-n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Mf-n!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!Mf-n!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!Mf-n!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!Mf-n!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Mf-n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg" width="1000" height="563" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:563,&quot;width&quot;:1000,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Monolith vs Microservices by Simon Brown&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Monolith vs Microservices by Simon Brown" title="Monolith vs Microservices by Simon Brown" srcset="/__u/substackcdn.com/image/fetch/$s_!Mf-n!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!Mf-n!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!Mf-n!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!Mf-n!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91f5495d-34dc-4309-9cc8-91ba948ec617_1000x563.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Most people think architecture is a straight line from monolith to microservices. That&#8217;s wrong.</p><p><strong>Monolithic Big Ball of Mud &#8592;&#8594; Modular Monolith &#8592;&#8594; Microservices &#8592;&#8594; Distributed Big Ball of Mud</strong></p><p>The horizontal axis is <strong>number of deployment units</strong>. The vertical axis is <strong>modularity</strong>&#8212;how clean your boundaries are.</p><p>Here&#8217;s the trap: <strong>modularity is not automatic.</strong></p><p>You can have one deploy unit with terrible boundaries. That&#8217;s the classic big ball of mud on the left. Everything coupled, changes terrifying.</p><p>You can also have many deploy units with terrible boundaries. That&#8217;s the distributed big ball of mud on the right. Your spaghetti is now spread across a network. Services call services in cycles, debugging is hell, and you have all the pain of distributed systems with none of the benefits.</p><p>The peak high modularity, few deploy units is the <strong>modular monolith</strong>. This is the sweet spot.</p><p>The goal isn&#8217;t to reach the far right. <strong>The goal is to climb high on modularity before you&#8217;re forced to increase deployment units.</strong></p><p></p><h3><strong>The Verdict: When to Move</strong></h3><p>You don&#8217;t choose an architecture for today; you choose it for the pain you&#8217;re willing to accept tomorrow.</p><p><strong>Start here: The Modular Monolith</strong><br>Unless you have forty engineers on day one, build here. Enforce strict boundaries between domains (Checkout, Inventory, Users) even within one deploy unit. You get the simplicity of a monolith with the discipline of microservices. This is your home base.</p><p><strong>The Litmus Test: &#8220;Does this hurt?&#8221;</strong><br>You only move right when the modular monolith physically prevents progress. Split when you feel one of three pains:</p><ol><li><p><strong>The Team Bottleneck:</strong> Multiple teams constantly block each other&#8217;s deploys. <strong>Conway&#8217;s Law</strong> is strangling you.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Duef!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae03e0b-4a7e-40aa-b54c-9d693047f34b_1536x1024.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Duef!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae03e0b-4a7e-40aa-b54c-9d693047f34b_1536x1024.webp 424w, /__u/substackcdn.com/image/fetch/$s_!Duef!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae03e0b-4a7e-40aa-b54c-9d693047f34b_1536x1024.webp 848w, /__u/substackcdn.com/image/fetch/$s_!Duef!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae03e0b-4a7e-40aa-b54c-9d693047f34b_1536x1024.webp 1272w, /__u/substackcdn.com/image/fetch/$s_!Duef!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae03e0b-4a7e-40aa-b54c-9d693047f34b_1536x1024.webp 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Duef!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae03e0b-4a7e-40aa-b54c-9d693047f34b_1536x1024.webp" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0ae03e0b-4a7e-40aa-b54c-9d693047f34b_1536x1024.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Conway's Law: What It Is and How It Affects Software Development - Nextage  Blog&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Conway's Law: What It Is and How It Affects Software Development - Nextage  Blog" title="Conway's Law: What It Is and How It Affects Software Development - Nextage  Blog" srcset="/__u/substackcdn.com/image/fetch/$s_!Duef!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae03e0b-4a7e-40aa-b54c-9d693047f34b_1536x1024.webp 424w, /__u/substackcdn.com/image/fetch/$s_!Duef!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae03e0b-4a7e-40aa-b54c-9d693047f34b_1536x1024.webp 848w, /__u/substackcdn.com/image/fetch/$s_!Duef!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae03e0b-4a7e-40aa-b54c-9d693047f34b_1536x1024.webp 1272w, /__u/substackcdn.com/image/fetch/$s_!Duef!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ae03e0b-4a7e-40aa-b54c-9d693047f34b_1536x1024.webp 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div></li><li><p><strong>The Scaling Cliff:</strong> One hungry module (video transcoding, reporting) needs to scale independently, but you&#8217;re forced to scale the whole app. e.g. 1 service needs much more storage than another one.</p></li><li><p><strong>The Blast Radius:</strong> A bug in &#8220;Forgot Password&#8221; crashes &#8220;Checkout.&#8221; Failure is no longer contained.</p></li></ol><p><strong>The Guardrail:</strong><br>If you don&#8217;t have at least two engineers dedicated to managing distributed systems complexity, you aren&#8217;t ready to leave the modular monolith. Otherwise, you&#8217;ll skip straight to the distributed big ball of mud.</p><div><hr></div><p><strong>The Final Line:</strong><br>The modular monolith is where you build products. Microservices are where you contain chaos.</p><p>Move right when it hurts. Not a moment before.</p>]]></content:encoded></item><item><title><![CDATA[What is system design, really?]]></title><description><![CDATA[Functional/non-functional reqs, trade-off thinking, scalability/reliability/maintainability]]></description><link>https://saifhatem.substack.com/p/what-is-system-design-really</link><guid isPermaLink="false">https://saifhatem.substack.com/p/what-is-system-design-really</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Fri, 13 Mar 2026 12:33:05 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/25a2fcee-93d1-4bfd-a99e-f620de79aaf5_1006x565.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1><strong>The Blueprint - Why &#8220;How Well&#8221; Matters More Than &#8220;What&#8221;</strong></h1><p><strong>Welcome to the first principles of System Design.</strong></p><p>If you&#8217;ve ever stared at a blank whiteboard with the prompt <em>&#8220;Design Twitter&#8221;</em> or <em>&#8220;Design Uber,&#8221;</em> you know the feeling of panic that sets in. Where do you even start? Do you talk about databases first? Load balancers? Microservices?</p><p>The difference between a junior engineer and a senior architect isn&#8217;t the ability to regurgitate tech buzzwords. It is the ability to <strong>frame the problem</strong>.</p><p>Before you draw a single box on a whiteboard, you must establish the rules of the game. In the world of software architecture, the rules are set by two types of requirements: <strong>Functional</strong> and <strong>Non-Functional</strong>. Understanding the tension between them is the essence of trade-off thinking, which in turn dictates the scalability, reliability, and maintainability of your system.</p><p>This is the framing every great interview starts with.</p><h2><strong>The &#8220;What&#8221; vs. The &#8220;How Well&#8221;</strong></h2><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!koNF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad4e9dfc-0392-4946-9a31-8833eb1f05a0_677x192.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!koNF!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad4e9dfc-0392-4946-9a31-8833eb1f05a0_677x192.png 424w, /__u/substackcdn.com/image/fetch/$s_!koNF!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad4e9dfc-0392-4946-9a31-8833eb1f05a0_677x192.png 848w, /__u/substackcdn.com/image/fetch/$s_!koNF!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad4e9dfc-0392-4946-9a31-8833eb1f05a0_677x192.png 1272w, /__u/substackcdn.com/image/fetch/$s_!koNF!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad4e9dfc-0392-4946-9a31-8833eb1f05a0_677x192.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!koNF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad4e9dfc-0392-4946-9a31-8833eb1f05a0_677x192.png" width="677" height="192" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ad4e9dfc-0392-4946-9a31-8833eb1f05a0_677x192.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:192,&quot;width&quot;:677,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Functional vs Non Functional Requirements&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Functional vs Non Functional Requirements" title="Functional vs Non Functional Requirements" srcset="/__u/substackcdn.com/image/fetch/$s_!koNF!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad4e9dfc-0392-4946-9a31-8833eb1f05a0_677x192.png 424w, /__u/substackcdn.com/image/fetch/$s_!koNF!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad4e9dfc-0392-4946-9a31-8833eb1f05a0_677x192.png 848w, /__u/substackcdn.com/image/fetch/$s_!koNF!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad4e9dfc-0392-4946-9a31-8833eb1f05a0_677x192.png 1272w, /__u/substackcdn.com/image/fetch/$s_!koNF!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad4e9dfc-0392-4946-9a31-8833eb1f05a0_677x192.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p>Let&#8217;s start with a simple analogy. Imagine you&#8217;re designing a car.</p><ul><li><p>A <strong>Functional Requirement</strong> is: <em>&#8220;The car must take me from Point A to Point B.&#8221;</em></p></li><li><p>A <strong>Non-Functional Requirement (NFR)</strong> is: <em>&#8220;The car must take me from Point A to Point B <strong>in under 10 minutes, safely, without breaking down, and while consuming less than 10 gallons of fuel</strong>.&#8221;</em></p></li></ul><p>You can build a car that meets the functional requirement with a cardboard box, some duct tape, and a hill. But will anyone buy it? No.</p><p>In system design, <strong>functional requirements</strong> define <em>what</em> the system does. They are the features, the actions, the specific behaviors.</p><ul><li><p><em>&#8220;Users can post short text messages.&#8221;</em></p></li><li><p><em>&#8220;Users can view a timeline of posts from people they follow.&#8221;</em></p></li><li><p><em>&#8220;Drivers can share their location with riders.&#8221;</em></p></li></ul><p><strong>Non-functional requirements</strong> define <em>how well</em> the system performs those functions under specific conditions. They are the quality attributes . They are the constraints that make building the system hard .</p><ul><li><p><em>&#8220;Posts should appear in followers&#8217; timelines within 5 seconds.&#8221;</em> (Performance)</p></li><li><p><em>&#8220;The system should be operational 99.9% of the time.&#8221;</em> (Availability)</p></li><li><p><em>&#8220;The password must be encrypted.&#8221;</em> (Security)</p></li></ul><p>A system can be functionally perfect but completely useless if it fails its NFRs. If Twitter goes down every time a major event happens, or if it takes 30 seconds to load a timeline, the &#8220;what&#8221; (posting a tweet) doesn&#8217;t matter anymore .</p><h2><strong>Why Constraints Drive Design</strong></h2><p>Here is the golden rule of system design interviews: <strong>Your design is only as good as the constraints it operates under.</strong></p><p>When an interviewer gives you a problem, your first job is not to solve it. It is to quantify it. You must ask questions that uncover the hidden constraints .</p><p>If I ask you to design a URL shortener, and you assume it&#8217;s for a small internal team, you&#8217;ll design a simple app with a single database. Problem solved.</p><p>But what if the non-functional requirements are:</p><ol><li><p><strong>Scalability:</strong> 10 million URLs created per month.</p></li><li><p><strong>Performance:</strong> Redirects must happen in under 100ms.</p></li><li><p><strong>Durability:</strong> We cannot lose data.</p></li></ol><p>Suddenly, that simple database is a bottleneck. You now need caching (for performance), database sharding (for scale), and replication (for durability). The constraints <em>forced</em> you to design a distributed system . </p><h2><strong>Scalability, Reliability, and Maintainability</strong></h2><p>While there are dozens of NFRs (Security, Usability, Compliance, etc.), almost every system design conversation eventually boils down to three fundamental pillars. These are the qualities that separate a prototype from a production-grade system.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Vwsz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1551cf84-7d63-47b9-b647-f5820a743883_1400x764.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Vwsz!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1551cf84-7d63-47b9-b647-f5820a743883_1400x764.png 424w, /__u/substackcdn.com/image/fetch/$s_!Vwsz!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1551cf84-7d63-47b9-b647-f5820a743883_1400x764.png 848w, /__u/substackcdn.com/image/fetch/$s_!Vwsz!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1551cf84-7d63-47b9-b647-f5820a743883_1400x764.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Vwsz!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1551cf84-7d63-47b9-b647-f5820a743883_1400x764.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Vwsz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1551cf84-7d63-47b9-b647-f5820a743883_1400x764.png" width="1400" height="764" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1551cf84-7d63-47b9-b647-f5820a743883_1400x764.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:764,&quot;width&quot;:1400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Reliability, Scalability &amp; Maintainability Guide | Medium&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Reliability, Scalability &amp; Maintainability Guide | Medium" title="Reliability, Scalability &amp; Maintainability Guide | Medium" srcset="/__u/substackcdn.com/image/fetch/$s_!Vwsz!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1551cf84-7d63-47b9-b647-f5820a743883_1400x764.png 424w, /__u/substackcdn.com/image/fetch/$s_!Vwsz!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1551cf84-7d63-47b9-b647-f5820a743883_1400x764.png 848w, /__u/substackcdn.com/image/fetch/$s_!Vwsz!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1551cf84-7d63-47b9-b647-f5820a743883_1400x764.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Vwsz!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1551cf84-7d63-47b9-b647-f5820a743883_1400x764.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>1. Scalability (The Growth)</strong></h3><p>Can your system handle increased load? If your user base grows 10x, what breaks first?<br>There are two ways to grow:</p><ul><li><p><strong>Vertical Scaling:</strong> Buying a bigger machine (faster CPU, more RAM). This is simple but has a hard ceiling.</p></li><li><p><strong>Horizontal Scaling:</strong> Buying more machines. This is the holy grail of modern system design, but it introduces complexity in coordination and data distribution .</p></li></ul><p>When designing, you must consider <em>how</em> you will scale. Will you use load balancers? Will your database need to shard data across multiple servers? Will your services be stateless to allow easy replication? .</p><h3><strong>2. Reliability (The Uptime)</strong></h3><p>Can the system keep working when things break? In a distributed system, things <em>will</em> break. Hard drives fail, networks lag, services crash. <strong>Reliability</strong> (often tied to Availability) is about designing for failure .</p><p>This involves concepts like:</p><ul><li><p><strong>Redundancy:</strong> Having multiple copies of data (replication) and multiple instances of services.</p></li><li><p><strong>Failover:</strong> If one server dies, another automatically takes over without the user noticing.</p></li><li><p><strong>Consistency vs. Availability (The CAP Theorem):</strong> In a distributed system during a network failure, you must choose between giving the user stale data (Availability) or giving them an error (Consistency). There is no &#8220;right&#8221; answer; it depends on the system. A bank chooses consistency; a social media feed might choose availability .</p></li></ul><h3><strong>3. Maintainability (The Sanity)</strong></h3><p>Can future engineers (including future-you) work on this system without pulling their hair out?<br>A system that scales infinitely but requires a six-month onboarding process for a simple bug fix is a failure. Maintainability is about:</p><ul><li><p><strong>Operability:</strong> Making it easy for the operations team to keep the system running (good logging, monitoring, debugging tools).</p></li><li><p><strong>Simplicity:</strong> Managing complexity. Can new engineers understand the flow?</p></li><li><p><strong>Evolvability:</strong> Can you easily change the system to adapt to new requirements? This is where concepts like modularity and separation of concerns come into play .</p></li></ul><h2><strong>The Art of the Trade-Off</strong></h2><p>Here is the uncomfortable truth: <strong>You cannot have it all</strong> .</p><p>System design is not about finding the <em>perfect</em> architecture; it is about making the <em>best possible compromise</em> based on your priorities .</p><ul><li><p><strong>Consistency vs. Performance:</strong> If you want every user in the world to see the exact same number of &#8220;likes&#8221; on a post at the exact same time (strong consistency), you will likely slow down the system because servers have to talk to each other to agree.</p></li><li><p><strong>Scalability vs. Cost:</strong> You can design a system to handle 1 billion users, but if you only have 1,000 users, you&#8217;ve wasted money on unnecessary infrastructure .</p></li><li><p><strong>Latency vs. Throughput:</strong> Do you need a single request to be super fast, or do you need to handle a massive volume of requests, even if each one takes a little longer? Optimizing for one often hurts the other .</p></li></ul><h3><strong>A Practical Trade-Off: The Monolith vs. Microservices</strong></h3><ul><li><p><strong>Monolith (Simple Maintainability):</strong> Easier to develop, deploy, and debug. Great for startups or simple systems. <strong>Trade-off:</strong> Harder to scale individual components.</p></li><li><p><strong>Microservices (Scalability):</strong> Each service scales independently. <strong>Trade-off:</strong> Massively increases complexity in network communication, data consistency, and operations .</p></li></ul><p>There is no &#8220;better&#8221; choice. There is only the right choice <em>for your specific constraints</em>.</p><h2><strong>Conclusion: The Interview Mindset</strong></h2><p>As you start your journey into system design, shift your mindset from <em>&#8220;How do I build this?&#8221;</em> to <em>&#8220;What are the rules?&#8221;</em></p><p>When you walk into an interview, your first 5-10 minutes should be dedicated to clarifying the requirements. Ask questions like:</p><ul><li><p>&#8220;What is the scale we are designing for? DAUs? Total users?&#8221;</p></li><li><p>&#8220;What is more important: low latency for writes or strong consistency for reads?&#8221;</p></li><li><p>&#8220;Do we need to worry about global traffic?&#8221;</p></li></ul><p>By defining the functional and non-functional requirements, you aren&#8217;t just gathering info&#8212;you are building a fence around the problem. You are identifying the constraints that will guide every decision you make for the rest of the interview. You are showing the interviewer that you understand that architecture is not about drawing pretty diagrams, but about navigating complex trade-offs under pressure.</p>]]></content:encoded></item><item><title><![CDATA[System Design Introduction & Roadmap]]></title><description><![CDATA[Start here]]></description><link>https://saifhatem.substack.com/p/system-design-introduction-and-roadmap</link><guid isPermaLink="false">https://saifhatem.substack.com/p/system-design-introduction-and-roadmap</guid><dc:creator><![CDATA[Saif Hatem]]></dc:creator><pubDate>Thu, 12 Mar 2026 15:29:56 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!cGG7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div><hr></div><p>System design is the process of defining the architecture, components, modules, interfaces, and data for a system to satisfy specified requirements. It&#8217;s a critical skill for building scalable, reliable, and efficient software systems that can handle real-world demands.</p><p>We&#8217;ll follow a structured approach to understanding system design principles, patterns, and best practices. Whether you&#8217;re preparing for interviews or building production systems, this resource will help you master the fundamentals and advanced concepts of designing distributed systems.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img processing" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!cGG7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!cGG7!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif 424w, /__u/substackcdn.com/image/fetch/$s_!cGG7!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif 848w, /__u/substackcdn.com/image/fetch/$s_!cGG7!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif 1272w, /__u/substackcdn.com/image/fetch/$s_!cGG7!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_webp, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!cGG7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif" width="800" height="918" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:918,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3783517,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://trimbex.substack.com/i/190736484?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif&quot;,&quot;isProcessing&quot;:true,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!cGG7!, /__u/saifhatem.substack.com/w_424, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif 424w, /__u/substackcdn.com/image/fetch/$s_!cGG7!, /__u/saifhatem.substack.com/w_848, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif 848w, /__u/substackcdn.com/image/fetch/$s_!cGG7!, /__u/saifhatem.substack.com/w_1272, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif 1272w, /__u/substackcdn.com/image/fetch/$s_!cGG7!, /__u/saifhatem.substack.com/w_1456, /__u/saifhatem.substack.com/c_limit, /__u/saifhatem.substack.com/f_auto, /__u/saifhatem.substack.com/q_auto:good, /__u/saifhatem.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4951969-be3e-4f7c-8dfa-c4dc06bcbdce_800x918.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div><hr></div><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;&quot;,&quot;id&quot;:&quot;CCJSMTVVFH&quot;}" data-component-name="LatexBlockToDOM"></div><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;&quot;,&quot;id&quot;:&quot;MTOJRTLAQT&quot;}" data-component-name="LatexBlockToDOM"></div><p></p>]]></content:encoded></item></channel></rss>