<?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 System Design Newsletter]]></title><description><![CDATA[Download my system design playbook on newsletter signup for FREE]]></description><link>https://newsletter.systemdesign.one</link><image><url>https://substackcdn.com/image/fetch/$s_!W5r-!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1c8067a-95bb-416b-9114-e0b9fb8821d4_256x256.png</url><title>The System Design Newsletter</title><link>https://newsletter.systemdesign.one</link></image><generator>Substack</generator><lastBuildDate>Sun, 03 May 2026 09:48:06 GMT</lastBuildDate><atom:link href="https://newsletter.systemdesign.one/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Neo Kim]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[systemdesignone@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[systemdesignone@substack.com]]></itunes:email><itunes:name><![CDATA[Neo Kim]]></itunes:name></itunes:owner><itunes:author><![CDATA[Neo Kim]]></itunes:author><googleplay:owner><![CDATA[systemdesignone@substack.com]]></googleplay:owner><googleplay:email><![CDATA[systemdesignone@substack.com]]></googleplay:email><googleplay:author><![CDATA[Neo Kim]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Multi-Agent Architectures, Clearly Explained]]></title><description><![CDATA[#143: Coordination architectures, protocols connecting them, and how to pick the right one before you write any code.]]></description><link>https://newsletter.systemdesign.one/p/multi-agent-system</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/multi-agent-system</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Thu, 30 Apr 2026 07:57:47 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/5a5b731e-9631-4db0-9007-c42802f05c64_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/multi-agent-system/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>A single agent<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a> has one context window<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>, one set of tools<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a>, and one running loop<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a>.</p><p>When a task outgrows any of those three, you need more than one agent. That&#8217;s what a <strong>multi-agent system</strong> is. Instead of one agent doing everything, you split the work across many agents. Each one has its own role, tools, and context.</p><p>Most multi-agent systems fail not because the model is weak but because you chose many agents before you actually <em>need</em> them, or chose the <em>wrong</em> architecture once you have many agents.</p><p>So you shouldn&#8217;t split anything yet.</p><p>Onward.</p><div><hr></div><h2><strong><a href="https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary">[Webinar] Stop babysitting your coding agents (Partner)</a></strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2Yva!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 424w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 848w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 1272w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2Yva!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.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;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!2Yva!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 424w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 848w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 1272w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.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 role="img" 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><title></title><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>Agents can generate code. Getting it right for your system, team conventions, and past decisions is the hard part &#8211; you end up wasting time and tokens in correction loops.</p><p>More MCPs give agents access to information, but not understanding. The teams pulling ahead use a context engine to give agents exactly what they need.</p><p><strong><a href="https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary">Join Unblocked live on May 6 (FREE)</a></strong> to see:</p><ul><li><p>Where teams get stuck on the AI maturity curve</p></li><li><p>How a context engine solves for quality, efficiency, and cost</p></li><li><p>Live demo: the same coding task with and without a context engine</p></li></ul><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary&quot;,&quot;text&quot;:&quot;Register Now&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary"><span>Register Now</span></a></p><p>(Thanks to <strong><a href="https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary">Unblocked</a></strong> for partnering on this post.)</p><div><hr></div><p><strong>Here&#8217;s what&#8217;s inside:</strong></p><ul><li><p><strong>Why single agents break.</strong> Context overflow, slow serial work, and why one agent can&#8217;t always hold every tool, model, or permission.</p></li><li><p><strong>The six architectures.</strong> Orchestrator-worker, pipeline, hierarchical, swarm, mesh, and handoffs. Plus, where each one works and breaks.</p></li><li><p><strong>How agents coordinate.</strong> Run loops, MCP vs A2A, shared state, isolated state, memory, and stopping conditions.</p></li><li><p><strong>The real cost.</strong> Why more agents mean more tokens, more latency, more coordination overhead, and more ways to fail.</p></li><li><p><strong>Failure and security risks.</strong> Bad instructions, misalignment, weak verification, prompt injection, context contamination, and privilege creep.</p></li><li><p><strong>Case study.</strong> How Spotify used an orchestrator-worker system to turn ad planning from a 15-minute workflow into 5 seconds.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Golden members get all posts like these!&#8230;</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><hr></div><h2><strong>Limits of single-agent systems</strong></h2><p>One agent with good prompts and the right tools handles more than most people expect.</p><p>For example, Cognition&#8217;s Devin processed 5 million lines of COBOL (Common Business-Oriented Language) across 500GB of repositories with a single agent, raising its pull request merge rate from 34% to 67%.</p><p>But a single agent has three HARD limits. When your task runs into any of them, better prompts won&#8217;t help:</p><p><strong>1. Context overflow</strong></p><p>A context window can only hold so much.</p><p>Past that limit, the earliest information drops out, and the agent starts losing track of its own plan. When compression<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-5" href="#footnote-5" target="_self">5</a> alone can&#8217;t fix the overflow, a second agent with its own context can.</p><p><strong>2. Parallelism</strong></p><p>Independent tasks shouldn&#8217;t wait in line.</p><p>If you have four research queries that don&#8217;t depend on each other, running them one at a time wastes time. Running them across four separate agents takes roughly as long as the slowest one.</p><p>Anthropic&#8217;s research system uses this exact pattern and reduced total query time by up to 90%.</p><p><strong>3. Specialization</strong></p><p>Different parts of a task often need different models<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-6" href="#footnote-6" target="_self">6</a>, tools, or access levels:</p><ul><li><p>A code-writing agent needs a sandbox</p></li><li><p>A research agent needs web search</p></li><li><p>A customer-facing agent needs user data, but shouldn&#8217;t have access to production databases</p></li></ul><p>When one agent can&#8217;t hold all the tools and permissions the task needs, you give each role its own agent.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Lyuf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F912095e9-be3f-47dc-bed8-0c3307cc6d6e_1376x768.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Lyuf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F912095e9-be3f-47dc-bed8-0c3307cc6d6e_1376x768.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Lyuf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F912095e9-be3f-47dc-bed8-0c3307cc6d6e_1376x768.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Lyuf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F912095e9-be3f-47dc-bed8-0c3307cc6d6e_1376x768.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Lyuf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F912095e9-be3f-47dc-bed8-0c3307cc6d6e_1376x768.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Lyuf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F912095e9-be3f-47dc-bed8-0c3307cc6d6e_1376x768.jpeg" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/912095e9-be3f-47dc-bed8-0c3307cc6d6e_1376x768.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Decision flow for when to use multi-agent systems based on context overflow, parallelism, and specialization conditions&quot;,&quot;title&quot;:&quot;Decision flow for when to use multi-agent systems based on context overflow, parallelism, and specialization conditions&quot;,&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="Decision flow for when to use multi-agent systems based on context overflow, parallelism, and specialization conditions" title="Decision flow for when to use multi-agent systems based on context overflow, parallelism, and specialization conditions" srcset="https://substackcdn.com/image/fetch/$s_!Lyuf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F912095e9-be3f-47dc-bed8-0c3307cc6d6e_1376x768.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Lyuf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F912095e9-be3f-47dc-bed8-0c3307cc6d6e_1376x768.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Lyuf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F912095e9-be3f-47dc-bed8-0c3307cc6d6e_1376x768.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Lyuf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F912095e9-be3f-47dc-bed8-0c3307cc6d6e_1376x768.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 role="img" 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><title></title><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 none of those three conditions apply, stay with one agent.</p><p>Better prompts and better tools solve most problems without adding the extra work of coordinating agents. But once you know you need many agents, the next question is what shape the system takes...</p><div><hr></div><h2><strong>Multi-agent architectures</strong></h2><p>Every multi-agent system makes a different choice about who coordinates work.</p><p>Here are 6 architectures that range from <em>tight</em> central control to <em>NO</em> coordinator at all:</p><h3><strong>1. Orchestrator-worker</strong></h3><p>One central agent breaks a task into pieces, assigns each piece to a worker agent, and then puts the results together:</p><ul><li><p>Workers don&#8217;t talk to each other; all communication goes through a central agent</p></li><li><p>Orchestrator calls each worker as a <strong>tool call</strong><a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-7" href="#footnote-7" target="_self">7</a>, waits for a result, and decides what to do next</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cx-g!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb44f7f9-f66b-4af5-8681-7582076ac083_1376x768.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cx-g!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb44f7f9-f66b-4af5-8681-7582076ac083_1376x768.jpeg 424w, https://substackcdn.com/image/fetch/$s_!cx-g!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb44f7f9-f66b-4af5-8681-7582076ac083_1376x768.jpeg 848w, https://substackcdn.com/image/fetch/$s_!cx-g!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb44f7f9-f66b-4af5-8681-7582076ac083_1376x768.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!cx-g!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb44f7f9-f66b-4af5-8681-7582076ac083_1376x768.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cx-g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb44f7f9-f66b-4af5-8681-7582076ac083_1376x768.jpeg" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fb44f7f9-f66b-4af5-8681-7582076ac083_1376x768.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Orchestrator-worker architecture showing central agent connected to isolated workers with task and result arrows&quot;,&quot;title&quot;:&quot;Orchestrator-worker architecture showing central agent connected to isolated workers with task and result arrows&quot;,&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="Orchestrator-worker architecture showing central agent connected to isolated workers with task and result arrows" title="Orchestrator-worker architecture showing central agent connected to isolated workers with task and result arrows" srcset="https://substackcdn.com/image/fetch/$s_!cx-g!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb44f7f9-f66b-4af5-8681-7582076ac083_1376x768.jpeg 424w, https://substackcdn.com/image/fetch/$s_!cx-g!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb44f7f9-f66b-4af5-8681-7582076ac083_1376x768.jpeg 848w, https://substackcdn.com/image/fetch/$s_!cx-g!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb44f7f9-f66b-4af5-8681-7582076ac083_1376x768.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!cx-g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb44f7f9-f66b-4af5-8681-7582076ac083_1376x768.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 role="img" 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><title></title><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 like an air traffic control tower that talks to every plane, while no plane talks directly to another.</p><p>Anthropic&#8217;s Claude Research system works this way:</p><p>A central agent running Opus 4 breaks a research query into parts and creates 2 to 10 worker agents on Sonnet 4 (sometimes more), all at the same time. The workers search the web, read documents, and gather evidence in parallel. When they finish, the central agent reads their results and writes a single research report.</p><p>This setup beat single-agent Opus 4 by 90.2% on Anthropic&#8217;s internal research eval<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-8" href="#footnote-8" target="_self">8</a>.</p><h4><em><strong>Tradeoffs</strong></em></h4><p>Central agent is both coordinator and bottleneck&#8230;</p><p>It talks to workers one at a time. If each call takes 3 seconds and 20 workers are waiting, the ceiling is about 7 tasks per second. So the central agent becomes the slowest part of the system.</p><p>Anthropic&#8217;s Claude Research system had this problem as well: <em>workers duplicated each other&#8217;s work.</em></p><p>Without specific instructions, many workers run overlapping searches on the same topic, wasting both tokens<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-9" href="#footnote-9" target="_self">9</a> and time. The takeaway is orchestrator-worker depends entirely on the quality of the lead agent&#8217;s instructions.</p><p>Vague task splitting turns parallelism into duplicated work.</p><h3><strong>2. Pipeline</strong></h3><p>Agents run in a fixed order, one after another.</p><p>Each agent&#8217;s output becomes the next agent&#8217;s input, and entire sequence is set in advance. While orchestrator-worker lets the central agent decide what to do as it goes, pipeline removes that choice.</p><p>An assembly line works the same way: <em>each station does one job, passes the result forward, and never sees the finished product.</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8Wf-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97a1bc5e-e8e9-460f-a72b-9cf92adfeab2_1376x768.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8Wf-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97a1bc5e-e8e9-460f-a72b-9cf92adfeab2_1376x768.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8Wf-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97a1bc5e-e8e9-460f-a72b-9cf92adfeab2_1376x768.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8Wf-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97a1bc5e-e8e9-460f-a72b-9cf92adfeab2_1376x768.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8Wf-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97a1bc5e-e8e9-460f-a72b-9cf92adfeab2_1376x768.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8Wf-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97a1bc5e-e8e9-460f-a72b-9cf92adfeab2_1376x768.jpeg" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/97a1bc5e-e8e9-460f-a72b-9cf92adfeab2_1376x768.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Pipeline architecture showing agents in linear sequence with output contracts between stages&quot;,&quot;title&quot;:&quot;Pipeline architecture showing agents in linear sequence with output contracts between stages&quot;,&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="Pipeline architecture showing agents in linear sequence with output contracts between stages" title="Pipeline architecture showing agents in linear sequence with output contracts between stages" srcset="https://substackcdn.com/image/fetch/$s_!8Wf-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97a1bc5e-e8e9-460f-a72b-9cf92adfeab2_1376x768.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8Wf-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97a1bc5e-e8e9-460f-a72b-9cf92adfeab2_1376x768.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8Wf-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97a1bc5e-e8e9-460f-a72b-9cf92adfeab2_1376x768.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8Wf-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97a1bc5e-e8e9-460f-a72b-9cf92adfeab2_1376x768.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 role="img" 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><title></title><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>Stripe uses this pattern to check whether new businesses on its platform are legitimate.</p><p>Before agents, a human reviewer had to jump between customer databases, legal sources, and support tickets to decide whether a business was safe to approve. Now their engineering team broke that work into a fixed flow of agent stages using a directed acyclic graph (<strong>DAG</strong>). So work moves forward through stages without looping back.</p><p>Order is set at design time, and each stage has a <strong>contract</strong>: <em>defined output format next stage expects.</em></p><p>Stripe calls these contracts &#8220;rails&#8221; because they keep any single agent from spending too much time on irrelevant data. This setup cut their average handling time by 26%, and reviewers rated the agent outputs 96% helpful, with a full record of every decision at every step.</p><h4><em><strong>Tradeoffs</strong></em></h4><p>Latency adds up.</p><p>A 5-stage pipeline where each stage takes 2 seconds means a 10-second wait before any output, and adding a stage to improve quality increases the response time.</p><p>Yet the upside is predictability.</p><p>When every stage has a narrow contract, you can trace any failure back to exactly one step. That&#8217;s why regulated workflows like Stripe&#8217;s continue to use pipelines.</p><p>When the cost of being wrong is a regulator flagging your process, the extra seconds are a small price to pay.</p><h3><strong>3. Hierarchical</strong></h3><p>A top-level manager agent gives work to one or more layers of manager agents below it, which then give work to individual workers.</p><p>Two levels are the minimum; big systems stack more. The result is a tree&#8230;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Yce7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602c6fef-d9d1-4e7f-82dd-674e34d78ed9_1376x768.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Yce7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602c6fef-d9d1-4e7f-82dd-674e34d78ed9_1376x768.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Yce7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602c6fef-d9d1-4e7f-82dd-674e34d78ed9_1376x768.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Yce7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602c6fef-d9d1-4e7f-82dd-674e34d78ed9_1376x768.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Yce7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602c6fef-d9d1-4e7f-82dd-674e34d78ed9_1376x768.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Yce7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602c6fef-d9d1-4e7f-82dd-674e34d78ed9_1376x768.jpeg" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/602c6fef-d9d1-4e7f-82dd-674e34d78ed9_1376x768.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Hierarchical architecture showing tree structure with top manager, mid-level managers, and worker agents&quot;,&quot;title&quot;:&quot;Hierarchical architecture showing tree structure with top manager, mid-level managers, and worker agents&quot;,&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="Hierarchical architecture showing tree structure with top manager, mid-level managers, and worker agents" title="Hierarchical architecture showing tree structure with top manager, mid-level managers, and worker agents" srcset="https://substackcdn.com/image/fetch/$s_!Yce7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602c6fef-d9d1-4e7f-82dd-674e34d78ed9_1376x768.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Yce7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602c6fef-d9d1-4e7f-82dd-674e34d78ed9_1376x768.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Yce7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602c6fef-d9d1-4e7f-82dd-674e34d78ed9_1376x768.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Yce7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602c6fef-d9d1-4e7f-82dd-674e34d78ed9_1376x768.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 role="img" 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><title></title><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>No single agent needs the full context.</p><p>The top-level agent holds the high-level goal and a summary from each branch, while each lower level sees only what its narrower role needs. Picture a military chain of command where orders flow down, reports flow up, and no one skips a level.</p><p>IBM watsonx Orchestrate runs on this pattern:</p><p>A top-level supervisor agent acts as a router and planner across 80+ pre-built domain agents for HR, sales, and procurement. Let&#8217;s say a user tries to &#8220;order new laptops for the design team&#8221;. The request reaches a Procure Equipment supervisor, who then hands the work to <em>three specialized child agents</em>:</p><ul><li><p>One requests quotes from approved vendors</p></li><li><p>Another checks responses</p></li><li><p>A third submits a purchase request</p></li></ul><p>The supervisor decides only who gets called and in which order.</p><h4><em><strong>Tradeoffs</strong></em></h4><p>Details might get lost at each level.</p><p>A worker produces a detailed result. The mid-level manager shortens it to one sentence. By the time it reaches the top, the detail that matters might be gone. Hierarchical structures trade detail for coverage: the higher you go, the wider the scope of each agent and the less it knows about any specific piece.</p><div><hr></div><p><em>These three architectures share one thing: a clear chain of command tells you exactly who&#8217;s in charge&#8230;</em></p><p><em>The next three architectures drop the chain entirely. So they're harder to debug, but they survive partial failures better&#8230;</em></p><div><hr></div><p><em><strong>Reminder: this is a teaser of the subscriber-only newsletter, exclusive to my golden members.</strong></em></p><p>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>High-level architecture of real-world systems.</strong></p></li><li><p>Deep dive into how popular real-world systems work.</p></li><li><p><strong>How real-world systems handle scale, reliability, and performance.</strong></p></li></ul><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe&quot;,&quot;text&quot;:&quot;Unlock Full Access&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://newsletter.systemdesign.one/subscribe"><span>Unlock Full Access</span></a></p><div><hr></div><h3><strong>4. Swarm</strong></h3><p>In a swarm, many agents work as equals.</p><p>They coordinate through a <strong>shared blackboard</strong>: a data store (typically Redis cache, database table, or vector store) that every agent can read from and write to. Yet there are NO direct messages between agents&#8230;</p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/multi-agent-system">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[29 LLM Evaluation Concepts Every Engineer Needs to Know]]></title><description><![CDATA[#142: From &#8220;it looked fine in testing&#8221; to a system you can actually trust]]></description><link>https://newsletter.systemdesign.one/p/llm-evals</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/llm-evals</guid><dc:creator><![CDATA[Anshuman Mishra]]></dc:creator><pubDate>Mon, 27 Apr 2026 11:50:18 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/644136e5-3bdd-481f-aaf3-26e01e791323_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/llm-evals/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>You ship an LLM feature.</p><p>It passes your manual tests. A day later, a user posts a screenshot of it hallucinating wildly! You tweak the prompt, run it again, and it works fine. Did you fix it, or did you just get lucky?</p><p>Welcome to the central frustration of LLM engineering: <em>you can NO longer just run a test and call it done.</em></p><p>This isn&#8217;t a debugging problem&#8230;</p><p>It&#8217;s a measurement problem. And measurement has a name: <strong>evaluation</strong>.</p><p>Most articles on LLM evaluation are written for ML researchers. This one is for engineers building real applications. You know how to ship software. You&#8217;re just new to the ways LLMs fail.</p><p>We&#8217;ll cover the vocabulary, methods, and mental models. By the end, you&#8217;ll have a framework for building an eval system from scratch. Not just an understanding of why it matters.</p><p>Let&#8217;s start with why your existing testing instincts don&#8217;t work here&#8230;</p><div><hr></div><h2><a href="https://coderabbit.link/neo-agent">Your team&#8217;s second brain. Now in Slack. (Partner)</a></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://coderabbit.link/neo-agent" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GfjP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a43027a-3160-457a-8e4b-4e144b0be46a_1248x654.png 424w, https://substackcdn.com/image/fetch/$s_!GfjP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a43027a-3160-457a-8e4b-4e144b0be46a_1248x654.png 848w, https://substackcdn.com/image/fetch/$s_!GfjP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a43027a-3160-457a-8e4b-4e144b0be46a_1248x654.png 1272w, https://substackcdn.com/image/fetch/$s_!GfjP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a43027a-3160-457a-8e4b-4e144b0be46a_1248x654.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GfjP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a43027a-3160-457a-8e4b-4e144b0be46a_1248x654.png" width="1248" height="654" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7a43027a-3160-457a-8e4b-4e144b0be46a_1248x654.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:654,&quot;width&quot;:1248,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:547609,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://coderabbit.link/neo-agent&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/192885623?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a43027a-3160-457a-8e4b-4e144b0be46a_1248x654.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GfjP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a43027a-3160-457a-8e4b-4e144b0be46a_1248x654.png 424w, https://substackcdn.com/image/fetch/$s_!GfjP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a43027a-3160-457a-8e4b-4e144b0be46a_1248x654.png 848w, https://substackcdn.com/image/fetch/$s_!GfjP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a43027a-3160-457a-8e4b-4e144b0be46a_1248x654.png 1272w, https://substackcdn.com/image/fetch/$s_!GfjP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a43027a-3160-457a-8e4b-4e144b0be46a_1248x654.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 role="img" 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><title></title><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>Your engineers talk on Slack. They code in the terminal. Somewhere between those two things, context goes to die.</p><ul><li><p>A bug was debated in #incidents at 2 AM.</p></li><li><p>An architectural call was made in a DM.</p></li></ul><p>Every handoff leaks context, and every leak costs you. That&#8217;s the context tax - and your team pays it every day.</p><p><a href="https://coderabbit.link/neo-agent">CodeRabbit Agent for Slack</a> is built for agentic SDLC workflows. One agent for your entire Software Development Lifecycle, living in the channel where the work already happens. It&#8217;s built on four things:</p><ul><li><p>Context - your org&#8217;s operating picture, pulled from across code, tickets, docs, monitoring and cloud.</p></li><li><p>Knowledge Base - a living memory of your team. Every run leaves a trace, so yesterday&#8217;s decisions don&#8217;t become tomorrow&#8217;s debates.</p></li><li><p>Multi-Player - works in shared threads alongside your team. Steerable, resumable and aligned as work evolves.</p></li><li><p>Governance - scoped access, cost attribution. Every run explainable and attributed.</p></li></ul><p>Your team keeps shipping. <a href="https://coderabbit.link/neo-agent">Agent</a> keeps the context.</p><p>From the team that pioneered AI code reviews. 2M code reviews every week. 6M repos. 15K customers. And now, one agent for your entire SDLC, right in Slack.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://coderabbit.link/neo-agent&quot;,&quot;text&quot;:&quot;Try CodeRabbit's Agent Today&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://coderabbit.link/neo-agent"><span>Try CodeRabbit's Agent Today</span></a></p><p>(Thanks to <a href="https://coderabbit.link/neo-agent">CodeRabbit</a> for partnering on this post.)</p><div><hr></div><p>I want to introduce <strong><a href="https://www.linkedin.com/in/athletickoder/">Anshuman</a></strong> as a guest author.</p><blockquote></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://beaiproof.substack.com/welcome" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WKHG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a32ac35-dc9b-4763-8078-226ec3f7186b_1294x776.png 424w, https://substackcdn.com/image/fetch/$s_!WKHG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a32ac35-dc9b-4763-8078-226ec3f7186b_1294x776.png 848w, https://substackcdn.com/image/fetch/$s_!WKHG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a32ac35-dc9b-4763-8078-226ec3f7186b_1294x776.png 1272w, https://substackcdn.com/image/fetch/$s_!WKHG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a32ac35-dc9b-4763-8078-226ec3f7186b_1294x776.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WKHG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a32ac35-dc9b-4763-8078-226ec3f7186b_1294x776.png" width="1294" height="776" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2a32ac35-dc9b-4763-8078-226ec3f7186b_1294x776.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:776,&quot;width&quot;:1294,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:870375,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://beaiproof.substack.com/welcome&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://beaiproof.substack.com/i/192525618?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a32ac35-dc9b-4763-8078-226ec3f7186b_1294x776.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!WKHG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a32ac35-dc9b-4763-8078-226ec3f7186b_1294x776.png 424w, https://substackcdn.com/image/fetch/$s_!WKHG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a32ac35-dc9b-4763-8078-226ec3f7186b_1294x776.png 848w, https://substackcdn.com/image/fetch/$s_!WKHG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a32ac35-dc9b-4763-8078-226ec3f7186b_1294x776.png 1272w, https://substackcdn.com/image/fetch/$s_!WKHG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a32ac35-dc9b-4763-8078-226ec3f7186b_1294x776.png 1456w" sizes="100vw" loading="lazy" 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 role="img" 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><title></title><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>He leads evals efforts at Zomato, where he built <strong>Gavel</strong> -- an internal LLM eval platform that started as a handful of scripts, got pitched to a VP, and now serves AI and ops teams across the company. Now he&#8217;s on the ground floor of making a large organization AI-native, one eval system at a time.</p><p>I highly recommend you checkout his newsletter, <strong><a href="https://beaiproof.substack.com/welcome">AI Proof</a></strong> -- it&#8217;ll help you stay relevant in the AI era.</p><div><hr></div><p>Before we get into solutions, you need to understand something&#8230;</p><p>LLM evaluation feels nothing like regular software testing. It&#8217;s not that it&#8217;s harder. It&#8217;s that the rules changed.</p><p>Let&#8217;s dive in!</p><h3><strong>1. Non-determinism Problem</strong></h3><p>Write a function.</p><p>Call it with the same input twice, and you&#8217;ll get the same output twice.</p><p>But LLMs don&#8217;t work that way.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZRjZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cc8ba0d-9314-456b-876d-9a7ff7a680a2_1024x559.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZRjZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cc8ba0d-9314-456b-876d-9a7ff7a680a2_1024x559.png 424w, https://substackcdn.com/image/fetch/$s_!ZRjZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cc8ba0d-9314-456b-876d-9a7ff7a680a2_1024x559.png 848w, https://substackcdn.com/image/fetch/$s_!ZRjZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cc8ba0d-9314-456b-876d-9a7ff7a680a2_1024x559.png 1272w, https://substackcdn.com/image/fetch/$s_!ZRjZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cc8ba0d-9314-456b-876d-9a7ff7a680a2_1024x559.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZRjZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cc8ba0d-9314-456b-876d-9a7ff7a680a2_1024x559.png" width="1024" height="559" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8cc8ba0d-9314-456b-876d-9a7ff7a680a2_1024x559.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:559,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!ZRjZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cc8ba0d-9314-456b-876d-9a7ff7a680a2_1024x559.png 424w, https://substackcdn.com/image/fetch/$s_!ZRjZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cc8ba0d-9314-456b-876d-9a7ff7a680a2_1024x559.png 848w, https://substackcdn.com/image/fetch/$s_!ZRjZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cc8ba0d-9314-456b-876d-9a7ff7a680a2_1024x559.png 1272w, https://substackcdn.com/image/fetch/$s_!ZRjZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cc8ba0d-9314-456b-876d-9a7ff7a680a2_1024x559.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 role="img" 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><title></title><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 same prompt can produce a different response on every run.</p><p>Sometimes slightly different. Sometimes completely different. This isn&#8217;t a bug. It&#8217;s called <strong>temperature</strong>.</p><p>It controls how random the outputs are. (More on this later.)</p><p>This breaks something deeper. Your entire mental model for testing assumes determinism. You run a test. It passes or fails. You know what you know.</p><p>With LLMs, a passing test is a data point, not a verdict. You&#8217;re not testing a function. Instead, you&#8217;re sampling from a probability distribution. One sample tells you almost nothing.</p><p>This is the first reason your existing instincts mislead you.</p><h3><strong>2. Fuzzy Correctness Problem</strong></h3><p>When a regex matches, it matches. Binary. Objective. Done.</p><p>But what&#8217;s the correct response to <em>&#8220;summarize this support ticket empathetically?</em>&#8221;</p><ul><li><p><em>Is the correct answer the one that&#8217;s most concise?</em></p></li><li><p><em>The one that uses the warmest language?</em></p></li><li><p><em>The one that captures all the key facts?</em></p></li><li><p><em>The one a human reviewer would score highest?</em></p></li></ul><p>LLM quality is <strong>multi-dimensional and subjective</strong>.</p><p>There usually isn&#8217;t one correct answer. There&#8217;s a range of acceptable answers and a range of bad ones. The line between them is a judgment call.</p><p>You can&#8217;t measure what you haven&#8217;t defined.</p><p>What does &#8216;good&#8217; mean for your use case? You need a clear answer to that before you can evaluate anything. Most people skip this step. It comes back to haunt them.</p><h3><strong>3. Silent Regression Problem</strong></h3><p>You updated your prompt.</p><p>Ran it a few times. The outputs seemed better. You shipped it.</p><p><em>But did quality actually improve, or did you get lucky with the samples you checked?</em></p><p>This is the <strong>silent regression problem</strong>. Without a systematic evaluation process, every prompt change is a blind bet. You might be making things better. You might be fixing one failure mode while introducing another. And you have no way of knowing.</p><p>In traditional software, <strong>CI</strong> (Continuous Integration) catches regressions before they reach users. In LLM engineering, there&#8217;s NO such equivalent. So people rely on their gut feelings and manual spot checks. You find out about regressions when a user complains!</p><p><em>These three problems make LLM evaluation its own discipline&#8230;</em></p><p><em>Now let&#8217;s build the vocabulary to actually talk about it&#8230;</em></p><div><hr></div><div class="captioned-button-wrap" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/llm-evals?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="CaptionedButtonToDOM"><div class="preamble"><p class="cta-caption"><em>Share this post &amp; get rewards for the referrals.</em></p></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/llm-evals?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/llm-evals?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p></div><div><hr></div><h2><strong>Primitives of Eval</strong></h2><p>These are <em>six terms</em> you&#8217;ll hear constantly.</p><p>Learn these, and the rest falls into place:</p><h3><strong>4. Criteria</strong></h3><p><strong>Criteria</strong> are the dimensions of quality that matter for your specific use case.</p><p>A customer support bot might care about:</p><ul><li><p><em>Does it address the user&#8217;s actual issue?</em></p></li><li><p><em>Is the tone empathetic?</em></p></li><li><p><em>Does it avoid triggering escalation unnecessarily?</em></p></li></ul><p>A code generation tool cares about something completely different:</p><ul><li><p><em>Is the output syntactically valid?</em></p></li><li><p><em>Does it follow the project&#8217;s conventions?</em></p></li><li><p><em>Does it actually solve the stated problem?</em></p></li></ul><p>Same technology, but entirely different criteria.</p><p>This is a product decision, NOT a technical one. You can&#8217;t outsource it to your model or your eval framework. Someone on your team needs to sit down and answer: <em>What does a good output actually look like here?</em></p><p>Get this wrong, and everything downstream is measuring the wrong thing&#8230;</p><h3><strong>5. Quality Dimensions</strong></h3><p>Quality dimensions are the standard industry vocabulary for LLM output quality.</p><p>Here are five of them that come up constantly:</p><ul><li><p><strong>Relevance</strong>: <em>Did the output address what was actually asked? </em>A response can be accurate, well-written, and completely beside the point.</p></li><li><p><strong>Coherence</strong>: <em>Does it hold together logically?</em> No contradictions. No mid-sentence topic shifts. Flows like something a thoughtful person wrote.</p></li><li><p><strong>Factual Accuracy</strong>: <em>Is what it says actually true?</em> Distinct from relevance. A response can be relevant and wrong.</p></li><li><p><strong>Helpfulness</strong>: <em>Does it give the user what they need to move forward? </em>The difference between a technically correct answer and a useful one.</p></li><li><p><strong>Safety</strong>: <em>Does it avoid harmful, biased, or inappropriate content?</em> This dimension matters more in some domains than others -- but it always matters.</p></li></ul><p>Knowing these helps you write <em>rubrics</em> that don&#8217;t miss important failure modes.</p><h3><strong>6. Rubric</strong></h3><p>Once you have the criteria, you need to operationalize them.</p><p>That&#8217;s what a <strong>rubric</strong> does.</p><p>Take a vague criterion like &#8220;<em>helpfulness</em>.&#8221; A rubric breaks it into specific, scorable questions. <em>Does it directly answer the question? Does it avoid unnecessary hedging? Is it under 200 words? Can a non-technical user understand it?</em></p><p>Think of it like a code review checklist.</p><p>Instead of <em>&#8220;Is this good code?&#8221;,</em> a checklist asks: A<em>re there tests? Is the function under 30 lines? Are variable names descriptive?</em> Rubrics do the same thing for LLM outputs.</p><p>The rubric is what makes evaluation reproducible.</p><p>Two different reviewers, human or AI, should arrive at similar scores. Same output, same rubric, same conclusion.</p><p>Without a rubric, every evaluation is just someone&#8217;s opinion.</p><h3><strong>7. Test Cases</strong></h3><p>A <strong>test case</strong> is an input/output pair that forms one unit of your evaluation.</p><p>Input is a prompt: <em>ideally, one representative of real user traffic.</em></p><p>Output can be one of two things. <em>A reference answer showing what good output looks like. Or the live model output you&#8217;re about to score.</em></p><p>Think of test cases like unit tests&#8230;</p><p>Except that a failing test case doesn&#8217;t mean the output was wrong. It means it scored below your defined threshold on your rubric.</p><p>That distinction matters.</p><p>You need a lot of them. A handful of test cases gives you anecdotes. A few hundred gives you a signal.</p><h3><strong>8. Golden Set</strong></h3><p>Everything in your eval gets measured against one thing: your <strong>golden set</strong>.</p><p>A curated collection of high-quality test cases.</p><p>Building a good golden set is harder than it sounds:</p><p>The instinct is to write examples yourself, covering the use cases you anticipate. That&#8217;s a start. But users phrase things differently than you expect. They hit edge cases you didn&#8217;t imagine.</p><p>And they might misuse features in creative ways.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wias!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wias!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.png 424w, https://substackcdn.com/image/fetch/$s_!wias!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.png 848w, https://substackcdn.com/image/fetch/$s_!wias!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.png 1272w, https://substackcdn.com/image/fetch/$s_!wias!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wias!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.png" width="1380" height="752" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:752,&quot;width&quot;:1380,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:770107,&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://newsletter.systemdesign.one/i/192885623?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wias!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.png 424w, https://substackcdn.com/image/fetch/$s_!wias!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.png 848w, https://substackcdn.com/image/fetch/$s_!wias!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.png 1272w, https://substackcdn.com/image/fetch/$s_!wias!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cedf74-ec5d-4e64-9114-2550a77d66dd_1380x752.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 role="img" 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><title></title><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 golden set built from your imagination reflects your imagination and not your users&#8217;. So seed it with real production queries instead. Anonymized, cleaned, representative.</p><p>Your golden set is your ground truth.</p><p>Treat it like a critical system artifact. Version and update it when you discover new failure modes.</p><h3><strong>9. Pass/Fail Threshold</strong></h3><p>Eval scores are rarely binary.</p><p>A rubric usually produces a score of 1 to 5, 0 to 10, or a percentage. The <strong>pass/fail threshold</strong> is what converts that score into a decision.</p><p>If your rubric scores range from 1 to 5 and your threshold is 3, any score below 3 is a failure. Simple in theory, but HARD in practice.</p><p>Setting the right threshold is a <em>product call</em>, not a technical one.</p><p>It depends on a few things: <em>how much imperfection your users can tolerate. How severe are failures in your domain? The cost of false positives.</em></p><p>Set your threshold too low, and you&#8217;re shipping garbage. And if you set it too high, you&#8217;re shipping nothing.</p><h3><strong>10. Eval Coverage</strong></h3><p><strong>Eval coverage</strong> is how well your golden set reflects real user inputs.</p><p>Most teams have low coverage and don&#8217;t know it. They built their golden set from examples they had written. Happy path, a few obvious edge cases. Meanwhile, production traffic is different: weird inputs, unusual phrasings, use cases nobody anticipated.</p><p>Low coverage means your eval suite is optimistic&#8230;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5b7I!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23d76175-b112-41eb-88fc-f23e06878733_2816x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5b7I!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23d76175-b112-41eb-88fc-f23e06878733_2816x1536.png 424w, https://substackcdn.com/image/fetch/$s_!5b7I!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23d76175-b112-41eb-88fc-f23e06878733_2816x1536.png 848w, https://substackcdn.com/image/fetch/$s_!5b7I!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23d76175-b112-41eb-88fc-f23e06878733_2816x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!5b7I!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23d76175-b112-41eb-88fc-f23e06878733_2816x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5b7I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23d76175-b112-41eb-88fc-f23e06878733_2816x1536.png" width="1456" height="794" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/23d76175-b112-41eb-88fc-f23e06878733_2816x1536.png&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;:5268690,&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://conductorbyam.substack.com/i/192525618?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23d76175-b112-41eb-88fc-f23e06878733_2816x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!5b7I!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23d76175-b112-41eb-88fc-f23e06878733_2816x1536.png 424w, https://substackcdn.com/image/fetch/$s_!5b7I!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23d76175-b112-41eb-88fc-f23e06878733_2816x1536.png 848w, https://substackcdn.com/image/fetch/$s_!5b7I!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23d76175-b112-41eb-88fc-f23e06878733_2816x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!5b7I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23d76175-b112-41eb-88fc-f23e06878733_2816x1536.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 role="img" 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><title></title><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>i.e., you&#8217;ll pass your tests but fail your users.</p><p>The fix isn&#8217;t writing more examples yourself. Instead, sample from production regularly and review failures. Then add the inputs that exposed new weaknesses to your golden set.</p><p>Eval coverage is something you build over time.</p><h3><strong>11. Temperature, Top-p, and Reproducibility</strong></h3><p>Temperature is the dial that controls how <em>random</em> your model&#8217;s outputs are.</p><p>Low temperature (close to 0) makes the model nearly deterministic: same input, same output, every time. High temperature makes it more creative. It samples from a wider range of probable tokens, producing more varied responses.</p><p><strong>Top-p</strong> (nucleus sampling) is a related setting.</p><p>Instead of a randomness dial, it sets a probability cutoff. Only the most likely tokens make the cut. <code>Top-p = 0.9</code> means the model considers only the top 90% most likely next tokens.</p><p>Both settings directly affect your eval results&#8230;</p><p>Run evals at <code>temperature = 1.0</code> and the same prompt might pass today and fail tomorrow. NOT because your model changed, but because randomness swung against you.</p><p>Here&#8217;s the standard practice: set temperature to 0 during eval runs. And lock in determinism. If you need creative variance in production, test at your production temperature.</p><p>Just know you&#8217;re accepting noisier results&#8230;</p><h3><strong>12. Statistical Rigor</strong></h3><p>Even at <code>temperature = 0</code>, a single eval run isn&#8217;t enough.</p><p>Your golden set is a sample of your input space. That sample has its own variance. One unlucky set of examples can make a good prompt look bad. And one lucky set can make a bad prompt look good.</p><p>So run many evaluations across different samples.</p><p>Then report the mean and the variance, not just the score. When comparing two prompt versions, check whether the difference is real. Or if it&#8217;s just noise.</p><p>In practice: if you change a prompt and your score goes from 4.1 to 4.3, that might be a real improvement.</p><p>It might be a random fluctuation. Without variance<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a> data across many runs, you can&#8217;t tell the difference. Most teams run once, report the number, and ship. That&#8217;s how confident regressions get deployed&#8230;</p><div><hr></div><div class="captioned-button-wrap" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/llm-evals?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="CaptionedButtonToDOM"><div class="preamble"><p class="cta-caption"><em>Share this post &amp; get rewards for the referrals.</em></p></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/llm-evals?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/llm-evals?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p></div><div><hr></div><h2><strong>How Do You Score Outputs?</strong></h2><p>You have criteria, a rubric, and test cases<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>.</p><p>Now the question is: <em>who does the scoring? </em>There are three options.</p><p>Each has different tradeoffs in cost, speed, and accuracy.</p><h3><strong>13. Human Evaluation</strong></h3><p>This is the gold standard.</p><p>A human reviews the output using your rubric and gives a score. It&#8217;s slow, expensive, and can be inconsistent. But it&#8217;s the closest thing to ground truth.</p><p>You can&#8217;t use humans for every eval run; it doesn&#8217;t scale.</p><p>But you shouldn&#8217;t remove human evaluation completely either. It&#8217;s what keeps your system grounded. Everything else: metrics, LLM judges, tests, is just an approximation of human judgment.</p><p>So use human evaluation strategically:</p><ul><li><p>To build and validate your golden dataset.</p></li><li><p>To periodically check the accuracy of your automated evals.</p></li><li><p>To debug when something breaks and you don&#8217;t know why.</p></li></ul><p>This way, you balance cost with reliability.</p><h3><strong>14. Heuristic/Code Based Evaluation</strong></h3><p>This is the fastest and cheapest type of evaluation.</p><p>It uses simple code checks to validate the output's structural properties. For example:</p><ul><li><p><em>Is the response valid JSON?</em></p></li><li><p><em>Is it within the character limit?</em></p></li><li><p><em>Does it include all required fields?</em></p></li><li><p><em>Does it avoid banned phrases?</em></p></li><li><p><em>Does it match a specific format (like a regex)?</em></p></li></ul><p>Heuristic eval is good at catching structural problems.</p><p>But they don&#8217;t measure quality. They can&#8217;t tell if a response is helpful, accurate, or well-written.</p><p>Think of heuristics as your first line of defense.</p><p>They catch basic issues before you run more expensive evaluations. They&#8217;re NOT enough on their own, but they&#8217;re an essential part of a complete eval system&#8230;</p><h3><strong>15. Semantic Similarity Evaluation</strong></h3><p>Sometimes you have a reference answer, a known-good response representing ideal output.</p><p>Semantic similarity evaluation measures how close your model&#8217;s output is to the reference. i.e., in meaning, and not exact wording.</p><p>This is where embeddings come in&#8230;</p><p>Each piece of text gets converted into a vector: <em>a list of numbers that represents its meaning.</em> Texts with similar meanings have vectors that are close to each other. Cosine similarity measures the angle between two vectors. A score of 1.0 means identical meaning. A score near 0 means unrelated.</p><p>This matters because string matching is too strict.</p><p>Take two sentences: <em>&#8220;API returns a 404 error&#8221;</em> and <em>&#8220;Endpoint responds with a not found status.&#8221;</em> They mean the same thing, but use different words. An exact match would call the second one wrong. Semantic similarity would call them equivalent.</p><p>But here&#8217;s the limitation:<em> it only measures closeness to your reference.</em></p><p>It can&#8217;t catch a response that&#8217;s fluent and factually wrong. Not if the wrong answer happens to be semantically similar to the right one. So use it as a fast, scalable layer. And don&#8217;t rely on it alone!</p><h3><strong>16. Task Specific Metrics (BLEU, ROUGE, Execution-based)</strong></h3><p>For certain tasks, there are established metrics purpose-built for automated evaluation:</p><ul><li><p><strong>BLEU (Bilingual Evaluation Understudy)</strong>: Originally for machine translation. Measures n-gram overlap between generated text and a reference. Good for tasks where exact phrasing matters.</p></li><li><p><strong>ROUGE (Recall-Oriented Understudy for Gisting Evaluation)</strong>: Designed for summarization. Measures recall: <em>how much of the reference answer appears in the output?</em> Useful when you care about coverage: <em>did the model hit all the key points?</em></p></li><li><p><strong>Execution-based evaluation</strong>: For code generation, one metric matters. <em>Does it run? Does it produce the correct output?</em> Execution-based eval runs the generated code against test cases and checks the results. A function that returns the wrong answer fails. Another function that passes all tests succeeds.</p></li></ul><p>But all three share the same trade-off:</p><p>They measure surface-level similarity to a reference, not actual quality. So use these where they fit.</p><h3><strong>17. LLM as Judge</strong></h3><p>This is what makes evaluation scalable&#8230;</p><p><strong>LLM-as-judge</strong> uses a more capable model to evaluate your application&#8217;s outputs. You give it three things:</p><ul><li><p>Original input,</p></li><li><p>Output you&#8217;re evaluating,</p></li><li><p>Your rubric. </p></li></ul><p>The judge then returns a score and an explanation.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IF5b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe688c960-0428-484f-84b7-56c011f17898_2816x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IF5b!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe688c960-0428-484f-84b7-56c011f17898_2816x1536.png 424w, https://substackcdn.com/image/fetch/$s_!IF5b!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe688c960-0428-484f-84b7-56c011f17898_2816x1536.png 848w, https://substackcdn.com/image/fetch/$s_!IF5b!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe688c960-0428-484f-84b7-56c011f17898_2816x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!IF5b!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe688c960-0428-484f-84b7-56c011f17898_2816x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IF5b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe688c960-0428-484f-84b7-56c011f17898_2816x1536.png" width="1456" height="794" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e688c960-0428-484f-84b7-56c011f17898_2816x1536.png&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;:5026763,&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://conductorbyam.substack.com/i/192525618?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe688c960-0428-484f-84b7-56c011f17898_2816x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!IF5b!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe688c960-0428-484f-84b7-56c011f17898_2816x1536.png 424w, https://substackcdn.com/image/fetch/$s_!IF5b!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe688c960-0428-484f-84b7-56c011f17898_2816x1536.png 848w, https://substackcdn.com/image/fetch/$s_!IF5b!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe688c960-0428-484f-84b7-56c011f17898_2816x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!IF5b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe688c960-0428-484f-84b7-56c011f17898_2816x1536.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 role="img" 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><title></title><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 it like automated load testing.</p><p>Nobody clicks through 10,000 user flows to check for regressions. You can instead automate it. LLM-as-judge does the same thing for quality. It lets you run your rubric across thousands of outputs without thousands of human hours.</p><p>GPT-5 and Claude Opus are commonly used as judges. They&#8217;re capable enough to apply nuanced rubrics reliably. You&#8217;re calling them via API, NO custom training required.</p><p>But here&#8217;s the catch: <em>judges can be wrong.</em></p><p>They have their own biases and blind spots. An LLM judge is an approximation of human judgment, not a replacement for it.</p><p>More on how to handle this in a moment&#8230;</p><h3><strong>18. Pointwise vs Pairwise Evaluation</strong></h3><p>These are 2 flavors of LLM-as-judge evaluation:</p><ul><li><p><strong>Pointwise</strong></p><ul><li><p><em>You ask, &#8220;Score this output on a scale of 1&#8211;5.&#8221;</em></p></li></ul><ul><li><p>It&#8217;s simple and fast.</p></li><li><p>And each output needs one evaluation call.</p></li></ul></li><li><p><strong>Pairwise</strong></p><ul><li><p>You ask: <em>&#8220;Here are two outputs. Which one is better?&#8221;</em></p></li><li><p>This is usually more reliable because comparing is easier than scoring.</p></li><li><p>It&#8217;s especially useful when you want to know if a new prompt is actually better.</p></li></ul></li></ul><p>But the downside of <em>pairwise</em> is the cost&#8230;</p><p>You&#8217;re evaluating two outputs instead of one, so it can be twice as expensive. At a small scale, this doesn&#8217;t matter, but at a production scale, it adds up quickly.</p><p>Because of this, the industry standard is to use a tiered approach:</p><ul><li><p>Online evaluation (production monitoring)</p><ul><li><p>Use fast, cheap methods like heuristics or smaller, fine-tuned judge models.</p></li></ul><ul><li><p>These can run continuously without high cost or latency.</p></li></ul></li><li><p>Offline evaluation (pre-ship testing)</p><ul><li><p>Use the best LLM judge you have.</p></li><li><p>Run pointwise and pairwise comparisons.</p></li><li><p>This is acceptable because you&#8217;re only running it before deployments.</p></li></ul></li></ul><p>Think of the powerful judge model as a gate before deployment, and NOT something you run on every request.</p><h3><strong>19. Judge Calibration</strong></h3><p>Before you rely on an LLM judge, you need to know how well it matches human judgment&#8230;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Wevo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_2816x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Wevo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_2816x1536.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Wevo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_2816x1536.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Wevo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_2816x1536.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Wevo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_2816x1536.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Wevo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_2816x1536.jpeg" width="1456" height="794" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_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;:1129047,&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://newsletter.systemdesign.one/i/192885623?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_2816x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Wevo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_2816x1536.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Wevo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_2816x1536.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Wevo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_2816x1536.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Wevo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef275e7b-9e9d-4e8d-a9ad-b63e6343cc6e_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 role="img" 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><title></title><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>Judge calibration measures this:</p><p>You take a sample of outputs, have both humans and the judge score them, and then check how often they agree.</p><ul><li><p>If agreement is high, your judge is a good proxy for human evaluation.</p></li><li><p>If agreement is low, the judge may be measuring the wrong thing.</p></li></ul><p>A poorly calibrated judge is risky.</p><p>It can give you confidence in results that aren&#8217;t actually correct. So calibrate your judge before using it. Then recalibrate periodically, especially after changing models or prompts.</p><div><hr></div><p>Get 20% savings by getting a group subscription right now:</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?group=true&amp;coupon=d6837d0d&quot;,&quot;text&quot;:&quot;Get 20% off a group subscription&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?group=true&amp;coupon=d6837d0d"><span>Get 20% off a group subscription</span></a></p><div><hr></div><h2><strong>RAG System Evaluation</strong></h2><p>Most LLM applications today aren&#8217;t just &#8220;prompt in, response out.&#8221;</p><p>They use Retrieval-Augmented Generation (<strong>RAG</strong>): <em>first fetch relevant documents, inject them into the context, and then generate a grounded response.</em></p><p>This helps reduce hallucinations because the model can rely on real data rather than just its training data. But it doesn&#8217;t solve the problem completely&#8230;</p><p>It also introduces new failure modes that standard LLM evaluation doesn&#8217;t catch&#8230;</p><h3><strong>20. RAG Triad</strong></h3><p>The standard framework for evaluating RAG systems has three dimensions:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eXKJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F487ff2a2-c404-4702-bcc5-e57fcd255586_2816x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eXKJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F487ff2a2-c404-4702-bcc5-e57fcd255586_2816x1536.jpeg 424w, https://substackcdn.com/image/fetch/$s_!eXKJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F487ff2a2-c404-4702-bcc5-e57fcd255586_2816x1536.jpeg 848w, https://substackcdn.com/image/fetch/$s_!eXKJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F487ff2a2-c404-4702-bcc5-e57fcd255586_2816x1536.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!eXKJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F487ff2a2-c404-4702-bcc5-e57fcd255586_2816x1536.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eXKJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F487ff2a2-c404-4702-bcc5-e57fcd255586_2816x1536.jpeg" width="1456" height="794" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/487ff2a2-c404-4702-bcc5-e57fcd255586_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;:928306,&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://newsletter.systemdesign.one/i/192885623?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F487ff2a2-c404-4702-bcc5-e57fcd255586_2816x1536.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!eXKJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F487ff2a2-c404-4702-bcc5-e57fcd255586_2816x1536.jpeg 424w, https://substackcdn.com/image/fetch/$s_!eXKJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F487ff2a2-c404-4702-bcc5-e57fcd255586_2816x1536.jpeg 848w, https://substackcdn.com/image/fetch/$s_!eXKJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F487ff2a2-c404-4702-bcc5-e57fcd255586_2816x1536.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!eXKJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F487ff2a2-c404-4702-bcc5-e57fcd255586_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 role="img" 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><title></title><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>1 Faithfulness</strong></p><p><em>Did the answer actually come from the retrieved context?</em></p><p>This often surprises people. You can retrieve the perfect documents, and the model can still ignore them. Faithfulness checks whether the response is grounded in the provided sources.</p><p>A failure here looks like a confident answer that isn&#8217;t supported by the retrieved documents. So it&#8217;s just a hallucination with extra steps.</p><p><strong>2 Answer Relevance</strong></p><p><em>Did the response actually answer the user&#8217;s question?</em></p><p>A response can be faithful to the context and still miss the point. The model may use the right documents but answer the wrong question.</p><p><em>Answer relevance</em> measures how well the response matches the user&#8217;s intent. While <em>Faithfulness</em> checks if the model stayed within the context.</p><p><strong>3 Context Precision</strong></p><p><em>Did the retrieval step fetch the right documents?</em></p><p>Even a perfect generator will fail if the input context is poor. If retrieval brings in weak or loosely related documents, the model either guesses or tells the user it doesn&#8217;t know.</p><p>Context precision evaluates the retrieval stage. It checks how many of the retrieved documents were actually relevant.</p><p>Think of a RAG system as three stages: <em>retrieval, augmentation, generation.</em></p><p>Each stage can fail on its own&#8230; The RAG triad is your observability layer to isolate where the problem is, so you know what to fix.</p><h3><strong>21. RAG-Specific Failure Patterns</strong></h3><p>Understanding the RAG triad is one thing. Spotting failures in practice is another&#8230;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8loO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8loO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.png 424w, https://substackcdn.com/image/fetch/$s_!8loO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.png 848w, https://substackcdn.com/image/fetch/$s_!8loO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!8loO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8loO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.png" width="1456" height="794" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.png&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;:4569940,&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://conductorbyam.substack.com/i/192525618?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!8loO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.png 424w, https://substackcdn.com/image/fetch/$s_!8loO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.png 848w, https://substackcdn.com/image/fetch/$s_!8loO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!8loO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8689a3ea-a350-49aa-9458-3dfaea3b0828_2816x1536.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 role="img" 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><title></title><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>Here are the three most common failure patterns:</p><p><strong>1 Retrieval returns irrelevant chunks </strong>(Context precision failure)</p><p>The system retrieves the wrong or loosely related documents. And the model then either:</p><ul><li><p>Hallucinates to fill the gaps,</p></li><li><p>Or says it doesn&#8217;t have enough information.</p></li></ul><p>The fix is in your retrieval layer: <em>embedding quality, chunking strategy, re-ranking.</em></p><p><strong>2 Retrieval is correct, but the model ignores it </strong>(Faithfulness failure)</p><p>The right documents get retrieved, but the model doesn&#8217;t use them.</p><p>This is usually a prompting issue. The model isn&#8217;t being forced to rely on the provided context. The fix is to strengthen the prompt, so the model stays grounded to the sources.</p><p><strong>3 The answer is grounded but doesn&#8217;t help the user </strong>(Answer relevance failure)</p><p>The answer is technically correct and grounded, but doesn&#8217;t solve the user&#8217;s problem. This usually means your knowledge base is missing the right information. The fix is to improve or expand your data, NOT your prompt.</p><div><hr></div><p>Get 20% savings by getting a group subscription right now:</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?group=true&amp;coupon=d6837d0d&quot;,&quot;text&quot;:&quot;Get 20% off a group subscription&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?group=true&amp;coupon=d6837d0d"><span>Get 20% off a group subscription</span></a></p><div><hr></div><h2><strong>Offline vs Online</strong></h2><p>Scoring a single output is one problem.</p><p>Building a system that reliably catches failures (before and after deployment) is another. There are two environments where evaluation happens:</p><h3><strong>22. Offline Evaluation</strong></h3><p>Offline evaluation happens before you ship.</p><p>You make a change: <em>a new prompt, model version, or retrieval strategy</em>. Before it reaches users, you test it against your golden dataset. Then you score the outputs and compare them to your current system.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Xy0u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Xy0u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.png 424w, https://substackcdn.com/image/fetch/$s_!Xy0u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.png 848w, https://substackcdn.com/image/fetch/$s_!Xy0u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.png 1272w, https://substackcdn.com/image/fetch/$s_!Xy0u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Xy0u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.png" width="1024" height="559" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:559,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:180427,&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://conductorbyam.substack.com/i/192525618?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Xy0u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.png 424w, https://substackcdn.com/image/fetch/$s_!Xy0u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.png 848w, https://substackcdn.com/image/fetch/$s_!Xy0u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.png 1272w, https://substackcdn.com/image/fetch/$s_!Xy0u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09f697c2-73fc-4568-b927-b501b4c43fb4_1024x559.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 role="img" 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><title></title><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 this like a continuous integration (<strong>CI</strong>) pipeline for LLMs.</p><p>A change shouldn&#8217;t go live unless it passes your evals. If quality drops, you catch it before deployment.</p><p>Plus, this is where you use your best (most accurate) judge model. For example, GPT-5, Claude Opus. Cost matters less here because you&#8217;re only evaluating a finite set of examples, and NOT each user request.</p><h3><strong>23. Online Evaluation</strong></h3><p>Online evaluation occurs in production.</p><p>You&#8217;re sampling live outputs continuously and scoring them. The goal is to catch issues that offline evals miss: <em>edge cases, unusual inputs, and failures that only appear at scale.</em></p><p>Think of online eval as your monitoring system&#8230;It helps you catch problems before users report them.</p><p>Yet the main constraint is cost. You can&#8217;t run your most expensive models on each request. So online eval relies on heuristics and smaller judge models; it&#8217;s cheap enough to run continuously.</p><p>This means you trade some accuracy for scale&#8230;</p><p>Offline and online eval should work together:</p><ul><li><p>Offline eval catches known issues before deployment</p></li><li><p>Online eval catches unexpected issues in production</p></li></ul><p>So you need both for a <em>reliable</em> system.</p><h3><strong>24. Prompt Versioning and Regression Testing</strong></h3><p>Your prompt is code; treat it that way.</p><p>Track every prompt change: <em>use version control, keep history, and compare differences. </em>When something breaks, you should know exactly what changed and when.</p><p>Without versioning, you&#8217;d NOT know what changed.</p><p><strong>Regression testing </strong>means running your eval suite against each prompt version. If your old prompt scored 4.2 and the new one scores 3.8, you&#8217;ve introduced a regression and caught it before it reached users.</p><p>This sounds simple, but most people don&#8217;t do it. They lack a solid eval setup: no golden dataset, no clear rubric, no infrastructure.</p><p>This is what separates people who iterate confidently from people who ship &amp; pray.</p><h3><strong>25. Benchmark-Based Evaluation</strong></h3><p>Benchmarks are standard tests used to compare different LLM models:</p><p><strong>1 MMLU (Massive Multitask Language Understanding)</strong></p><p>Tests knowledge across many subjects like math, science, law, and medicine. Think of it as a general knowledge exam for LLMs.</p><p><strong>2 HellaSwag</strong></p><p>Tests common<strong> </strong>sense reasoning. The model is given the start of a scenario and must predict what happens next. (Many earlier models struggled with this.)</p><p><strong>3 HumanEval</strong></p><p>Test code generation. The model gets a function signature and must write the correct implementation. It&#8217;s measured using pass@k: <em>how often the model gets the right answer within k attempts.</em></p><p>Here are two useful leaderboards:</p><ul><li><p>Hugging Face Open LLM Leaderboard for open-weight models</p></li><li><p>Chatbot Arena (LMSYS), where models get ranked based on human preferences</p></li></ul><p>Remember, these benchmarks are useful for comparing models, but they don&#8217;t always reflect real-world performance for your specific use case&#8230;</p><h3><strong>26. Benchmark vs Real-World Tradeoff</strong></h3><p>Benchmarks don&#8217;t tell you if a model will work for your specific use case.</p><p>A model that scores 90% on MMLU might still struggle with your domain-specific language. A model that performs well on HumanEval might generate code that doesn&#8217;t fit your standards&#8230; Benchmarks measure <em>general</em> capability, but your application might need a <em>specific</em> capability.</p><p>So use benchmarks to narrow down your options. Then use your own eval on your own golden set to make the final decision.</p><h3><strong>27. Dataset Contamination / Data Leakage</strong></h3><p>There&#8217;s a problem with benchmarks that most engineers overlook:</p><p><em>Dataset contamination</em> occurs when evaluation data overlaps with the model&#8217;s training data. The model has already seen the answers. So its high benchmark score reflects memorization, NOT capability.</p><p>This happens because training data and benchmark datasets come from the internet. And the data overlap is often <em>unknown</em>. Over time, widely used benchmarks become less reliable, which is why new ones keep getting created&#8230;</p><p>To avoid this, <em>don&#8217;t rely on public examples</em> for your evals&#8230;Plus, <em>use real user queries </em>and <em>create your own datasets</em> instead.</p><div><hr></div><div class="captioned-button-wrap" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/llm-evals?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="CaptionedButtonToDOM"><div class="preamble"><p class="cta-caption"><em>Share this post &amp; get rewards for the referrals.</em></p></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/llm-evals?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/llm-evals?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p></div><div><hr></div><h2><strong>Failure Modes (What Not to Do)</strong></h2><p>You can have the right tools and still build a BAD eval system.</p><p>Here are the common mistakes:</p><h3><strong>28. Eval Anti-Patterns</strong></h3><p><strong>Vibe-based evaluation.</strong></p><p><em>&#8220;I tried it a few times<strong>,</strong> and it looked good.&#8221;</em></p><p>This is the most common mistake. Informal spot-checking creates false confidence. It doesn&#8217;t catch edge cases, track performance over time, or scale beyond one person looking at a few outputs.</p><p>Vibes are a starting point, but not an eval system.</p><p><strong>The single-sample trap.</strong></p><p><em>You run your eval suite once and report the results.</em></p><p>But LLMs are nondeterministic&#8230;</p><ul><li><p>A bad prompt might look good</p></li><li><p>A good prompt might look bad</p></li></ul><p>So run many samples and aggregate results. Remember, report variance, not just average scores.</p><p><strong>Goodhart&#8217;s Law in disguise.</strong></p><p><em>&#8220;When a measure becomes a target, it stops being a good measure.&#8221;</em></p><p>If you optimize for a metric too aggressively, the metric stops measuring what you care about&#8230;</p><ul><li><p>Reward confidence: you&#8217;ll get confident hallucinations</p></li><li><p>Reward length: you&#8217;ll get long, low-quality answers</p></li></ul><p>Metrics are only a proxy for quality. So don&#8217;t mistake them for the actual goal.</p><p><strong>Eval-production mismatch.</strong></p><p><em>Your golden dataset reflects what you expect.</em></p><p>Yet real users behave differently. They&#8217;re vague, unpredictable, and use your system in ways you didn&#8217;t anticipate. If your evals don&#8217;t reflect real usage, your scores are misleading. A high pass rate on unrealistic data doesn&#8217;t mean your system works.</p><p><strong>Ignoring tail failures.</strong></p><p><em>A 92% pass rate sounds good. But what about the 8%?</em></p><p>LLM failures are often catastrophic, not graceful. One harmful or incorrect response can matter more than hundreds of correct ones. So always review failure cases, not just averages.</p><p>The worst outputs tell you the most&#8230;</p><div><hr></div><p>Get 20% savings by getting a group subscription right now:</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?group=true&amp;coupon=d6837d0d&quot;,&quot;text&quot;:&quot;Get 20% off a group subscription&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?group=true&amp;coupon=d6837d0d"><span>Get 20% off a group subscription</span></a></p><div><hr></div><h2><strong>Decision Framework</strong></h2><p>There&#8217;s no single tool that solves LLM evaluation.</p><p>What works is a layered system&#8230; Each layer catches problems the previous one misses&#8230;</p><h3><strong>29. Eval Stack</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Bow3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Bow3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.png 424w, https://substackcdn.com/image/fetch/$s_!Bow3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.png 848w, https://substackcdn.com/image/fetch/$s_!Bow3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!Bow3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Bow3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.png" width="1456" height="794" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.png&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;:5453669,&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://conductorbyam.substack.com/i/192525618?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Bow3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.png 424w, https://substackcdn.com/image/fetch/$s_!Bow3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.png 848w, https://substackcdn.com/image/fetch/$s_!Bow3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!Bow3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F471a919e-22c9-4d02-a463-710c9c24d20b_2816x1536.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 role="img" 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><title></title><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>Layer 1: Heuristics.</strong></p><p>Fast, deterministic, and cheap. These run on every output and catch structural issues such as incorrect format, missing fields, or banned content.</p><p><strong>Layer 2: Semantic similarity and task-specific metrics.</strong></p><p>These run automatically against reference answers. They help catch meaning-level failures without the cost of an LLM judge.</p><p><strong>Layer 3: LLM-as-judge (offline).</strong></p><p>This runs before deployment on your golden dataset using your best judge model. Its job is to catch quality regressions before they reach users.</p><p><strong>Layer 4: LLM-as-judge (online, smaller model).</strong></p><p>This runs in production on a sample of live outputs using a smaller, cheaper judge model. It helps catch failures at scale that offline evals missed.</p><p><strong>Layer 5: Human spot checks.</strong></p><p>These run periodically. And keep you calibrated, verify automated evals scoring still match human judgment, and add new failure cases back into your golden dataset.</p><p><em>Each layer has a different cost profile and catches a different failure type&#8230;</em></p><p><em>Eventually, you want all five. But you do NOT need all of them on day one.</em></p><p><em><strong>So if you are starting from scratch, here is a simple three-step MVP:</strong></em></p><p><strong>Step 1: Build a golden set of 50 examples.</strong></p><p>Don&#8217;t write all of them yourself.</p><p>Use real user queries if you have them. If not, create 30 representative examples and 20 edge cases. Also, include normal cases, adversarial inputs, and strange phrasings you expect users to try.</p><p>This dataset becomes the foundation of your eval system.</p><p><strong>Step 2: Add one deterministic heuristic.</strong></p><p>Pick the single most important structural requirement for your output.</p><p>That might be length, format, a required field, or a banned phrase. Then write a simple code check for it. This is quick to build and catches more failures than most people expect.</p><p><strong>Step 3: Add one LLM judge prompt.</strong></p><p>Take your rubric and turn it into a judge prompt.</p><p>Then use a strong model to score outputs on one important quality dimension, and run it on your golden dataset. Read the scores and the explanations carefully.</p><p>You will find something surprising&#8230;that&#8217;s the point.</p><p>That is your MVP eval system.</p><p>Everything else builds on top of it: <em>pairwise comparisons, online monitoring, RAG scoring, regression testing, and more.</em></p><p>Start here&#8230;</p><div><hr></div><h2><strong>Closing Thoughts</strong></h2><p>Evaluation isn&#8217;t something you do at the end.</p><p>Instead, it&#8217;s what makes iteration possible. Without it, you&#8217;re not doing LLM engineering. But guessing and shipping changes, only to find out from users that they didn&#8217;t.</p><p>Traditional software engineering learned this lesson the hard way: CI, automated tests, production monitoring&#8230;these aren&#8217;t optional. They&#8217;re what make fast, reliable development possible.</p><p>LLM systems need the same discipline. The difference is that the outputs are nondeterministic and hard to measure.</p><p>Now you have the vocabulary to deal with that&#8230;</p><p>Start simple and build your eval stack step by step. Over time, you&#8217;ll know whether a change improved quality before users ever see it.</p><div><hr></div><p>&#128075; I&#8217;d like to thank <strong><a href="https://www.linkedin.com/in/athletickoder/">Anshuman</a></strong> for writing this newsletter!</p><p>If you&#8217;re building LLM applications and want to go deeper, follow him on <a href="https://www.linkedin.com/in/athletickoder/">LinkedIn</a> and <a href="https://x.com/athleticKoder">X</a>.</p><p>Don&#8217;t forget to check out his newsletter, <strong><a href="https://beaiproof.substack.com/welcome">AI Proof</a></strong> -- it&#8217;ll help you stay relevant in the AI era.</p><div><hr></div><p>Louis and I launched the <strong>GENERATIVE AI MASTERCLASS</strong> (newsletter series exclusive to PAID subscribers) this month.</p><p>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>Simple breakdown of real-world architectures</strong></p></li><li><p>Frameworks you can plug into your work or business</p></li><li><p><strong>Proven systems behind ChatGPT, Perplexity, and Copilot</strong></p></li></ul><p><strong>&#128073; <a href="https://newsletter.systemdesign.one/subscribe?yearly=true">CLICK HERE TO JOIN THE GENERATIVE AI MASTERCLASS</a></strong></p><p>(Golden members will get the next Generative AI newsletter in the first week of May.)</p><div><hr></div><p>If you find this newsletter valuable, share it with a friend, and subscribe if you haven&#8217;t already. There are <a href="http://newsletter.systemdesign.one/subscribe?group=true">group discounts</a>, <a href="http://newsletter.systemdesign.one/subscribe?gift=true">gift options</a>, and <a href="https://newsletter.systemdesign.one/leaderboard">referral rewards</a> available.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://www.linkedin.com/in/nk-systemdesign-one/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png" width="152" height="152" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:320,&quot;width&quot;:320,&quot;resizeWidth&quot;:152,&quot;bytes&quot;:74009,&quot;alt&quot;:&quot;Author Neo Kim; System design case studies&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://www.linkedin.com/in/nk-systemdesign-one/&quot;,&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="Author Neo Kim; System design case studies" title="Author Neo Kim; System design case studies" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption"><strong>&#128075; Find me on <a href="https://www.linkedin.com/in/nk-systemdesign-one/">LinkedIn</a> | <a href="https://x.com/intent/follow?screen_name=systemdesignone">Twitter</a> | <a href="https://www.threads.net/@systemdesignone">Threads</a> | <a href="https://www.instagram.com/systemdesignone/">Instagram</a></strong></figcaption></figure></div><div><hr></div><p><strong>Want to reach 200K+ tech professionals at scale? </strong>&#128240;</p><p>If your company wants to reach 200K+ tech professionals, <a href="https://newsletter.systemdesign.one/p/sponsorship">advertise with me</a>.</p><div><hr></div><p>Thank you for supporting this newsletter.</p><p>You are now 210,001+ readers strong, very close to 210k. Let&#8217;s try to get 211k readers by 29 April. Consider sharing this post with your friends and get rewards.</p><p>Y&#8217;all are the best.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6oWl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" width="590" height="368.75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:800,&quot;resizeWidth&quot;:590,&quot;bytes&quot;:87878,&quot;alt&quot;:&quot;system design newsletter&quot;,&quot;title&quot;:&quot;system design newsletter&quot;,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/163380418?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="system design newsletter" title="system design newsletter" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.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 role="img" 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><title></title><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 class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/llm-evals?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/llm-evals?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p>Variance is how much your results change when you repeat the same evaluation. It tells you how spread out or inconsistent your scores are.</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><ul><li><p>Criteria: what you care about when judging the output (e.g., accuracy, clarity, helpfulness)</p></li><li><p>Rubric: how you score those criteria consistently (e.g., a 1&#8211;5 scale with clear definitions)</p></li><li><p>Test cases: specific inputs or examples that you use to evaluate the model</p></li></ul><p></p></div></div>]]></content:encoded></item><item><title><![CDATA[Vector Database - A Deep Dive]]></title><description><![CDATA[#141: A Beginner&#8217;s Guide to the AI Stack&#8217;s Most Misunderstood Component]]></description><link>https://newsletter.systemdesign.one/p/what-is-a-vector-database</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/what-is-a-vector-database</guid><dc:creator><![CDATA[Maxine Meurer]]></dc:creator><pubDate>Sat, 25 Apr 2026 09:11:55 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/f1a11bc3-2222-4fbe-a3db-234b1991cb9b_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/what-is-a-vector-database/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>You&#8217;ve built a search feature.</p><p>Then a user types a query, your application hits the database, and results come back ranked by relevance.</p><p><em>Simple enough</em>, it works perfectly.</p><p>But you thought about how search needs to actually understand what users meant, not just match the exact words they typed.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EE7V!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ca0a2b-f1b1-487b-8049-d82793dcce7f_800x800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EE7V!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ca0a2b-f1b1-487b-8049-d82793dcce7f_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!EE7V!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ca0a2b-f1b1-487b-8049-d82793dcce7f_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!EE7V!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ca0a2b-f1b1-487b-8049-d82793dcce7f_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!EE7V!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ca0a2b-f1b1-487b-8049-d82793dcce7f_800x800.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EE7V!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ca0a2b-f1b1-487b-8049-d82793dcce7f_800x800.png" width="800" height="800" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/45ca0a2b-f1b1-487b-8049-d82793dcce7f_800x800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:800,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!EE7V!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ca0a2b-f1b1-487b-8049-d82793dcce7f_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!EE7V!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ca0a2b-f1b1-487b-8049-d82793dcce7f_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!EE7V!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ca0a2b-f1b1-487b-8049-d82793dcce7f_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!EE7V!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ca0a2b-f1b1-487b-8049-d82793dcce7f_800x800.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 role="img" 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><title></title><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 user searching for <em>&#8220;how do I log in&#8221;</em> should find results about <em>&#8220;account access&#8221;</em> and <em>&#8220;sign in&#8221;</em> even if those exact words never appear in their query.</p><p>This kind of search, where the database understands meaning rather than just matching words, is called <strong>semantic search</strong>. It requires a completely different approach to how you store and search your data.</p><p>Yet if you try adding this in as a feature, everything that made your traditional relational database fast will stop working.</p><p><em>The tools you relied on: </em><code>indexes, WHERE clauses, keyword matching</code><em> were all built for finding exact values.</em></p><p><strong>Semantic search does NOT work with exact values.</strong></p><p>Instead, it works with meaning, and meaning is harder to search efficiently. A search that took milliseconds before now takes seconds, and the bigger your dataset, the worse it gets.</p><p>Your database is NOT broken.</p><p>It&#8217;s doing exactly what you told it to do: comparing your search against every single item in your database, one by one, because there is no other way to find &#8220;similar&#8221; when there is NO exact match.</p><p>This is where vector databases come in.</p><p>Not because they are trendy, but because traditional databases were never designed to handle this kind of search at scale.</p><p>If you&#8217;re a software engineer encountering the term &#8220;vector database&#8221; for the first time, whether your team is adding AI features or you keep seeing it mentioned everywhere and want to understand what it actually means, this newsletter explains it from the ground up&#8230;</p><div><hr></div><h2><strong><a href="https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary">[Webinar] Stop babysitting your coding agents (Partner)</a></strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2Yva!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 424w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 848w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 1272w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2Yva!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.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;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!2Yva!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 424w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 848w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.png 1272w, https://substackcdn.com/image/fetch/$s_!2Yva!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5360c077-4b63-4b77-ac93-49ad7fe35954_2048x1152.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 role="img" 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><title></title><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>Agents can generate code. Getting it right for your system, team conventions, and past decisions is the hard part &#8211; you end up wasting time and tokens in correction loops.</p><p>More MCPs give agents access to information, but not understanding. The teams pulling ahead use a context engine to give agents exactly what they need.</p><p><a href="https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary">Join Unblocked live on May 6 (FREE)</a> to see:</p><ul><li><p>Where teams get stuck on the AI maturity curve</p></li><li><p>How a context engine solves for quality, efficiency, and cost</p></li><li><p>Live demo: the same coding task with and without a context engine</p></li></ul><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary&quot;,&quot;text&quot;:&quot;Register Now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary"><span>Register Now</span></a></p><p>(Thanks to <a href="https://watch.getcontrast.io/register/unblocked-how-to-stop-babysitting-your-agents?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=primary">Unblocked</a> for partnering on this post.)</p><div><hr></div><p>I want to introduce <strong><a href="https://www.linkedin.com/in/maxinemeurer/">Maxine</a></strong> as the guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://www.linkedin.com/in/maxinemeurer/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!08DB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39b9c478-d7d7-4f94-a440-8cd2d9abe2fc_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!08DB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39b9c478-d7d7-4f94-a440-8cd2d9abe2fc_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!08DB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39b9c478-d7d7-4f94-a440-8cd2d9abe2fc_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!08DB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39b9c478-d7d7-4f94-a440-8cd2d9abe2fc_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!08DB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39b9c478-d7d7-4f94-a440-8cd2d9abe2fc_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/39b9c478-d7d7-4f94-a440-8cd2d9abe2fc_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;:278821,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://www.linkedin.com/in/maxinemeurer/&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/193910825?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39b9c478-d7d7-4f94-a440-8cd2d9abe2fc_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!08DB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39b9c478-d7d7-4f94-a440-8cd2d9abe2fc_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!08DB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39b9c478-d7d7-4f94-a440-8cd2d9abe2fc_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!08DB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39b9c478-d7d7-4f94-a440-8cd2d9abe2fc_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!08DB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39b9c478-d7d7-4f94-a440-8cd2d9abe2fc_1200x630.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 role="img" 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><title></title><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>She&#8217;s a cloud infrastructure engineer who spends her days scaling databases, debugging production incidents at 2 am, and writing about what actually works in production.</p><p>You can get a copy of her <strong><a href="https://mameurer.gumroad.com/l/LLMsForHumans?layout=profile">LLMs for Humans: From Prompts to Production (at 30% off right now)</a></strong>. It&#8217;s 20 chapters of practical applied AI with real production context, not theory. And it&#8217;ll help you get smarter about using AI tools in infrastructure workflows.</p><p>Checkout her work:</p><ul><li><p><a href="https://ilovedevops.substack.com/subscribe">Substack - I Love DevOps</a></p></li><li><p><a href="https://www.linkedin.com/in/maxinemeurer/">LinkedIn</a></p></li><li><p><a href="https://www.threads.com/@devopgirl">Threads</a></p></li></ul><p>Plus, if you&#8217;re thinking about making a career move into cloud or DevOps and want a structured path to get there, get a copy of her <strong><a href="https://mameurer.gumroad.com/l/devops-career-switch-blueprint?layout=profile">The DevOps Career Switch Blueprint</a>.</strong></p><div><hr></div><p><strong>Inside this newsletter, you&#8217;ll get:</strong></p><ul><li><p><strong>Why traditional search breaks.</strong> How exact-match databases fail with semantic meaning and why O(n) similarity search doesn&#8217;t scale.</p></li><li><p><strong>How vector search works.</strong> Embeddings, high-dimensional space, and why similarity is measured by distance instead of exact matches.</p></li><li><p><strong>The core architecture.</strong> Storage, indexing (HNSW), and query layers, with key tradeoffs in cost, latency, and accuracy.</p></li><li><p><strong>Query execution in practice.</strong> ANN search, metadata filtering (pre vs post), and ranking, including how real systems return results.</p></li><li><p><strong>Production realities.</strong> Scaling, replication, cost structure, monitoring, and failure modes teams hit in production.</p></li><li><p><strong>Decision framework.</strong> When pgvector is enough, when to use a dedicated vector DB, and when distributed systems become necessary.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Golden members get all posts like these!...</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><hr></div><h2><strong>Why Traditional Databases Struggle with Embeddings</strong></h2><p>Traditional relational databases are good at exact matches and range queries.</p><p>They use indexes and data structures so the database can jump directly to relevant rows without scanning the entire table.</p><p>When you query <code>WHERE user_id = 12345</code>, database uses an index to find that row instantly, the same way you&#8217;d look up a word in a dictionary: you don&#8217;t read every page, you jump straight to the right section. Also when you query, <code>WHERE created_at &gt; &#8216;2026-01-01&#8217;,</code> it works the same way for dates.</p><p>But embeddings break this model because there is no exact value to look up!</p><p>An <strong>embedding</strong> is a list of numbers that represents the meaning of a text.</p><p>Words, sentences, or entire paragraphs get converted into these numbers by an AI model, and <em>similar meanings produce similar numbers</em>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!clcD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d1b8027-9826-43dd-ac5f-7ddb18b1aeb0_800x800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!clcD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d1b8027-9826-43dd-ac5f-7ddb18b1aeb0_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!clcD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d1b8027-9826-43dd-ac5f-7ddb18b1aeb0_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!clcD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d1b8027-9826-43dd-ac5f-7ddb18b1aeb0_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!clcD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d1b8027-9826-43dd-ac5f-7ddb18b1aeb0_800x800.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!clcD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d1b8027-9826-43dd-ac5f-7ddb18b1aeb0_800x800.png" width="800" height="800" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4d1b8027-9826-43dd-ac5f-7ddb18b1aeb0_800x800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:800,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!clcD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d1b8027-9826-43dd-ac5f-7ddb18b1aeb0_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!clcD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d1b8027-9826-43dd-ac5f-7ddb18b1aeb0_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!clcD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d1b8027-9826-43dd-ac5f-7ddb18b1aeb0_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!clcD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d1b8027-9826-43dd-ac5f-7ddb18b1aeb0_800x800.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 role="img" 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><title></title><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>Instead of finding a specific row, you find rows closer in meaning, and &#8220;close&#8221; requires measuring distance in high-dimensional space rather than matching values. Think of it like a regular map with latitude and longitude, except you&#8217;re working with 1,536 dimensions instead of just 2.</p><p><em>Let&#8217;s walk through a concrete example to see why this creates a problem&#8230;</em></p><p>Imagine you have a document database where each document gets split into chunks.</p><p>And think of chunks like cutting a book into individual paragraphs so you can search each one separately. Each chunk gets converted into a 1,536-dimensional vector using an embedding model like OpenAI&#8217;s text-embedding-3-small:</p><ol><li><p>A user submits a search query</p></li><li><p>App converts the query into a vector using the same embedding model</p></li><li><p><em>Now you have to find the &#8220;most similar&#8221; document chunks</em></p></li></ol><p>Without specialized indexing, the only way to find &#8220;most similar&#8221; ones is to calculate the distance between your query vector and every chunk vector in your database, sort by distance, and return the top results.</p><p><em>Let&#8217;s break down what it means&#8230;</em></p><p>A vector is simply a list of numbers. In AI, those numbers represent meaning.</p><p>When you convert text into an embedding, you&#8217;re assigning it a location in a very high-dimensional space (imagine a map with 1,536 dimensions instead of the normal 2, latitude and longitude). Similar pieces of text end up close to each other on this map, while unrelated text ends up far apart.</p><p>When a user searches for something, their query also gets converted into coordinates on this map. To find the most relevant results, you need to measure the distance from the query&#8217;s location to every document chunk&#8217;s location in your database, then return the closest ones.</p><p><em>But here&#8217;s the problem&#8230;</em></p><p>Without an index, there&#8217;s no shortcut. You must measure the distance to each item.</p><p>Now imagine you&#8217;re standing in Times Square in New York City, and you need to find the 10 closest coffee shops. Without a map or any organized system, your only option is to:</p><ol><li><p>Walk to every building</p></li><li><p>Check if it&#8217;s a coffee shop</p></li><li><p>Measure how far it is from Times Square</p></li><li><p>Keep a list of the 10 closest ones you&#8217;ve found</p></li></ol><p>If there are 10k buildings, you check all 10k. And if there are 10 million buildings, you check all 10 million.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gu5U!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F283169d2-99c4-4a06-8f5d-400a67802149_800x800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gu5U!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F283169d2-99c4-4a06-8f5d-400a67802149_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!gu5U!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F283169d2-99c4-4a06-8f5d-400a67802149_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!gu5U!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F283169d2-99c4-4a06-8f5d-400a67802149_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!gu5U!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F283169d2-99c4-4a06-8f5d-400a67802149_800x800.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gu5U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F283169d2-99c4-4a06-8f5d-400a67802149_800x800.png" width="800" height="800" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/283169d2-99c4-4a06-8f5d-400a67802149_800x800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:800,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!gu5U!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F283169d2-99c4-4a06-8f5d-400a67802149_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!gu5U!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F283169d2-99c4-4a06-8f5d-400a67802149_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!gu5U!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F283169d2-99c4-4a06-8f5d-400a67802149_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!gu5U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F283169d2-99c4-4a06-8f5d-400a67802149_800x800.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 role="img" 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><title></title><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 more buildings that exist, the longer it takes&#8230;</p><p>Put simply, it takes&nbsp;<strong>O(n)</strong>&nbsp;time, and it grows linearly with the size of your dataset.</p><p>In practical terms, if you have 10,000 document chunks and each distance calculation takes 0.0001 seconds, one query takes 1 second. That&#8217;s not terrible.</p><p><em>But what if you have 10 million chunks?</em></p><p>That same query now takes 1,000 seconds, i.e., 16 minutes. And if your application serves 100 queries per second from different users? Your system immediately grinds to a halt!</p><p>This is why traditional databases struggle with embeddings&#8230;</p><p>Their indexes are built for exact matches.</p><p>They can jump straight to <code>user_id = 12345</code> without checking every row. But with vectors, there are no exact matches, only &#8220;similar&#8221; matches, and similarity requires measuring distances.</p><p><em>Let&#8217;s now imagine finding a similar song to the one you already like&#8230;</em></p><p>You cannot just look it up by name; you have to compare it against every other song across hundreds of characteristics: tempo, key, energy, mood, and so on. The more songs in your library, the longer it takes.</p><p><strong>Vector search</strong> works the same way, except instead of songs, you compare text, and instead of a few characteristics, you are comparing across 1,536 dimensions at the same time.</p><p><em>Without specialized techniques to avoid checking everything, the math simply doesn&#8217;t scale.</em></p><p>This is where people often bring up <a href="https://github.com/pgvector/pgvector">pgvector</a>, a PostgreSQL extension that adds vector search capabilities to Postgres. It&#8217;s a good option for smaller datasets and lets you avoid adding another database to your stack. This keeps operational efforts very low.</p><p>For datasets with fewer than 100,000 vectors and <em>moderate</em> query volumes, pgvector works well and keeps your infrastructure simpler.</p><p>But as your dataset grows into the millions and your query latency requirements tighten, you hit the limits of what a general-purpose database can do for this specific workload.</p><p>You don&#8217;t need a specialized vector database just because you&#8217;re working with embeddings, but you need to understand when the operational trade-offs tip in favor of dedicated infrastructure.</p><p><em>This brings us to the core challenge that vector databases solve&#8230;</em></p><p>How do you find approximate nearest neighbors in high-dimensional space without comparing against every vector, while still returning results that are &#8220;good enough&#8221; in terms of accuracy?</p><p>The answer involves building specialized index structures that trade accuracy for massive speed improvements, and understanding those trade-offs is essential for operating these systems in production.</p><div><hr></div><h2><strong>Architecture: How It Works Under the Hood</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!isUf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F317f1e41-a15b-4682-9de6-da170fbd1b73_800x800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!isUf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F317f1e41-a15b-4682-9de6-da170fbd1b73_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!isUf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F317f1e41-a15b-4682-9de6-da170fbd1b73_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!isUf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F317f1e41-a15b-4682-9de6-da170fbd1b73_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!isUf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F317f1e41-a15b-4682-9de6-da170fbd1b73_800x800.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!isUf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F317f1e41-a15b-4682-9de6-da170fbd1b73_800x800.png" width="800" height="800" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/317f1e41-a15b-4682-9de6-da170fbd1b73_800x800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:800,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!isUf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F317f1e41-a15b-4682-9de6-da170fbd1b73_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!isUf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F317f1e41-a15b-4682-9de6-da170fbd1b73_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!isUf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F317f1e41-a15b-4682-9de6-da170fbd1b73_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!isUf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F317f1e41-a15b-4682-9de6-da170fbd1b73_800x800.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 role="img" 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><title></title><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>Vector databases have three key layers: <em>storage, index, and query</em>.</p><p>Each layer involves trade-offs that directly affect your operational concerns: cost, latency, accuracy, and scalability.</p><p>Let&#8217;s break down what matters from an infrastructure perspective&#8230;</p><h3><strong>Storage Layer: Where Vectors Live</strong></h3><p>Vectors are massive.</p><p>A single 1,536-dimensional vector using 32-bit floats takes up 6KB of storage. If you multiply that across millions of vectors, storage costs add up fast. This is a problem every vector database must solve at its foundation: <em>the storage layer determines how vectors are physically stored, compressed, and retrieved from disk.</em> This layer focuses on compression techniques that reduce both storage costs and the memory footprint while preserving as much accuracy as possible.</p><p><em>The most common approach is quantization.</em></p><p><strong>Quantization</strong> reduces the precision of each dimension to use fewer bits.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tpO6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e0fb2b2-0f68-4fbe-9ebc-eb650d508ef3_800x800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tpO6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e0fb2b2-0f68-4fbe-9ebc-eb650d508ef3_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!tpO6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e0fb2b2-0f68-4fbe-9ebc-eb650d508ef3_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!tpO6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e0fb2b2-0f68-4fbe-9ebc-eb650d508ef3_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!tpO6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e0fb2b2-0f68-4fbe-9ebc-eb650d508ef3_800x800.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tpO6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e0fb2b2-0f68-4fbe-9ebc-eb650d508ef3_800x800.png" width="800" height="800" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9e0fb2b2-0f68-4fbe-9ebc-eb650d508ef3_800x800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:800,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!tpO6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e0fb2b2-0f68-4fbe-9ebc-eb650d508ef3_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!tpO6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e0fb2b2-0f68-4fbe-9ebc-eb650d508ef3_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!tpO6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e0fb2b2-0f68-4fbe-9ebc-eb650d508ef3_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!tpO6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e0fb2b2-0f68-4fbe-9ebc-eb650d508ef3_800x800.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 role="img" 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><title></title><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>Instead of storing each dimension as a 32-bit float, you quantize to 8-bit integers (scalar quantization) or binary representations (binary quantization).</p><p>This can reduce storage and memory requirements by 4x or more, but it introduces approximation error. <strong>Approximation error</strong> is the gap between the compressed version of data and the original.</p><p>When you round numbers to save space, your calculations become slightly less precise. In vector search, this means you might occasionally miss a result that was truly the closest match, but in practice, the difference is small enough that most applications never notice it.</p><p>In production, you&#8217;re constantly trading off storage costs for search accuracy, and the right balance depends on your use case.</p><p><em>Another critical decision is the trade-off between memory and disk&#8230;</em></p><p>For <strong>maximum query speed</strong>, you want your vector index in memory, but that&#8217;s expensive at scale. Some vector databases support tiered storage, where frequently accessed vectors stay in memory while cold data lives on disk, or hybrid approaches in which the index structure stays in memory while raw vectors get pulled from disk when needed.</p><p>These architectural choices directly affect your cost structure and query latency percentiles.</p><p>From an operational perspective, you need to understand how your chosen vector database handles durability and recovery:</p><ul><li><p><em>What happens if a node crashes mid-write?</em></p></li><li><p><em>How long does it take to rebuild indexes after a restart?</em></p></li><li><p><em>Are vectors written to disk synchronously or asynchronously?</em></p></li></ul><p>These aren&#8217;t theoretical questions. They&#8217;re the difference between acceptable downtime and a major incident when something goes wrong.</p><h3><strong>Indexing Layer: Graph Structure</strong></h3><p>This is where the &#8220;magic&#8221; happens, and by magic I mean carefully engineered data structures that let you find approximate neighbors without exhaustive search.</p><p>The most popular algorithm in production vector databases is <strong>HNSW</strong> (Hierarchical Navigable Small World), and it&#8217;s worth understanding at a conceptual level even if you&#8217;re not implementing it yourself.</p><p>The core idea behind HNSW is based on &#8220;small world&#8221; networks, the same principle that says you&#8217;re only a few connections away from any other person on the planet.</p><p>Instead of comparing your query vector against every vector in your database, HNSW builds a multi-layer graph in which similar vectors are connected to each other. When you query, the algorithm starts at the top layer and navigates toward your target by following edges to similar neighbors, dropping through layers until it reaches the most similar vectors at the bottom layer.</p><p><em>Remember our map analogy?</em></p><p>Your vectors are locations on a high-dimensional map, and you&#8217;re trying to find the closest ones to your query without checking every single location. HNSW solves this by building a navigation system with different zoom levels.</p><p>Think of it like Google Maps navigating from New York to a specific coffee shop in San Francisco:</p><ul><li><p><strong>Top layer (zoomed out):</strong>&nbsp;From New York, HNSW identifies the general direction of your target, the West Coast, and follows connections to get you to California. You&#8217;re not considering every city in America, just the major waypoints that get you closer to where you need to be.</p></li><li><p><strong>Middle layers (zooming in):</strong> Now you&#8217;re looking at California. The algorithm narrows down to the San Francisco Bay Area, following connections between nearby locations. You&#8217;re still not checking every street, just the neighborhoods that are directionally correct toward the coffee shop you want to visit.</p></li><li><p><strong>Bottom layer (street level):</strong> Finally, you&#8217;re at the specific neighborhood and can see individual addresses. The algorithm follows the last few connections to find the exact coffee shop location (or, in vector terms, the most similar document chunks).</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zZEO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85edadd3-1c48-4baa-8cfc-3288ba15b2e9_800x800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zZEO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85edadd3-1c48-4baa-8cfc-3288ba15b2e9_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!zZEO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85edadd3-1c48-4baa-8cfc-3288ba15b2e9_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!zZEO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85edadd3-1c48-4baa-8cfc-3288ba15b2e9_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!zZEO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85edadd3-1c48-4baa-8cfc-3288ba15b2e9_800x800.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zZEO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85edadd3-1c48-4baa-8cfc-3288ba15b2e9_800x800.png" width="800" height="800" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/85edadd3-1c48-4baa-8cfc-3288ba15b2e9_800x800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:800,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!zZEO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85edadd3-1c48-4baa-8cfc-3288ba15b2e9_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!zZEO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85edadd3-1c48-4baa-8cfc-3288ba15b2e9_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!zZEO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85edadd3-1c48-4baa-8cfc-3288ba15b2e9_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!zZEO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85edadd3-1c48-4baa-8cfc-3288ba15b2e9_800x800.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 role="img" 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><title></title><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 each zoom level, you&#8217;re following connections between &#8220;nearby&#8221; locations without checking everywhere.</p><p>You only need to follow the connections that get you closer to your target. This is how HNSW turns an O(n) problem into something much faster: <em>it builds a navigation structure that lets you skip large portions of the map in the wrong direction.</em></p><p>The key trade-off in HNSW is speed versus accuracy, controlled by two parameters: the number of connections each vector has (called &#8220;M&#8221; or &#8220;max connections&#8221;) and the number of neighbors to check during search (called &#8220;ef&#8221; or &#8220;exploration factor&#8221;).</p><p>Higher values mean better accuracy, but slower queries and larger indexes&#8230;</p><p>Lower values mean faster queries, but you might miss some relevant results. In production, you tune these parameters based on your latency requirements and tolerance for accuracy.</p><p><em>Building the HNSW index is expensive.</em></p><p>Inserting vectors requires calculating distances and updating graph connections, which is why bulk index building often happens offline or during low-traffic periods. Index build time matters because it affects how quickly you can recover from failures, deploy updates, or onboard new data.</p><p>You do not need to understand the math behind HNSW to work with vector databases.</p><p>Just like driving a car, you might not know how the engine works, and that doesn&#8217;t affect how you drive. But knowing that the engine exists and what it does helps you figure out what is wrong when the car breaks down.</p><p>What you need to know is that HNSW produces approximate results, not perfect ones, and it&#8217;s possible to adjust its approximation. When search results seem wrong, queries suddenly slow down, or the index fails to build, this understanding helps you identify the problem.</p><div><hr></div><blockquote><p>Get a copy of <em><strong><a href="https://mameurer.gumroad.com/l/LLMsForHumans?layout=profile">LLMs for Humans: From Prompts to Production</a></strong> </em>right now and save 30%.</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://mameurer.gumroad.com/l/LLMsForHumans?layout=profile" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7mFj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6003f91-fafd-4281-99c4-c6947facff9d_590x756.jpeg 424w, https://substackcdn.com/image/fetch/$s_!7mFj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6003f91-fafd-4281-99c4-c6947facff9d_590x756.jpeg 848w, https://substackcdn.com/image/fetch/$s_!7mFj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6003f91-fafd-4281-99c4-c6947facff9d_590x756.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!7mFj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6003f91-fafd-4281-99c4-c6947facff9d_590x756.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7mFj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6003f91-fafd-4281-99c4-c6947facff9d_590x756.jpeg" width="320" height="410.03389830508473" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e6003f91-fafd-4281-99c4-c6947facff9d_590x756.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:756,&quot;width&quot;:590,&quot;resizeWidth&quot;:320,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://mameurer.gumroad.com/l/LLMsForHumans?layout=profile&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!7mFj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6003f91-fafd-4281-99c4-c6947facff9d_590x756.jpeg 424w, https://substackcdn.com/image/fetch/$s_!7mFj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6003f91-fafd-4281-99c4-c6947facff9d_590x756.jpeg 848w, https://substackcdn.com/image/fetch/$s_!7mFj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6003f91-fafd-4281-99c4-c6947facff9d_590x756.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!7mFj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6003f91-fafd-4281-99c4-c6947facff9d_590x756.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 role="img" 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><title></title><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><p><em><strong>Reminder: this is a teaser of the subscriber-only newsletter, exclusive to my golden members.</strong></em></p><p>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>High-level architecture of real-world systems.</strong></p></li><li><p>Deep dive into how popular real-world systems work.</p></li><li><p><strong>How real-world systems handle scale, reliability, and performance.</strong></p></li></ul><p>And much more!</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe&quot;,&quot;text&quot;:&quot;Unlock Full Access&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe"><span>Unlock Full Access</span></a></p><div><hr></div><h3><strong>Query Layer: How Requests Move Through System</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dk46!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6d104f-f42f-4f31-86ed-7fc7865f326f_800x800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dk46!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6d104f-f42f-4f31-86ed-7fc7865f326f_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!dk46!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6d104f-f42f-4f31-86ed-7fc7865f326f_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!dk46!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6d104f-f42f-4f31-86ed-7fc7865f326f_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!dk46!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6d104f-f42f-4f31-86ed-7fc7865f326f_800x800.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dk46!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6d104f-f42f-4f31-86ed-7fc7865f326f_800x800.png" width="800" height="800" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b6d104f-f42f-4f31-86ed-7fc7865f326f_800x800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:800,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!dk46!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6d104f-f42f-4f31-86ed-7fc7865f326f_800x800.png 424w, https://substackcdn.com/image/fetch/$s_!dk46!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6d104f-f42f-4f31-86ed-7fc7865f326f_800x800.png 848w, https://substackcdn.com/image/fetch/$s_!dk46!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6d104f-f42f-4f31-86ed-7fc7865f326f_800x800.png 1272w, https://substackcdn.com/image/fetch/$s_!dk46!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6d104f-f42f-4f31-86ed-7fc7865f326f_800x800.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 role="img" 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><title></title><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>When a query hits your vector database, it follows a specific path:</p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/what-is-a-vector-database">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[9 Agentic Patterns, Simply Explained]]></title><description><![CDATA[#140: The design decisions behind modern AI systems: how each design pattern works, where it breaks, and when to use it.]]></description><link>https://newsletter.systemdesign.one/p/agentic-design-patterns</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/agentic-design-patterns</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Wed, 22 Apr 2026 11:50:43 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/23793653-8f74-4b7a-b9ac-4ba50a00eb78_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/agentic-design-patterns/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>When you build software with LLMs<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a>, you need to decide how much control to give the model.</p><p><em>Does your code run every step, or does the model figure out the steps on its own?</em></p><p>Agentic patterns are design patterns for making that decision. They&#8217;re the same architecture choices you already make in any system: <em>who controls what happens next, what happens on failure, and how data moves between components.</em></p><p>The difference is that some of those components are now language models.</p><p>This newsletter covers nine of those patterns&#8230;</p><p>On one end, <em>workflow patterns</em> where your code controls every step. On the other hand, <em>agent patterns</em> where the Large Language Model (<strong>LLM</strong>) decides what to do next.</p><p>That boundary is a decision about how much control to hand to the model: at some point, you stop telling the model what to do and start letting it figure that out.</p><p>The first question isn&#8217;t which pattern to use. It&#8217;s whether you need one at all.</p><p>Let&#8217;s start there...</p><div><hr></div><h2><a href="https://pages.awscloud.com/awsmp-gim-jqup-adhoc-aim-ent-ai-data-leader-book-1-ent.html?trk=68d21c4e-c3e8-4668-959c-cb996265ef28&amp;sc_channel=el">Find out why enterprise leaders are doubling down on data foundations for AI (Partner)</a></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://pages.awscloud.com/awsmp-gim-jqup-adhoc-aim-ent-ai-data-leader-book-1-ent.html?trk=68d21c4e-c3e8-4668-959c-cb996265ef28&amp;sc_channel=el" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!s4PY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc0b098a-af83-481b-805b-c1ad861f8c9d_1280x720.gif 424w, https://substackcdn.com/image/fetch/$s_!s4PY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc0b098a-af83-481b-805b-c1ad861f8c9d_1280x720.gif 848w, https://substackcdn.com/image/fetch/$s_!s4PY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc0b098a-af83-481b-805b-c1ad861f8c9d_1280x720.gif 1272w, https://substackcdn.com/image/fetch/$s_!s4PY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc0b098a-af83-481b-805b-c1ad861f8c9d_1280x720.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!s4PY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc0b098a-af83-481b-805b-c1ad861f8c9d_1280x720.gif" width="1280" height="720" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cc0b098a-af83-481b-805b-c1ad861f8c9d_1280x720.gif&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;:2609945,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:&quot;https://pages.awscloud.com/awsmp-gim-jqup-adhoc-aim-ent-ai-data-leader-book-1-ent.html?trk=68d21c4e-c3e8-4668-959c-cb996265ef28&amp;sc_channel=el&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/193554859?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc0b098a-af83-481b-805b-c1ad861f8c9d_1280x720.gif&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!s4PY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc0b098a-af83-481b-805b-c1ad861f8c9d_1280x720.gif 424w, https://substackcdn.com/image/fetch/$s_!s4PY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc0b098a-af83-481b-805b-c1ad861f8c9d_1280x720.gif 848w, https://substackcdn.com/image/fetch/$s_!s4PY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc0b098a-af83-481b-805b-c1ad861f8c9d_1280x720.gif 1272w, https://substackcdn.com/image/fetch/$s_!s4PY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc0b098a-af83-481b-805b-c1ad861f8c9d_1280x720.gif 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 role="img" 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><title></title><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>AI is moving fast, but your data foundation isn&#8217;t keeping up?</p><p>That&#8217;s exactly why leaders from JPMorgan, Mercedes-Benz, Siemens, and Roche contributed to this AWS book on agentic analytics.</p><p>Here&#8217;s what you get:</p><ul><li><p>Real strategies from enterprise leaders: Learn how top companies are building data foundations for AI systems that actually scale.</p></li><li><p>Practical frameworks you can apply: From data strategy to data products, ML, and agentic AI.</p></li><li><p>Perspectives from 15+ enterprise leaders: Each chapter brings a unique view from senior leaders across industries.</p></li><li><p>Complex topics broken down clearly: Understand what matters without getting lost in theory.</p></li></ul><p>An <strong><a href="https://pages.awscloud.com/awsmp-gim-jqup-adhoc-aim-ent-ai-data-leader-book-1-ent.html?trk=68d21c4e-c3e8-4668-959c-cb996265ef28&amp;sc_channel=el">AWS book </a></strong>designed to help you build data foundations for intelligent agents that scale.</p><p>Download it now and learn how to build systems ready for intelligent agents.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://pages.awscloud.com/awsmp-gim-jqup-adhoc-aim-ent-ai-data-leader-book-1-ent.html?trk=68d21c4e-c3e8-4668-959c-cb996265ef28&amp;sc_channel=el&quot;,&quot;text&quot;:&quot;Get the AWS Data &amp; AI Book&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://pages.awscloud.com/awsmp-gim-jqup-adhoc-aim-ent-ai-data-leader-book-1-ent.html?trk=68d21c4e-c3e8-4668-959c-cb996265ef28&amp;sc_channel=el"><span>Get the AWS Data &amp; AI Book</span></a></p><p>(Thanks to <a href="https://pages.awscloud.com/awsmp-gim-jqup-adhoc-aim-ent-ai-data-leader-book-1-ent.html?trk=68d21c4e-c3e8-4668-959c-cb996265ef28&amp;sc_channel=el">AWS</a> for partnering on this post.)</p><div><hr></div><p><strong>Inside this newsletter, you&#8217;ll get:</strong></p><ul><li><p><strong>The shift from prompts to systems.</strong> Why simple LLM calls break down, and how workflows and agents introduce structured decision-making.</p></li><li><p><strong>A practical escalation ladder.</strong> When to stay simple, when to use workflows, and when agents are actually justified.</p></li><li><p><strong>Workflow patterns.</strong> chaining, routing, parallelization, and orchestrator-workers, with clear tradeoffs in cost, latency, and failure modes.</p></li><li><p><strong>Agent patterns.</strong> Reflection, tool use, ReAct, and planning, focusing on how the model makes decisions and where things go wrong.</p></li><li><p><strong>Evaluator-optimizer loop.</strong> How to add a reliability layer with evaluation, iteration limits, and cost control.</p></li><li><p><strong>Real-world case study.</strong> Combining multiple patterns in an AI code review pipeline, showing how to choose the simplest architecture that works.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Golden members get all posts like these!...</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><hr></div><h2><strong>Not everything needs an agent</strong></h2><p>Most tasks don&#8217;t need an agent<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>&#8230;</p><p>Most tasks don&#8217;t even need a workflow&#8230;The default should be the simplest setup that works, and you escalate only when that setup breaks.</p><p>Start with a <strong>direct API call to an LLM</strong>. You can do more with this than most people think:</p><ul><li><p>Summarization</p></li><li><p>Classification</p></li><li><p>Extraction</p></li><li><p>Rewriting</p></li><li><p>Translation</p></li><li><p>Code generation with clear specs</p></li></ul><p>Most people skip this level too quickly!</p><p><strong>Workflow patterns</strong> are the next step up.</p><p>Escalate when a task has many steps, and when focused attention at each step improves the output. Between those steps, you define <strong>validation gates</strong>: <em>checks that verify the output before passing it forward</em>. The defining feature: <em>you can write every step down before the system runs.</em> Your code owns the control flow.</p><p>And the LLM handles the details.</p><p><strong>Agent patterns</strong> are for when the number and type of steps are <em>unknown</em> until the system runs.</p><p>The model needs to look at results, decide what to do next, and choose its own path. For example, say you built a support agent that handles order cancellations. A customer asks to cancel, but the agent doesn&#8217;t know upfront whether it needs to check the refund policy, look up the shipping status, or pass the issue to a human.</p><p>The steps depend on what it finds&#8230;</p><p>Here&#8217;s how you know it&#8217;s time to switch: you write more code handling errors and exceptions than doing the actual work. Or you keep adding special cases for situations the LLM encounters you didn&#8217;t plan for.</p><p>If you can still write down all the steps before the system runs, stick with a workflow.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SSER!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6337a830-7cfd-437c-a23d-24bf10f7dafb_2048x1143.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SSER!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6337a830-7cfd-437c-a23d-24bf10f7dafb_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!SSER!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6337a830-7cfd-437c-a23d-24bf10f7dafb_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!SSER!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6337a830-7cfd-437c-a23d-24bf10f7dafb_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!SSER!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6337a830-7cfd-437c-a23d-24bf10f7dafb_2048x1143.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SSER!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6337a830-7cfd-437c-a23d-24bf10f7dafb_2048x1143.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6337a830-7cfd-437c-a23d-24bf10f7dafb_2048x1143.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;:null,&quot;alt&quot;:&quot;Agentic pattern complexity escalation ladder showing four levels from direct API calls to multi-agent systems with decision criteria at each step-up point&quot;,&quot;title&quot;:&quot;Agentic pattern complexity escalation ladder showing four levels from direct API calls to multi-agent systems with decision criteria at each step-up point&quot;,&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="Agentic pattern complexity escalation ladder showing four levels from direct API calls to multi-agent systems with decision criteria at each step-up point" title="Agentic pattern complexity escalation ladder showing four levels from direct API calls to multi-agent systems with decision criteria at each step-up point" srcset="https://substackcdn.com/image/fetch/$s_!SSER!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6337a830-7cfd-437c-a23d-24bf10f7dafb_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!SSER!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6337a830-7cfd-437c-a23d-24bf10f7dafb_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!SSER!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6337a830-7cfd-437c-a23d-24bf10f7dafb_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!SSER!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6337a830-7cfd-437c-a23d-24bf10f7dafb_2048x1143.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 role="img" 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><title></title><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>Agent patterns sit within multi-agent architectures, i.e., many agents cooperate on the same problem, each with its own role.</p><p>One common mistake: you get your system to 70-80% of a prototype and assume the architecture needs upgrading. It usually doesn&#8217;t&#8230;The real issue is usually prompt quality or missing validation gates. Move to a more complex pattern only after the simpler one has actually failed, not when it feels limiting.</p><p>With that baseline set, here are the four workflow patterns:</p><div><hr></div><h2><strong>Workflow patterns: you control the flow</strong></h2><p>With workflow patterns, your code controls what happens.</p><p>You decide the steps, the order, and the checks between them. The LLM handles each step, but your code is in charge&#8230;</p><h3><strong>1. Prompt chaining</strong></h3><p>Prompt chaining breaks a task into a series of LLM calls.</p><p>Each call takes the output from the previous step, and a check runs between them to ensure the result is correct before moving on.</p><p>If you&#8217;ve ever set up a <strong>CI/CD</strong> (Continuous Integration/Continuous Deployment) pipeline, this is the same idea. A build pipeline compiles, lints, tests, and packages. Each step must pass before the next one runs.</p><p>If tests fail, the pipeline stops.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qUdp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6f8b6ec-1bc5-4670-9b25-3c2d782f1098_2048x1143.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qUdp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6f8b6ec-1bc5-4670-9b25-3c2d782f1098_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!qUdp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6f8b6ec-1bc5-4670-9b25-3c2d782f1098_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!qUdp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6f8b6ec-1bc5-4670-9b25-3c2d782f1098_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!qUdp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6f8b6ec-1bc5-4670-9b25-3c2d782f1098_2048x1143.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qUdp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6f8b6ec-1bc5-4670-9b25-3c2d782f1098_2048x1143.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e6f8b6ec-1bc5-4670-9b25-3c2d782f1098_2048x1143.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;:null,&quot;alt&quot;:&quot;Prompt chaining workflow pattern showing sequential LLM calls connected by validation gates that stop the pipeline on failure&quot;,&quot;title&quot;:&quot;Prompt chaining workflow pattern showing sequential LLM calls connected by validation gates that stop the pipeline on failure&quot;,&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="Prompt chaining workflow pattern showing sequential LLM calls connected by validation gates that stop the pipeline on failure" title="Prompt chaining workflow pattern showing sequential LLM calls connected by validation gates that stop the pipeline on failure" srcset="https://substackcdn.com/image/fetch/$s_!qUdp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6f8b6ec-1bc5-4670-9b25-3c2d782f1098_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!qUdp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6f8b6ec-1bc5-4670-9b25-3c2d782f1098_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!qUdp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6f8b6ec-1bc5-4670-9b25-3c2d782f1098_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!qUdp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6f8b6ec-1bc5-4670-9b25-3c2d782f1098_2048x1143.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 role="img" 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><title></title><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 example, in <a href="https://gradientflow.substack.com/p/ais-biggest-enterprise-test-case">legal contract review</a>, this looks like: extract all clauses from a contract, classify each clause by risk level, then generate a summary of high-risk items for human review. Products like <a href="https://legal.thomsonreuters.com/en/c/cocounsel">Thomson Reuters CoCounsel</a> and Robin AI run variations of this pipeline.</p><p>Each step gets a focused prompt with a narrow task, and a validation gate checks the output before passing it forward.</p><h4><em><strong>Tradeoffs</strong></em></h4><p>Latency grows linearly&#8230;</p><p>Five steps mean five round-trip. Errors carry forward: if step two misclassifies a clause, steps three through five process bad input. The gates between steps catch these failures early, but they only catch what the conditions you write can catch.</p><h3><strong>2. Routing</strong></h3><p>A routing pattern classifies the input and sends it to the right handler: <em>a different prompt, a different model, or a different sub-workflow.</em></p><p>Each handler is built for one type of input.</p><p>This is like a hospital front desk. A patient walks in, the front desk checks their symptoms, and then sends them to the right doctor. The front desk doesn&#8217;t treat anyone. And the doctor doesn&#8217;t check in patients.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YT5p!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36bd3215-0100-4043-9ebd-0589949a309a_2048x1143.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YT5p!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36bd3215-0100-4043-9ebd-0589949a309a_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!YT5p!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36bd3215-0100-4043-9ebd-0589949a309a_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!YT5p!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36bd3215-0100-4043-9ebd-0589949a309a_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!YT5p!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36bd3215-0100-4043-9ebd-0589949a309a_2048x1143.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YT5p!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36bd3215-0100-4043-9ebd-0589949a309a_2048x1143.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/36bd3215-0100-4043-9ebd-0589949a309a_2048x1143.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;:null,&quot;alt&quot;:&quot;Routing pattern architecture showing a classifier directing inputs to cheap, specialized, or expensive model handlers based on input type&quot;,&quot;title&quot;:&quot;Routing pattern architecture showing a classifier directing inputs to cheap, specialized, or expensive model handlers based on input type&quot;,&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="Routing pattern architecture showing a classifier directing inputs to cheap, specialized, or expensive model handlers based on input type" title="Routing pattern architecture showing a classifier directing inputs to cheap, specialized, or expensive model handlers based on input type" srcset="https://substackcdn.com/image/fetch/$s_!YT5p!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36bd3215-0100-4043-9ebd-0589949a309a_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!YT5p!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36bd3215-0100-4043-9ebd-0589949a309a_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!YT5p!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36bd3215-0100-4043-9ebd-0589949a309a_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!YT5p!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36bd3215-0100-4043-9ebd-0589949a309a_2048x1143.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 role="img" 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><title></title><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 href="https://sierra.ai/blog/constellation-of-models">Sierra AI</a> routes across 15+ models this way.</p><p>Classification tasks go to one model, tool calling to another, and response generation to a third. Customer support platforms like <a href="https://www.intercom.com/help/en/articles/9929230-the-fin-ai-engine">Intercom Fin</a> route each customer request based on what the customer wants and how they feel about it, sending requests to either an AI handler or a human agent.</p><p>The cost argument is built into the pattern&#8230;</p><p>Simple queries hit cheap, fast models. While complex ones hit expensive, capable ones. You&#8217;re not paying the highest prices for work that a smaller model handles well.</p><h4><em><strong>Tradeoffs</strong></em></h4><p>In 1 word: misclassification.</p><p>A complex query routed to the cheaper model produces a poor answer. A simple query routed to the expensive model is just a waste of money.</p><p>Either way, the router is a single point of failure, and its accuracy sets the upper limit for the entire system.</p><h3><strong>3. Parallelization</strong></h3><p>In software, parallelization means running many tasks simultaneously rather than one after another. With LLMs, it has two variants that solve different problems&#8230;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8m3i!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F244a234b-7085-4ac5-ae83-4a49c35d3810_2048x1143.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8m3i!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F244a234b-7085-4ac5-ae83-4a49c35d3810_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8m3i!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F244a234b-7085-4ac5-ae83-4a49c35d3810_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8m3i!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F244a234b-7085-4ac5-ae83-4a49c35d3810_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8m3i!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F244a234b-7085-4ac5-ae83-4a49c35d3810_2048x1143.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8m3i!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F244a234b-7085-4ac5-ae83-4a49c35d3810_2048x1143.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/244a234b-7085-4ac5-ae83-4a49c35d3810_2048x1143.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;:null,&quot;alt&quot;:&quot;Parallelization pattern comparing sectioning (split task into independent subtasks and merge) versus voting (run same task multiple times and aggregate for consensus)&quot;,&quot;title&quot;:&quot;Parallelization pattern comparing sectioning (split task into independent subtasks and merge) versus voting (run same task multiple times and aggregate for consensus)&quot;,&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="Parallelization pattern comparing sectioning (split task into independent subtasks and merge) versus voting (run same task multiple times and aggregate for consensus)" title="Parallelization pattern comparing sectioning (split task into independent subtasks and merge) versus voting (run same task multiple times and aggregate for consensus)" srcset="https://substackcdn.com/image/fetch/$s_!8m3i!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F244a234b-7085-4ac5-ae83-4a49c35d3810_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8m3i!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F244a234b-7085-4ac5-ae83-4a49c35d3810_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8m3i!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F244a234b-7085-4ac5-ae83-4a49c35d3810_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8m3i!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F244a234b-7085-4ac5-ae83-4a49c35d3810_2048x1143.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 role="img" 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><title></title><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>Sectioning</strong> splits a task into independent parts, runs them in parallel, and merges the results. This is like a construction crew. Electricians, plumbers, and carpenters work in the same building at the same time. Their work gets combined at the end.</p><p><a href="https://docs.github.com/en/code-security/code-scanning/introduction-to-code-scanning/about-code-scanning">GitHub Advanced Security</a> works this way: CodeQL and third-party tools like Snyk and Semgrep scan the same pull request in parallel, each producing independent security alerts.</p><p><strong>Voting</strong> runs the same task many times with different prompts and combines the answers. This is like a jury. Each juror looks at the same evidence and gives their own opinion, and the group decides together.</p><p>You&#8217;d build this for something like a security review: three separate prompts analyze the same code change for vulnerabilities, and you flag an issue only if two or more agree. Running the task many times is more expensive, but it catches fewer false alarms.</p><p>In short, <em>sectioning</em> gives each worker a different job; <em>voting</em> gives every worker the same job.</p><h4><em><strong>Tradeoffs</strong></em></h4><p>Cost multiplies with every parallel branch.</p><p>Partial failures are a design decision you need to plan for up front:<em> if one branch fails, do you retry it, proceed with the others, or fail the whole operation?</em> There&#8217;s no universal answer, and a wrong choice is expensive.</p><h3><strong>4. Orchestrator-workers</strong></h3><p>The orchestrator-workers pattern uses one central LLM to break a task into subtasks, assign each subtask to a worker LLM, and combine the results.</p><p>The difference from the earlier patterns is that the subtasks aren&#8217;t known in advance. Orchestrator figures them out as it goes. This is like a general contractor building a house:</p><ul><li><p>They hire the right people, but don&#8217;t know every subcontractor they&#8217;ll need upfront</p></li><li><p>Plumber finds a structural problem, so the contractor brings in a structural engineer</p></li><li><p>The work plan changes as the project reveals new problems</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!c9_Q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F042accd5-ff55-4030-acf1-e28ecfcb7f0f_2048x1143.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!c9_Q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F042accd5-ff55-4030-acf1-e28ecfcb7f0f_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!c9_Q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F042accd5-ff55-4030-acf1-e28ecfcb7f0f_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!c9_Q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F042accd5-ff55-4030-acf1-e28ecfcb7f0f_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!c9_Q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F042accd5-ff55-4030-acf1-e28ecfcb7f0f_2048x1143.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!c9_Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F042accd5-ff55-4030-acf1-e28ecfcb7f0f_2048x1143.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/042accd5-ff55-4030-acf1-e28ecfcb7f0f_2048x1143.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;:null,&quot;alt&quot;:&quot;Orchestrator-workers pattern showing a central LLM dynamically delegating to worker agents including unknown workers decided at runtime&quot;,&quot;title&quot;:&quot;Orchestrator-workers pattern showing a central LLM dynamically delegating to worker agents including unknown workers decided at runtime&quot;,&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="Orchestrator-workers pattern showing a central LLM dynamically delegating to worker agents including unknown workers decided at runtime" title="Orchestrator-workers pattern showing a central LLM dynamically delegating to worker agents including unknown workers decided at runtime" srcset="https://substackcdn.com/image/fetch/$s_!c9_Q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F042accd5-ff55-4030-acf1-e28ecfcb7f0f_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!c9_Q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F042accd5-ff55-4030-acf1-e28ecfcb7f0f_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!c9_Q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F042accd5-ff55-4030-acf1-e28ecfcb7f0f_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!c9_Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F042accd5-ff55-4030-acf1-e28ecfcb7f0f_2048x1143.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 role="img" 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><title></title><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 href="https://cursor.com/learn/agents">Cursor&#8217;s agent mode</a> works this way. It starts with different agents for different parts of the codebase:</p><ul><li><p>One adding tests</p></li><li><p>Another updating documentation</p></li><li><p>A third refactoring shared utilities</p></li></ul><p>You&#8217;re trusting the LLM to figure out what work needs to be done, not just to do the work you&#8217;ve assigned.</p><p>This uses several LLMs, but it&#8217;s NOT a multi-agent architecture: <em>a single central LLM remains in control of the entire process.</em> In multi-agent systems, agents can call each other directly without a central coordinator, and control can transfer between them.</p><h4><em><strong>Tradeoffs</strong></em></h4><p>The orchestrator can lose track of the original goal.</p><p>It breaks simple tasks into too many subtasks. And when workers finish faster than it can combine results, the orchestrator itself becomes the bottleneck.</p><div><hr></div><p>These four patterns get gradually more powerful and more expensive&#8230;</p><p>Chaining and routing are cheap and predictable: you know what will happen before it runs. Parallelization saves time but costs more. Orchestrator-workers handle problems you can&#8217;t predict upfront, but it introduces failure modes you can&#8217;t predict either. The first three patterns are simple to understand.</p><p>Most production systems shouldn&#8217;t need to go further than parallelization. When they do, the next four patterns hand control to the model itself...</p><div><hr></div><p><em><strong>Reminder: this is a teaser of the subscriber-only newsletter, exclusive to my golden members.</strong></em></p><p>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>High-level architecture of real-world systems.</strong></p></li><li><p>Deep dive into how popular real-world systems work.</p></li><li><p><strong>How real-world systems handle scale, reliability, and performance.</strong></p></li></ul><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe&quot;,&quot;text&quot;:&quot;Unlock Full Access&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe"><span>Unlock Full Access</span></a></p><div><hr></div><h2><strong>Agent patterns: LLM controls the flow</strong></h2><p>With agent patterns, you STOP defining what happens and in what order.</p><p>Instead of defining steps, you define constraints: <em>what tools are available, how much the model can spend, and when to stop</em>. The model observes, reasons, and chooses what happens next.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8Y67!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05738b84-f3c1-43d4-a706-6ed0ae52f5ef_2048x1143.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8Y67!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05738b84-f3c1-43d4-a706-6ed0ae52f5ef_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8Y67!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05738b84-f3c1-43d4-a706-6ed0ae52f5ef_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8Y67!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05738b84-f3c1-43d4-a706-6ed0ae52f5ef_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8Y67!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05738b84-f3c1-43d4-a706-6ed0ae52f5ef_2048x1143.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8Y67!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05738b84-f3c1-43d4-a706-6ed0ae52f5ef_2048x1143.jpeg" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/05738b84-f3c1-43d4-a706-6ed0ae52f5ef_2048x1143.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;:null,&quot;alt&quot;:&quot;Side-by-side comparison of workflow patterns where you define the fixed execution path versus agent patterns where the LLM controls the flow and you define the boundaries&quot;,&quot;title&quot;:&quot;Side-by-side comparison of workflow patterns where you define the fixed execution path versus agent patterns where the LLM controls the flow and you define the boundaries&quot;,&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="Side-by-side comparison of workflow patterns where you define the fixed execution path versus agent patterns where the LLM controls the flow and you define the boundaries" title="Side-by-side comparison of workflow patterns where you define the fixed execution path versus agent patterns where the LLM controls the flow and you define the boundaries" srcset="https://substackcdn.com/image/fetch/$s_!8Y67!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05738b84-f3c1-43d4-a706-6ed0ae52f5ef_2048x1143.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8Y67!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05738b84-f3c1-43d4-a706-6ed0ae52f5ef_2048x1143.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8Y67!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05738b84-f3c1-43d4-a706-6ed0ae52f5ef_2048x1143.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8Y67!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05738b84-f3c1-43d4-a706-6ed0ae52f5ef_2048x1143.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 role="img" 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><title></title><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>That trust decision appears differently in each pattern: <em>how much autonomy, over what actions, with what limits.</em></p><h3><strong>5. Reflection</strong></h3><p>Reflection is when the LLM generates output, reviews its own work, and then fixes the problems it found.</p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/agentic-design-patterns">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[I rejected 1000s of resumes at Meta]]></title><description><![CDATA[#139: This is what they got wrong]]></description><link>https://newsletter.systemdesign.one/p/software-engineer-resume</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/software-engineer-resume</guid><dc:creator><![CDATA[Austen McDonald]]></dc:creator><pubDate>Wed, 15 Apr 2026 07:40:44 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/2eedd062-dbeb-4728-8592-effb8923d220_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/software-engineer-resume/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>Most engineering resume advice you come across is junk.</p><p>At best, it comes from a tech recruiter who&#8217;s looked at 100s of resumes. At worst, it&#8217;s from yet another senior engineer cobbling together a blog post based on their experience applying to MAANGO.</p><p>This post is not like that.</p><p>I&#8217;ve made thousands of hiring and leveling decisions as mobile Hiring Committee Chair at Meta. I also led Meta&#8217;s engineering team responsible for finding and ingesting over 2M engineers&#8217; resumes into their internal <strong>ATS</strong> (Applicant Tracking System).</p><p>I&#8217;ve seen a lot of resumes :)</p><p>And because of that, I know that <strong>you should treat your resume like a product</strong>. Think of it as a landing page for your career, designed to drive each target user who touches it to take action. And yes, your resume has multiple target users&#8212;four, in fact&#8212;and you should learn what each one is looking for.</p><p>(Oh, and btw, a lot of this applies to your LinkedIn profile too, since that is literally a landing page.)</p><p>Onward.</p><div><hr></div><h2><strong><a href="https://cline.gg/neo">The tax you pay to run multiple agents (Partner)</a></strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://cline.gg/neo" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MX0h!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 424w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 848w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 1272w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MX0h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_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;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://cline.gg/neo&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!MX0h!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 424w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 848w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 1272w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_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 role="img" 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><title></title><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 you&#8217;ve spent any time with coding agents, you know the feeling.</p><p>You start the morning with a clean plan. Spin up a few agents. One is refactoring the auth module. Another is writing tests. A third is scaffolding a new API endpoint. You&#8217;re flying.</p><p>Then, around 10:30 AM, you look up and realize you have 20 terminal windows open. One agent is blocked waiting for a decision you forgot to make. Another finished 40 minutes ago, and you never noticed. A third went sideways three commits back. You&#8217;re no longer flying. You&#8217;re drowning.</p><p>You&#8217;ve shifted from human as driver to human as director.</p><p>When running coding agents in parallel, the bottleneck isn&#8217;t just context. It&#8217;s your own attention trying to manage 10 agents across 10 terminals. You&#8217;re losing your mind to terminal chaos.</p><p>Meet <strong><a href="https://cline.gg/neo">Cline Kanban</a></strong>, a CLI-agnostic visual orchestration layer that makes multi-agent workflows usable across providers. Multiple agents, one UI. It&#8217;s the air traffic controller for the agents you&#8217;re already running, regardless of where they live.</p><ul><li><p><strong>Interoperable: </strong>Claude Code and Codex compatible, with more coming soon.</p></li><li><p><strong>Full Visibility:</strong> Confidently run multiple agents and work through your backlog faster.</p></li><li><p><strong>Smart Triage:</strong> See which agents are blocked or in review and jump in to unblock them.</p></li><li><p><strong>Chain Tasks:</strong> Set dependencies so Agent B won&#8217;t start until Agent A is complete.</p></li><li><p><strong>Familiar UI:</strong> Everything in a single Kanban view.</p></li></ul><p>Stop tracking agents and start directing them. Get a meaningful edge with the beta release.</p><p><strong>Install Cline Kanban Today: </strong><code>npm i -g cline</code></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://cline.gg/neo&quot;,&quot;text&quot;:&quot;Get Started Today&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://cline.gg/neo"><span>Get Started Today</span></a></p><p>(Thanks to <a href="https://cline.gg/neo">Cline</a> for partnering on this post.)</p><div><hr></div><p>I want to introduce you to <strong><a href="https://thebehavioral.tech/">Austen McDonald</a></strong> as a guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://thebehavioral.tech/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ifOs!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd926164c-c3c5-4428-91a7-b237ed8cb6ad_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!ifOs!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd926164c-c3c5-4428-91a7-b237ed8cb6ad_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!ifOs!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd926164c-c3c5-4428-91a7-b237ed8cb6ad_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!ifOs!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd926164c-c3c5-4428-91a7-b237ed8cb6ad_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ifOs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd926164c-c3c5-4428-91a7-b237ed8cb6ad_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d926164c-c3c5-4428-91a7-b237ed8cb6ad_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;:324054,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://thebehavioral.tech/&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/193714466?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd926164c-c3c5-4428-91a7-b237ed8cb6ad_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ifOs!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd926164c-c3c5-4428-91a7-b237ed8cb6ad_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!ifOs!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd926164c-c3c5-4428-91a7-b237ed8cb6ad_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!ifOs!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd926164c-c3c5-4428-91a7-b237ed8cb6ad_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!ifOs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd926164c-c3c5-4428-91a7-b237ed8cb6ad_1200x630.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 role="img" 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><title></title><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>Austen is a former Senior Engineering Manager and Hiring Committee Chair at Meta, where he spent almost 10 years and conducted over 1,000+ interviews. He&#8217;s the industry&#8217;s resident expert on behavioral interviews and writes about them on his <strong><a href="https://thebehavioral.substack.com/welcome">Substack</a></strong> and in his book, <strong><a href="https://thebehavioral.tech/">Mastering Behavioral Interviews</a>.</strong> As AI raises the bar for ownership and independent judgment, behavioral interviews matter more than ever.</p><p>For a few days only, use code <em><strong>SDN26</strong></em> for <strong><a href="https://thebehavioral.tech/premium-access">20% off Premium Access</a></strong>, which includes a print copy of his book and an AI copilot that helps you find your best career stories, shape them into high-signal answers, and deliver them well.</p><div><hr></div><h1>Part 1: Your Resume is a Product</h1><p>Your resume is a landing page for your career search.</p><p>It&#8217;s the first thing these four personas see when they consider you for an engineering job:</p><ul><li><p>Machines (Applicant Tracking System),</p></li><li><p>Recruiters (we&#8217;ll include sourcers for all you sticklers),</p></li><li><p>Interviewers,</p></li><li><p>And Hiring Managers.</p></li></ul><p>Each of these personas looks progressively deeper into the content in the resume. Each one also extracts different, but overlapping, information.</p><p>Let&#8217;s consider the needs of each of these personas, what they look for in a resume, how they read it, and the decisions they make along the way&#8230;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CnMx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28d91b52-093c-43a0-b72f-48192d75887b_1600x683.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CnMx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28d91b52-093c-43a0-b72f-48192d75887b_1600x683.png 424w, https://substackcdn.com/image/fetch/$s_!CnMx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28d91b52-093c-43a0-b72f-48192d75887b_1600x683.png 848w, https://substackcdn.com/image/fetch/$s_!CnMx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28d91b52-093c-43a0-b72f-48192d75887b_1600x683.png 1272w, https://substackcdn.com/image/fetch/$s_!CnMx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28d91b52-093c-43a0-b72f-48192d75887b_1600x683.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CnMx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28d91b52-093c-43a0-b72f-48192d75887b_1600x683.png" width="1456" height="622" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/28d91b52-093c-43a0-b72f-48192d75887b_1600x683.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:622,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!CnMx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28d91b52-093c-43a0-b72f-48192d75887b_1600x683.png 424w, https://substackcdn.com/image/fetch/$s_!CnMx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28d91b52-093c-43a0-b72f-48192d75887b_1600x683.png 848w, https://substackcdn.com/image/fetch/$s_!CnMx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28d91b52-093c-43a0-b72f-48192d75887b_1600x683.png 1272w, https://substackcdn.com/image/fetch/$s_!CnMx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28d91b52-093c-43a0-b72f-48192d75887b_1600x683.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 role="img" 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><title></title><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>Machines (ATS)</h2><p>Unless your profile is handed directly to a recruiter, your hiring process starts with software. Whether you apply online, get referred, or turn up in a sourcer&#8217;s keyword search, you need to pass this automated filter first&#8230;</p><p><strong>How ATS systems work:</strong></p><p>When you submit a resume, the ATS parses it into structured data: <em>your name, contact info, work history, education, and skills.</em></p><p>It then scores you against the job description on keyword relevance, years of experience, and other recruiter-configured criteria. High-scoring candidates float to the top of the pile; low-scoring ones may never be seen by a human.</p><p>Of course, companies use AI-powered search that goes beyond keyword matching. These systems understand that &#8220;built ML pipelines&#8221; and &#8220;machine learning infrastructure&#8221; mean the same thing. This is good news&#8212;it means you don&#8217;t need to stuff your resume with every keyword&#8212;but it also means your accomplishments need to be substantively relevant to the role and described as such.</p><p><strong>What they need:</strong></p><ul><li><p>Clean, parseable formatting. Fancy designs can break text extraction: tables, some multi-column layouts, text boxes, icons, or images. Even creative section titles like &#8220;My Journey&#8221; instead of &#8220;Professional Experience&#8221; are risky.</p></li><li><p>Easy to find minimum qualifications since an automated tool is probably filtering first on whatever is stated in the job description.</p></li><li><p>Keywords matching the job posting and role requirements.</p></li><li><p>Technologies named where they can be easily indexed.</p></li></ul><p><strong>Hot Take:</strong> I have no data for this, but numerous companies have buttons on their career sites that say, &#8220;Upload your resume to see if you&#8217;re a fit.&#8221; Seems like it would be valuable to iterate on your resume until the site tells you you&#8217;re a good fit, lol.</p><h2>Recruiters</h2><p>Recruiters (or, more properly, sourcers) are speed readers scanning hundreds of resumes daily.</p><p>After basic machine filtering for experience, education, and past companies, they&#8217;ll skim your summary and a few accomplishment bullets, then make an in/out call in 5&#8211;7 seconds.</p><p>They&#8217;re looking for two things: candidates who meet the stated requirements, and candidates who fit the hiring manager&#8217;s mental model of a great hire. Those who clear both bars move forward to the next stage.</p><p>This is either a direct screening process, such as a phone call, or a final call to the hiring manager or committee before they begin screening process.</p><p><strong>What they need:</strong></p><ul><li><p>To immediately see that your profile fits the minimum requirements. They will reject you immediately if you don&#8217;t have the years of experience or the proper degrees, or have worked in similar roles (based mostly on title) that are identified in the job description.</p></li><li><p>A quick visual path to something that excites them about you and convinces them you fit the idea of what the hiring manager is looking for. This could be a name-brand company, a project relevant to the hiring team, or frequent use of technology related to the role. Give them a reason to take action and move you to the next step.</p></li><li><p>Brevity. Obviously, with 100s of these to review, the shorter the time all this takes, the better. So keep it to one page unless you&#8217;re a CEO.</p></li></ul><h2>Interviewers</h2><p>There are a couple of places where interviewers or members of the engineering team read your resume.</p><p>Sometimes there is a layer of reviewers who approve the resume before they green-light a technical screen. It could be the hiring manager or a committee of ICs. You can see them more as a technical version of a recruiter, as they have the same needs.</p><p>Technical screeners are a different type of reader. They&#8217;re looking for conversation starters and signals that you&#8217;d contribute to the team.</p><p>Onsite interviewers (especially behavioral interviewers) are gauging your level based on the business impact you&#8217;ve driven. They&#8217;re also looking for red flags, such as performance challenges: short stints at a workplace or career gaps.</p><p><strong>What they need:</strong></p><ul><li><p>Easy to find accomplishments that look like they fit with the work of the company/team</p></li><li><p>Evidence you can defend your claims under scrutiny: those accomplishments need technical details</p></li><li><p>Signals of technical depth and leadership</p></li><li><p>A minimum of reasons to be suspicious</p></li></ul><h2>Hiring Managers</h2><p>Hiring managers are sometimes the first, as we talked about above in &#8220;Interviewers,&#8221; but almost always the last person to touch your resume.</p><p>At this stage, they&#8217;re reviewing a handful of finalists, which makes them the most thorough readers of your resume. They know what their team needs and look for specific evidence of alignment with those needs.</p><p><strong>What they need:</strong></p><ul><li><p>Evidence that your past work resembles what they&#8217;re hiring for</p></li><li><p>Measurable impact with appropriate scope</p></li><li><p>They want ownership and growth signals: can you self-direct, drive work to completion, and adapt fast, i.e., you&#8217;re ready for agentic coding.</p></li><li><p>Clear visual hierarchy so they can find what matters</p></li></ul><p>Now that you know who&#8217;s reading your resume and what they&#8217;re scanning for, there&#8217;s a natural question: <em>what do you actually put on the page?</em></p><p>The answer isn&#8217;t &#8220;everything you&#8217;ve ever done.&#8221; Instead, curate a story of the impact you&#8217;ve made in your career. The next part walks you through that step by step...</p><div class="captioned-button-wrap" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/software-engineer-resume?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="CaptionedButtonToDOM"><div class="preamble"><p class="cta-caption"><em>Share this post &amp; get rewards for the referrals.</em></p></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/software-engineer-resume?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/software-engineer-resume?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p></div><div><hr></div><h1>Part 2: Resume Content that Converts</h1><p>Now that we understand the users of your resume, let&#8217;s build a product that converts, moving you through the recruiting pipeline to a hire!</p><h2>The Basics: What Goes In and What Stays Out of Your Resume</h2><p>Before diving into content, we should get the basics out of the way.</p><p>Here&#8217;s the standard structure that readers expect, roughly in this order:</p><ol><li><p><strong>Contact Information</strong> &#8211; name, email, LinkedIn (maybe GitHub, if it&#8217;s good; more on that later)</p></li><li><p><strong>Summary</strong> &#8211; Who you are and why you&#8217;re right for the role in 2-3 sentences</p></li><li><p><strong>Work Experience</strong> &#8211; Your professional history with accomplishments</p></li><li><p><strong>Education</strong> &#8211; Degrees, relevant coursework, honors</p></li><li><p><strong>Projects</strong> &#8211; Side projects, open source, portfolio work</p></li><li><p><strong>Skills</strong> &#8211; The keyword soup for machines, as we&#8217;ll see</p></li></ol><p>This order should vary depending on who you are: experienced candidates can de-emphasize education; new grads should surface projects higher.</p><p>But readers expect to find things in roughly this order, so don&#8217;t make them hunt.</p><h2>Contact Information</h2><p>Of course, you should include basics like name and email.</p><p>If you want a phone call, include your phone number. Recruiters will ask for it later if you don&#8217;t give it now.</p><p>I also believe you should include a LinkedIn URL, linkified in the PDF form of the resume. Companies expect engineers to have LinkedIn profiles and may ingest that profile data automatically (don&#8217;t tell the LinkedIn lawyers). Much of the advice I give in this newsletter applies to LinkedIn profiles as well, especially the summary and bullet-point writing.</p><p>And please get a decent profile photo and cover photo for your LinkedIn profile.</p><p>Anything else you put in this contact information section should be additive to your candidacy. Like, don&#8217;t include a GitHub or personal website link if that&#8217;s there, it&#8217;s unimpressive. GitHub profiles need at least some recruiting-friendly repos that are deployed somewhere and well-documented. Personal websites should work (lol) and be a high-quality representation of yourself. Otherwise, don&#8217;t include them.</p><p>If you&#8217;re a US citizen applying to US roles and your citizenship isn&#8217;t obvious from your resume, note it in your contact section.</p><h2>Write a Summary</h2><p>Most resume advice is subjective.</p><p>Here&#8217;s my most opinionated take in this newsletter: <em>always include a summary and put it at the top.</em></p><p>Two or three sentences max. And tailor it to the role. After reading it, I should immediately come away with the idea that you&#8217;d be a good fit for the role. Again, recruiters will heavily depend on this summary to help them decide.</p><p><strong>&#9888;&#65039; Warning: Don&#8217;t let AI write your summary.</strong> AI-generated summaries are an epidemic. They all sound the same&#8212;vague, buzzword-laden, and interchangeable. Recruiters and hiring managers can spot them instantly, and they leave readers with zero understanding of who you actually are.</p><p>These all say nothing:</p><blockquote><p><em>Results-driven Front End Engineer with 4+ years of experience building scalable, user-centric web applications. Proven track record of delivering high-quality code in fast-paced environments. Passionate about creating seamless user experiences and collaborating with cross-functional teams.</em></p><p><em>Dynamic and detail-oriented Front End Engineer with expertise in modern JavaScript frameworks. Adept at translating complex requirements into elegant, performant solutions. Strong communicator with a passion for continuous learning and staying current with industry trends.</em></p><p><em>Innovative Front End Engineer bringing 4 years of hands-on experience crafting responsive, accessible interfaces. Committed to writing clean, maintainable code and driving technical excellence. Thrives in collaborative environments and passionate about mentoring junior developers.</em></p></blockquote><p>My mind just numbs over reading these.</p><p>Phrases like &#8220;results-driven,&#8221; &#8220;passionate,&#8221; and &#8220;cross-functional teams&#8221; are filler. They fit any candidate, which means they describe none of them.</p><ul><li><p>What kind of products have you built? (B2B dashboards? Consumer apps? E-commerce?)</p></li><li><p>What&#8217;s your technical specialty? (Performance optimization? Design systems? Accessibility?)</p></li><li><p>What makes you different from the other 500 front-end engineers applying?</p></li></ul><h3>A Better Summary</h3><p>Let&#8217;s build something better, remembering to tailor the summary to the role.</p><p>Suppose you were applying to some B2B SaaS company as this same front-end engineer who&#8217;s looking to replace their AI-built summary.</p><p>What about this one, that I typed with my own meat sticks:</p><blockquote><p><em>I make complex data feel simple. I&#8217;m a front-end engineer with 4 years experience building B2B decision platforms at multiple fast-moving startups.</em></p></blockquote><p>First, it&#8217;s shorter, and therefore more likely to be read.</p><p>My technical writing instructor in college told me, &#8220;Every line decreases your readership by half.&#8221; I don&#8217;t know if that&#8217;s true, but it&#8217;s a good principle to live by.</p><p>Next, it&#8217;s interesting and attractive. Who doesn&#8217;t want someone who makes complex data feel simple?</p><p>It also immediately communicates who you are: a front-end engineer with 4 years of experience at startups. Now I know whether your profile is relevant to me or not.</p><p>Finally, it connects to the role.</p><p><strong>Note:</strong> Let&#8217;s talk about the &#8220;cute summary&#8221;. I actually prefer something like &#8220;Assistant to my local Claude Code instance&#8221; over a buzzwordy AI summary. At least it communicates some creativity and humanity. But I think you can do better and should do better unless it&#8217;s really obvious your resume matches the target role&#8212;like you&#8217;re applying for a senior ML safety engineering role at Big Tech X and just came from Big Tech Y with the same title.</p><h2>Writing Bullets That Get Read</h2><p>Resume readers are hiring you to deliver business value using technology.</p><p>That&#8217;s why they need an engineer. So give them confidence that you can do that with the bullets you list under your experience.</p><p>Here&#8217;s how you can do this:</p><ul><li><p><strong>Lead with results, not activities.</strong> Start with what happened, not what you did. The activity is the supporting detail. Use a formula like: &#8220;Delivered [business value] using [technology/approach].&#8221;</p></li><li><p><strong>Quantify and show scope.</strong> Percentages, dollar amounts, user counts, latency improvements, and length of the project. Let the numbers imply how hard the work was.</p></li><li><p><strong>Your bullets become interview topics.</strong> The accomplishments you list will get asked about. Make them interesting enough to discuss and defensible under scrutiny.</p></li><li><p><strong>Include leadership signals.</strong> Highlight moments where you took initiative, managed others, or drove a project forward&#8212;even if you weren&#8217;t a manager.</p></li><li><p><strong>Lead with your best.</strong> Don&#8217;t sort accomplishments chronologically within a role. Place the most relevant and impactful ones first in each section.</p></li><li><p><strong>Embed tech in your accomplishments.</strong> Mentioning technologies within achievement bullets improves your ranking for those keywords, not just in a separate skills section.</p></li></ul><p>Here are some examples of weak vs strong bullets:</p><blockquote><p><strong>Weak:</strong> <em>Worked on the checkout system and fixed bugs.</em></p><p><strong>Strong:</strong> <em>Reduced checkout abandonment by 12% by identifying and resolving a race condition in the payment flow using React and Stripe&#8217;s API.</em></p><p><strong>Weak:</strong> <em>Responsible for migrating the database to a new system.</em></p><p><strong>Strong:</strong> <em>Led a 6-month migration of 50M records from MySQL to PostgreSQL, coordinating across 3 teams and achieving zero downtime during cutover.</em></p><p><strong>Weak:</strong><em> Helped improve the CI/CD pipeline.</em></p><p><strong>Strong:</strong><em> Cut deploy times from 45 minutes to 8 minutes by parallelizing test suites and implementing Docker layer caching, adopted by 12 engineering teams.</em></p><p><strong>Weak:</strong><em> Mentored junior engineers on the team.</em></p><p><strong>Strong:</strong><em> Mentored 3 junior engineers through their first production launches, with one promoted to mid-level within 8 months.</em></p></blockquote><h2>Projects &amp; Proof of Work</h2><p>I don&#8217;t think projects or other non-paid work are super valuable on a resume, unless you are in one of two positions:</p><ul><li><p>You&#8217;re a new grad with little paid experience, and projects are actually what you&#8217;ve done most of in your life,</p></li><li><p>Or you&#8217;re trying to land a role in a new technical area where you haven&#8217;t technically worked (*cough* AI).</p></li></ul><p>Outside of those two cases, projects are marginal. They might tip the scales if a recruiter is on the fence, but they rarely move the needle on their own.</p><p>Generally, though, prioritize contributions from paid work and don&#8217;t spend too much vertical space on projects.</p><p><strong>GitHub </strong><em><strong>can</strong></em><strong> be useful.</strong> If your GitHub profile has a lot of green squares and/or a few polished repos <em>deployed</em>&nbsp;somewhere, with good READMEs, tests, and documentation, then great. Be sure to pin repos that showcase your best work. But if your contribution chart doesn&#8217;t look like a Christmas tree and/or you don&#8217;t have meaningful projects, just leave it off.</p><p><strong>Side projects have some value.</strong> I don&#8217;t think side projects do a ton for you, since working by yourself with no expectation of production-level code is just a different environment than a real job. But they do show initiative and genuine interest. Skip the generic description (&#8221;AI-powered todo app in React Native&#8221;). Write something that shows personality: &#8220;Maximalist AI approach to running my life &#8212; a case study in build-fast-with-Claude-Code development.&#8221;</p><p><strong>Technical blogs or writing are worth considering.</strong> Publishing shows communication skills and depth of understanding. If you provide anything, make sure it&#8217;s easy for me to find the 2-3 best pieces.</p><h2>The Skills Section</h2><p>If there&#8217;s one part of the resume that&#8217;s most often overlooked by readers, it&#8217;s the skills section. Even though that&#8217;s true, it still serves a purpose.</p><p><strong>Include a skill soup section.</strong> A ranked list of technologies ensures you show up in keyword searches and reassures recruiters when hiring managers say, &#8220;They must know React.&#8221;</p><p><strong>Keep it limited to what you actually know.</strong> Don&#8217;t list everything you&#8217;ve ever touched&#8212;only what&#8217;s relevant and what you can actually discuss. Some interviewers will probe for depth if you include an unholy number of skills. Also, I feel like I should charge you for my AI tokens if you include things like &#8220;HTML.&#8221;</p><h2>Tailoring Your Resume Per Job</h2><p>Honestly, most people don&#8217;t tailor their resume to roles because it&#8217;s just too much work. That&#8217;s probably true, especially if you&#8217;re applying to dozens of jobs.</p><p>Rather than tailoring per job, tailor for big-name companies, which are worth the extra effort, and keep a small set of versions for <strong>different role types</strong>. Perhaps you have one focused on your front-end work for tech-heavy senior IC roles, and another on your leadership skills for tech lead roles. Maybe one that highlights your AI personal projects and one that focuses on your full-time data engineering experience.</p><p>If you&#8217;re going to tailor, you need to know what to tailor <em>to</em>. Leverage the job description for this:</p><ol><li><p><strong>Look for repeated terms.</strong> If &#8220;distributed systems&#8221; appears three times, it matters more than &#8220;familiarity with GraphQL,&#8221; which only appears once.</p></li><li><p><strong>Separate requirements from wish list.</strong> Most job postings have a &#8220;must have&#8221; and &#8220;nice to have&#8221; section&#8212;or they bury the real requirements in the first few bullets and pad the rest. Focus your tailoring energy on what appears at the top.</p></li><li><p><strong>Identify the core problem they&#8217;re hiring for.</strong> &#8220;Looking for someone to own our data pipeline&#8221; means they want reliability and ownership signals. &#8220;Help us scale to 10x users&#8221; means they want performance and system design experience. Mirror this kind of language back to them.</p></li><li><p><strong>Note specific technologies vs general skills vs filler.</strong> &#8220;Experience with Kafka&#8221; is a keyword you either have or don&#8217;t. &#8220;Experience leading teams&#8221; means they&#8217;re looking for some kind of people leadership and cross-functional signals. &#8220;Strong communication skills&#8221; is a filler that every job post includes. Don&#8217;t waste resume space on filler.</p></li></ol><p><em>A quick trick: </em>paste the job description into an LLM and ask, &#8220;What are the top 10 concepts in this job description and what are they looking for in this candidate?&#8221; Upload your resume and ask it to compare.</p><p>Now that you&#8217;ve identified what to focus on, here are some specific tactics to apply:</p><ul><li><p><strong>Adjust your summary.</strong> Emphasize the aspects of your experience that align with the needs of that role or company that we just discussed, identifying.</p></li><li><p><strong>Reorder the sections.</strong> We&#8217;ll talk more about formatting below, but if you&#8217;re applying to AI roles but don&#8217;t have AI experience other than personal projects, leaving those projects at the bottom is a sure way to get ignored. Lift them up, even above the professional experience section if needed.</p></li><li><p><strong>Reorder your bullets.</strong> Lead with accomplishments most relevant to the target role.</p></li><li><p><strong>Expand or condense roles.</strong> Similar to reordering bullets, you can expand or condense on certain past roles that are most relevant, or even completely remove some experience if you think it&#8217;s distracting.</p></li><li><p><strong>Match the skills.</strong> If different skills are needed, then include those or reorder them to the front of the skills listing.</p></li></ul><p>Now you have the raw materials: a summary, impact-driven bullets, and content tailored to your target roles. But even the best content fails if it&#8217;s buried in a cluttered design.</p><p>The next section is about making your resume visually effortless for each type of reader&#8230;</p><div class="captioned-button-wrap" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/software-engineer-resume?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="CaptionedButtonToDOM"><div class="preamble"><p class="cta-caption"><em>Share this post &amp; get rewards for the referrals.</em></p></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/software-engineer-resume?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/software-engineer-resume?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p></div><div><hr></div><h1>Part 3: Designing a Resume for Ease of Use</h1><p>Your resume doesn&#8217;t have to be pretty, but it needs to fulfill the visual needs of the four readers. Aim for a simple, easy-to-use formatting:</p><ul><li><p>Most important stuff at the top: top of the page and the top of each new section</p></li><li><p>Optimize for a clear visual flow, top to bottom</p></li><li><p>Draw the reader&#8217;s eye to the most important parts with text size and weight. Be careful with color.</p></li><li><p>Make it easy for machines to read</p></li></ul><h2>Formatting for Both Machines and Humans</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-lAH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb8c5c1f-f5c6-43e4-851d-02d9259d7e6c_1600x1013.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-lAH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb8c5c1f-f5c6-43e4-851d-02d9259d7e6c_1600x1013.png 424w, https://substackcdn.com/image/fetch/$s_!-lAH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb8c5c1f-f5c6-43e4-851d-02d9259d7e6c_1600x1013.png 848w, https://substackcdn.com/image/fetch/$s_!-lAH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb8c5c1f-f5c6-43e4-851d-02d9259d7e6c_1600x1013.png 1272w, https://substackcdn.com/image/fetch/$s_!-lAH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb8c5c1f-f5c6-43e4-851d-02d9259d7e6c_1600x1013.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-lAH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb8c5c1f-f5c6-43e4-851d-02d9259d7e6c_1600x1013.png" width="1456" height="922" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fb8c5c1f-f5c6-43e4-851d-02d9259d7e6c_1600x1013.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:922,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!-lAH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb8c5c1f-f5c6-43e4-851d-02d9259d7e6c_1600x1013.png 424w, https://substackcdn.com/image/fetch/$s_!-lAH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb8c5c1f-f5c6-43e4-851d-02d9259d7e6c_1600x1013.png 848w, https://substackcdn.com/image/fetch/$s_!-lAH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb8c5c1f-f5c6-43e4-851d-02d9259d7e6c_1600x1013.png 1272w, https://substackcdn.com/image/fetch/$s_!-lAH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb8c5c1f-f5c6-43e4-851d-02d9259d7e6c_1600x1013.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 role="img" 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><title></title><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>Use simple formatting.</strong> Avoid overly creative designs. Distribute it as a PDF that exports cleanly to text. You can test this by uploading to Google Docs&#8212;if formatting breaks, the ATS may misread it too.</p><p><strong>Keep it to one page.</strong> Admittedly, part of this is convention, but having everything on one page makes it easy for your readers to review. It&#8217;s like having the key elements &#8220;above the fold&#8221; on a product page. Here are some space-saving tips:</p><ul><li><p>Adjust margins, even all the way down to 1/2&#8221; on every side.</p></li><li><p>Think about what you can fit on one line, such as the company name, title, years.</p></li><li><p>Older or shorter experiences can sometimes be summarized in one line instead of a series of bullets. The farther the experience is down your resume, the less likely a reader is to actually read it, so feel free to reduce fidelity for those roles.</p></li><li><p>Consider a two-column format, with the lesser-read parts like contact information, skills, and education in a smaller, side column.</p></li></ul><p><strong>Use formatting to guide the eye.</strong> Sub-bullets, bolding, and visual hierarchy. If every bullet looks equally weighted, eyes glaze over.</p><p><strong>Don&#8217;t overthink templates.</strong> You&#8217;re not going to get hired because of your amazing resume template. Don&#8217;t spend too much energy on this. Find something that matches the principles here and then put your energy into the content.</p><h2>Suggested Templates</h2><p>I almost didn&#8217;t include templates at all, since there are so many good ones and the final formatting choices don&#8217;t matter that much. But how can this newsletter about resumes be complete without a couple of resume templates?</p><p>Here are a couple of templates that follow our guidelines: a&nbsp;<a href="https://docs.google.com/document/d/1xlTpcmIBIaVyNZhYWJ0CqlcwUNSOW_g-bsFq9OxQ-L4/edit?usp=sharing">single-column</a>&nbsp;example and a&nbsp;<a href="https://docs.google.com/document/d/1sDY1-c2bTplkO5eJpgr-reqBC4mffTEesOVJ-95dcM8/edit?usp=sharing">two-column</a>&nbsp;example. Notice how much more vertical space you save with the two-column format.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qguF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec143f2f-1813-4655-8304-dbc71420c6c9_1120x1450.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qguF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec143f2f-1813-4655-8304-dbc71420c6c9_1120x1450.png 424w, https://substackcdn.com/image/fetch/$s_!qguF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec143f2f-1813-4655-8304-dbc71420c6c9_1120x1450.png 848w, https://substackcdn.com/image/fetch/$s_!qguF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec143f2f-1813-4655-8304-dbc71420c6c9_1120x1450.png 1272w, https://substackcdn.com/image/fetch/$s_!qguF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec143f2f-1813-4655-8304-dbc71420c6c9_1120x1450.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qguF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec143f2f-1813-4655-8304-dbc71420c6c9_1120x1450.png" width="1120" height="1450" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ec143f2f-1813-4655-8304-dbc71420c6c9_1120x1450.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1450,&quot;width&quot;:1120,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!qguF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec143f2f-1813-4655-8304-dbc71420c6c9_1120x1450.png 424w, https://substackcdn.com/image/fetch/$s_!qguF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec143f2f-1813-4655-8304-dbc71420c6c9_1120x1450.png 848w, https://substackcdn.com/image/fetch/$s_!qguF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec143f2f-1813-4655-8304-dbc71420c6c9_1120x1450.png 1272w, https://substackcdn.com/image/fetch/$s_!qguF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec143f2f-1813-4655-8304-dbc71420c6c9_1120x1450.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 role="img" 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><title></title><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><figcaption class="image-caption">Single Column Template</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qy0C!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60c169ca-3a45-4843-a3f7-a461e972e1d1_1122x1450.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qy0C!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60c169ca-3a45-4843-a3f7-a461e972e1d1_1122x1450.png 424w, https://substackcdn.com/image/fetch/$s_!qy0C!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60c169ca-3a45-4843-a3f7-a461e972e1d1_1122x1450.png 848w, https://substackcdn.com/image/fetch/$s_!qy0C!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60c169ca-3a45-4843-a3f7-a461e972e1d1_1122x1450.png 1272w, https://substackcdn.com/image/fetch/$s_!qy0C!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60c169ca-3a45-4843-a3f7-a461e972e1d1_1122x1450.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qy0C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60c169ca-3a45-4843-a3f7-a461e972e1d1_1122x1450.png" width="1122" height="1450" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/60c169ca-3a45-4843-a3f7-a461e972e1d1_1122x1450.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1450,&quot;width&quot;:1122,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!qy0C!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60c169ca-3a45-4843-a3f7-a461e972e1d1_1122x1450.png 424w, https://substackcdn.com/image/fetch/$s_!qy0C!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60c169ca-3a45-4843-a3f7-a461e972e1d1_1122x1450.png 848w, https://substackcdn.com/image/fetch/$s_!qy0C!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60c169ca-3a45-4843-a3f7-a461e972e1d1_1122x1450.png 1272w, https://substackcdn.com/image/fetch/$s_!qy0C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60c169ca-3a45-4843-a3f7-a461e972e1d1_1122x1450.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 role="img" 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><title></title><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><figcaption class="image-caption">Two-Column Template</figcaption></figure></div><h2>Making Your Experience Scannable</h2><p><strong>Make recognizable names visible.</strong> Make sure the eye jumps directly to household-name companies and high-impact projects. Recruiters notice brand recognition quickly, and readers only read the first part of each section.</p><p><strong>Surface minimum qualifications.</strong> Many companies require recruiters to verify basic criteria, such as education or years of experience. Make this information prominent, as in the summary.</p><p><strong>Prioritize your recent or flagship experience.</strong> Give more visual weight and spend more vertical space on the recent experience. Similarly, for experience at a name-brand company. Both of these will be the most-read content by reviewers. To accomplish this, compress older experience by removing bullets or shortening them.</p><p><strong>Handling sticky situations: gaps and layoffs.</strong> Minimize these if you can. You don&#8217;t want to get screened out b/c of these before you can talk to someone:</p><ul><li><p>Remove the month indicators on roles that hide an intra-year gap.</p></li><li><p>If you were recently let go, don&#8217;t update the current role with an end date yet. You can probably get away with this for 6-12 months since people expect resumes to be somewhat out of date.</p></li><li><p>If you have recent stints at startups that folded after a year, add a brief one-liner explaining what happened. Otherwise, reviewers may assume it reflects on you.</p></li></ul><p>At this point, you know what to write and how to format it.</p><p>But there are a lot of common mistakes I see in resumes. The good news is they&#8217;re fixable in five minutes.</p><div><hr></div><h1>Part 4: Common Mistakes &amp; What to Avoid</h1><p>Writing resumes can be tricky, so let&#8217;s consider some common advice I give coaching clients when we&#8217;re talking about resumes&#8230;</p><h2>Common Resume Mistakes</h2><p><strong>Too many buzzwords.</strong> &#8220;Results-driven,&#8221; &#8220;synergy,&#8221; &#8220;leverage&#8221; all mean nothing really. If you can swap your bullet with any other candidate&#8217;s and it still makes sense, it&#8217;s too generic.</p><p><strong>Zero impact.</strong> Describing activities without outcomes. &#8220;Worked on the payments team&#8221; tells me nothing. What shipped? What changed because you were there?</p><p><strong>Hard-to-read templates.</strong> Fancy designs with unusual typefaces, lots of white space, etc., that prioritize aesthetics over scannability are pretty risky unless you&#8217;re applying to a design-heavy role. A reader should be able to make a decision about your resume in about 3 seconds.</p><p><strong>Irrelevant information.</strong> Remove that summer lifeguarding job from 2015 when you&#8217;re a senior engineer in 2026. Every line that doesn&#8217;t serve the reader is a line they might stop reading at.</p><p><strong>Wall of text.</strong> If I can&#8217;t immediately see where the key information is and there&#8216;s no hierarchy, no bolding, and no visual breaks, then I just get overwhelmed and close your profile.</p><h2>What NOT to Include</h2><p><strong>Unnecessary personal info.</strong> Age, photo (in the US), full address. These create opportunities for bias and waste space.</p><p><strong>Irrelevant jobs.</strong> Unless they demonstrate transferable skills or fill a gap, cut them. Nobody hiring a backend engineer cares about your retail experience from a decade ago.</p><p><strong>Social media links.</strong> Exception: LinkedIn. Your Twitter, Instagram, or TikTok is irrelevant noise unless you&#8217;re applying to a social media company and they showcase relevant work.</p><p><strong>References available upon request.</strong> Everyone assumes this. It&#8217;s a filler.</p><p><strong>Hobbies and interests.</strong> Unless directly relevant (you&#8217;re applying to a gaming company and list game development as a hobby), these just take up space.</p><p><strong>ATS tricks.</strong> Don&#8217;t try things like packing your resume with white text to rock the ATS layer. Recruiters and engineers who write ATS systems know about these tricks and despise them.</p><div class="captioned-button-wrap" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/software-engineer-resume?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="CaptionedButtonToDOM"><div class="preamble"><p class="cta-caption"><em>Share this post &amp; get rewards for the referrals.</em></p></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/software-engineer-resume?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/software-engineer-resume?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p></div><div><hr></div><h1>Closing Thoughts</h1><p>Your resume is never done.</p><p>That might sound exhausting, but it&#8217;s actually liberating. You don&#8217;t need to craft the perfect resume before you start applying. You need a <em>good enough</em> resume that you improve over time.</p><p><strong>Treat your resume like a product.</strong> We started this newsletter with that idea, and it&#8217;s worth restating here. Products ship, get feedback, and iterate; your resume should too. If an interviewer or recruiter asks you about something on your resume, consider adding it. Did you bomb a question about an accomplishment you listed? Either cut it or prepare better.</p><p><strong>Get human feedback early and often.</strong> Have friends, mentors, or peers review your resume. If you can, get feedback from someone who&#8217;s actually hired engineers.</p><p><strong>Iterate ruthlessly.</strong> When I&#8217;ve worked with coaching clients on their resumes, it usually takes 3-4 revisions before it&#8217;s good.</p><p><strong>The takeaway:</strong> Your resume has four readers&#8212;machines, recruiters, interviewers, and hiring managers&#8212;and each one needs something different. Build for all of them. Make it easy to scan, with the information each persona needs. Quantify your impact. Make it scannable. And then iterate.</p><p>Now go get that interview.</p><div><hr></div><p>&#128075; I&#8217;d like to thank <strong><a href="https://thebehavioral.tech/">Austen</a></strong> for writing this newsletter!</p><p>Also, subscribe to his free newsletter,&nbsp;<strong><a href="https://thebehavioral.substack.com/welcome">Mastering Behavioral Interviews</a></strong><a href="https://thebehavioral.substack.com/">,</a>&nbsp;and check out his&nbsp;<strong><a href="https://thebehavioral.tech/">book by the same name</a></strong>.</p><p>It will help you prepare for the interview round you&#8217;re underinvesting in, the one that separates Senior engineers from Staff and above. He&#8217;s got a lot of practical advice similar to what he shared in this post.</p><p>Remember, you can claim <strong><a href="https://thebehavioral.tech/premium-access">20% off Premium Access</a></strong> to his interview prep content with code <em><strong>SDN26</strong></em>, but only for a few days!</p><div><hr></div><p>If you find this newsletter valuable, share it with a friend, and subscribe if you haven&#8217;t already. There are <a href="http://newsletter.systemdesign.one/subscribe?group=true">group discounts</a>, <a href="http://newsletter.systemdesign.one/subscribe?gift=true">gift options</a>, and <a href="https://newsletter.systemdesign.one/leaderboard">referral rewards</a> available.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://www.linkedin.com/in/nk-systemdesign-one/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png" width="152" height="152" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:320,&quot;width&quot;:320,&quot;resizeWidth&quot;:152,&quot;bytes&quot;:74009,&quot;alt&quot;:&quot;Author Neo Kim; System design case studies&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://www.linkedin.com/in/nk-systemdesign-one/&quot;,&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="Author Neo Kim; System design case studies" title="Author Neo Kim; System design case studies" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption"><strong>&#128075; Find me on <a href="https://www.linkedin.com/in/nk-systemdesign-one/">LinkedIn</a> | <a href="https://x.com/intent/follow?screen_name=systemdesignone">Twitter</a> | <a href="https://www.threads.net/@systemdesignone">Threads</a> | <a href="https://www.instagram.com/systemdesignone/">Instagram</a></strong></figcaption></figure></div><div><hr></div><p><strong>Want to reach 200K+ tech professionals at scale? </strong>&#128240;</p><p>If your company wants to reach 200K+ tech professionals, <a href="https://newsletter.systemdesign.one/p/sponsorship">advertise with me</a>.</p><div><hr></div><p>Thank you for supporting this newsletter.</p><p>You are now 210,001+ readers strong, very close to 210k. Let&#8217;s try to get 211k readers by 17 April. Consider sharing this post with your friends and get rewards.</p><p>Y&#8217;all are the best.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6oWl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" width="590" height="368.75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:800,&quot;resizeWidth&quot;:590,&quot;bytes&quot;:87878,&quot;alt&quot;:&quot;system design newsletter&quot;,&quot;title&quot;:&quot;system design newsletter&quot;,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/163380418?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="system design newsletter" title="system design newsletter" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.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 role="img" 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><title></title><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 class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/software-engineer-resume?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/software-engineer-resume?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[11 AI Concepts Explained, Simply]]></title><description><![CDATA[#138: Break into AI Engineering]]></description><link>https://newsletter.systemdesign.one/p/ai-concepts</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/ai-concepts</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Thu, 09 Apr 2026 09:54:36 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/f266f60d-51aa-416b-b477-90b1dc4c2299_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/ai-concepts/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>I&#8217;ve built agents at Google to support their machine learning operations.</p><p>Then one thing became super clear to me: <em>AI engineering is good software engineering with an understanding of a few key AI principles.</em></p><p>Just a year ago, hardly any software engineers were building with AI.</p><p>Now, engineers are expected to understand AI engineering and integrate AI into their products. This newsletter is a primer to bridge the gap from software to AI engineering.</p><p>Onward.</p><div><hr></div><h2><a href="https://cline.gg/neo">The tax you pay to run multiple agents (Partner)</a></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://cline.gg/neo" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MX0h!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 424w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 848w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 1272w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MX0h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_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;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://cline.gg/neo&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!MX0h!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 424w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 848w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_1600x900.png 1272w, https://substackcdn.com/image/fetch/$s_!MX0h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e0ba733-c96e-461d-92e4-e2bd8c2cb2a5_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 role="img" 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><title></title><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 you&#8217;ve spent any time with coding agents, you know the feeling.</p><p>You start the morning with a clean plan. Spin up a few agents. One is refactoring the auth module. Another is writing tests. A third is scaffolding a new API endpoint. You&#8217;re flying.</p><p>Then, around 10:30 AM, you look up and realize you have 20 terminal windows open. One agent is blocked waiting for a decision you forgot to make. Another finished 40 minutes ago, and you never noticed. A third went sideways three commits back. You&#8217;re no longer flying. You&#8217;re drowning.</p><p>You&#8217;ve shifted from human as driver to human as director.</p><p>When running coding agents in parallel, the bottleneck isn&#8217;t just context. It&#8217;s your own attention trying to manage 10 agents across 10 terminals. You&#8217;re losing your mind to terminal chaos.</p><p>Meet <strong><a href="https://cline.gg/neo">Cline Kanban</a></strong>, a CLI-agnostic visual orchestration layer that makes multi-agent workflows usable across providers. Multiple agents, one UI. It&#8217;s the air traffic controller for the agents you&#8217;re already running, regardless of where they live.</p><ul><li><p><strong>Interoperable: </strong>Claude Code and Codex compatible, with more coming soon.</p></li><li><p><strong>Full Visibility:</strong> Confidently run multiple agents and work through your backlog faster.</p></li><li><p><strong>Smart Triage:</strong> See which agents are blocked or in review and jump in to unblock them.</p></li><li><p><strong>Chain Tasks:</strong> Set dependencies so Agent B won&#8217;t start until Agent A is complete.</p></li><li><p><strong>Familiar UI:</strong> Everything in a single Kanban view.</p></li></ul><p>Stop tracking agents and start directing them. Get a meaningful edge with the beta release.</p><p><strong>Install Cline Kanban Today: </strong><code>npm i -g cline</code></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://cline.gg/neo&quot;,&quot;text&quot;:&quot;Get Started Today&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://cline.gg/neo"><span>Get Started Today</span></a></p><p>(Thanks to <a href="https://cline.gg/neo">Cline</a> for partnering on this post.)</p><div><hr></div><p>I want to introduce <strong><a href="http://aiforswes.com/subscribe">Logan Thorneloe</a></strong> as the guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="http://aiforswes.com/subscribe" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Zf30!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ee68530-d50b-4df7-9548-6d342b4361b2_1310x816.png 424w, https://substackcdn.com/image/fetch/$s_!Zf30!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ee68530-d50b-4df7-9548-6d342b4361b2_1310x816.png 848w, https://substackcdn.com/image/fetch/$s_!Zf30!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ee68530-d50b-4df7-9548-6d342b4361b2_1310x816.png 1272w, https://substackcdn.com/image/fetch/$s_!Zf30!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ee68530-d50b-4df7-9548-6d342b4361b2_1310x816.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Zf30!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ee68530-d50b-4df7-9548-6d342b4361b2_1310x816.png" width="1310" height="816" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6ee68530-d50b-4df7-9548-6d342b4361b2_1310x816.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:816,&quot;width&quot;:1310,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;http://aiforswes.com/subscribe&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!Zf30!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ee68530-d50b-4df7-9548-6d342b4361b2_1310x816.png 424w, https://substackcdn.com/image/fetch/$s_!Zf30!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ee68530-d50b-4df7-9548-6d342b4361b2_1310x816.png 848w, https://substackcdn.com/image/fetch/$s_!Zf30!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ee68530-d50b-4df7-9548-6d342b4361b2_1310x816.png 1272w, https://substackcdn.com/image/fetch/$s_!Zf30!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ee68530-d50b-4df7-9548-6d342b4361b2_1310x816.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 role="img" 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><title></title><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>He&#8217;s a software engineer at Google, building at the intersection of machine learning infrastructure, AI agents, and developer tooling.</p><p>He uses his background in machine learning research to teach software engineers the AI topics they should know via his newsletter, <strong><a href="http://aiforswes.com/subscribe">AI for Software Engineers</a></strong>.</p><p>You can also get an exclusive&nbsp;<strong><a href="https://www.aiforswes.com/67113502">25% off a paid AI for Software Engineers subscription</a></strong>&nbsp;as a reader of the System Design Newsletter.</p><div><hr></div><h2><strong>1 Software 1.0, 2.0, and 3.0</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3Ir2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeebfe95-2383-47ab-9b48-714973d2e17a_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3Ir2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeebfe95-2383-47ab-9b48-714973d2e17a_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!3Ir2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeebfe95-2383-47ab-9b48-714973d2e17a_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!3Ir2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeebfe95-2383-47ab-9b48-714973d2e17a_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!3Ir2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeebfe95-2383-47ab-9b48-714973d2e17a_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3Ir2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeebfe95-2383-47ab-9b48-714973d2e17a_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/feebfe95-2383-47ab-9b48-714973d2e17a_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;:277568,&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://newsletter.systemdesign.one/i/192186526?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeebfe95-2383-47ab-9b48-714973d2e17a_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3Ir2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeebfe95-2383-47ab-9b48-714973d2e17a_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!3Ir2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeebfe95-2383-47ab-9b48-714973d2e17a_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!3Ir2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeebfe95-2383-47ab-9b48-714973d2e17a_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!3Ir2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeebfe95-2383-47ab-9b48-714973d2e17a_1200x630.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 role="img" 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><title></title><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><blockquote><p>&#8220;The hottest new programming language is English.&#8221; - <a href="https://x.com/karpathy/status/1617979122625712128">Andrej Karpathy</a></p></blockquote><p>There have been two recent AI-related shifts that have fundamentally changed software development and required software engineers to learn new concepts.</p><p>Both changes have been caused by the development of <em>machine learning models</em>: programs trained on data to recognize patterns and make predictions rather than follow explicit rules.</p><p>Andrej Karpathy details these changes by describing three different eras of software engineering:</p><ul><li><p><a href="https://karpathy.medium.com/software-2-0-a64152b37c35">Software 1.0</a>: hand-written logic via writing code. This was the paradigm from the inception of programming all the way to the advent of machine learning.</p></li><li><p><a href="https://karpathy.medium.com/software-2-0-a64152b37c35">Software 2.0</a>: shift from explicitly writing logic via code to curating datasets and teaching algorithms to understand them. This shifts logic from a set of instructions to logic learned from data. A good example of this is Tesla&#8217;s Autopilot system, shifting from hand-written C++ code to neural networks<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a> for vision.</p></li><li><p><a href="https://www.youtube.com/watch?v=LCEmiRjPEtQ">Software 3.0</a>: shift toward natural language<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a> being our new programming interface. This enables engineers to write code by speaking English (<a href="https://x.com/karpathy/status/1886192184808149383">vibe coding</a>). It also enables engineers to build agents<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a>, or software that can think and act autonomously.</p></li></ul><p>Software engineers <a href="https://www.aiforswes.com/p/why-software-engineers-need-to-understand-ml">need to understand</a> these key AI principles to be productive in the software 3.0 paradigm&#8230;</p><h2><strong>2 Large Language Models (LLMs)</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VnN-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VnN-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!VnN-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!VnN-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!VnN-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VnN-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_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;:402460,&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://newsletter.systemdesign.one/i/192186526?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!VnN-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!VnN-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!VnN-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!VnN-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4095f8c9-e27f-4be6-bec4-ceb6e8f2a8fc_1200x630.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 role="img" 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><title></title><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>LLMs are natural language AI models trained to predict the continuation of text given a natural language input.</p><p>As with any AI model, understanding how it works best comes from examining its training data. LLMs are trained on a massive dataset of text from the internet. They&#8217;re trained to learn the <em><strong>relationship between words</strong></em> <em><strong>to best predict an output</strong></em> when given a specific string of inputs.</p><p>This relationship enables LLMs to use the knowledge stored in the semantics of language to understand relationships between concepts.</p><p>LLMs are also tuned to be <em><strong>non-deterministic</strong></em>; i.e., to provide different answers when an input is sent to the LLM more than once. This ensures <a href="https://www.aiforswes.com/p/temperature-in-llms?utm_source=publication-search">an LLM&#8217;s output isn&#8217;t locked to a given input</a>.</p><p>These two concepts make LLMs intelligent.</p><p>To relate LLMs to general software engineering, we can think of an LLM as a &#8220;non-deterministic database&#8221;.</p><p>This makes it easier to understand the impact of the knowledge encoded in its weights via semantic understanding. I like to compare it to a SQL database and a query: <em>LLM is the database, and the prompt given to the LLM is the query that extracts the information in the format the user wants.</em></p><p>In AI engineering, it&#8217;s apt to think of an LLM as the central processing unit (CPU) of your application. By giving an LLM input information, it can make decisions on its own. Thus, the LLM becomes the CPU for your software, deciding what to do with the information provided.</p><p>This is also an apt comparison because choosing an LLM is like picking a CPU.</p><p>Each LLM has its own tradeoffs for latency, cost, functionality, and more. Choosing the right model (or models!) is important to meet the requirements of production software systems.</p><h2><strong>3 Context</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-Elf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195e9f44-5a2b-46e9-be38-fb9370a85ca1_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-Elf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195e9f44-5a2b-46e9-be38-fb9370a85ca1_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!-Elf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195e9f44-5a2b-46e9-be38-fb9370a85ca1_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!-Elf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195e9f44-5a2b-46e9-be38-fb9370a85ca1_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!-Elf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195e9f44-5a2b-46e9-be38-fb9370a85ca1_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-Elf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195e9f44-5a2b-46e9-be38-fb9370a85ca1_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/195e9f44-5a2b-46e9-be38-fb9370a85ca1_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;:291234,&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://newsletter.systemdesign.one/i/192186526?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195e9f44-5a2b-46e9-be38-fb9370a85ca1_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-Elf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195e9f44-5a2b-46e9-be38-fb9370a85ca1_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!-Elf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195e9f44-5a2b-46e9-be38-fb9370a85ca1_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!-Elf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195e9f44-5a2b-46e9-be38-fb9370a85ca1_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!-Elf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195e9f44-5a2b-46e9-be38-fb9370a85ca1_1200x630.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 role="img" 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><title></title><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><em><strong>Context</strong></em> is the information LLMs store in their memory and functions as the working memory for a task. For an LLM to perform a task or make a decision, it must have the relevant information in its context window<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a>.</p><p>Context works by converting all input into <em><strong>tokens</strong></em>, which are small chunks of text (roughly 3-4 characters each) and feeding them into a model sequentially. The model uses an <em><strong>attention mechanism</strong></em> (a process that calculates how each token relates to every other token in the sequence) to determine which tokens are relevant to each other.</p><p>This is how LLMs &#8216;understand&#8217; the relationships within the input mentioned above.</p><p>The tokens currently part of a conversation with an LLM are considered part of that LLM&#8217;s &#8220;context window&#8221;. Each time you interact with an LLM, the model processes the entire context window from scratch. It doesn&#8217;t remember the previous turn unless you feed the entire conversation history back in.</p><p>Similar to RAM, an LLM&#8217;s context window is finite&#8230;</p><p>There is a hard limit to the number of tokens that can be stored in context at a time. Even before hitting that limit, LLMs tend to bias their knowledge toward the start and end of their context window. This means an LLM&#8217;s understanding of the information it is given can degrade before it reaches the hard limit.</p><p>The size of an LLM&#8217;s context window varies between models.</p><p>We&#8217;re at a point where frontier models can process 1 million or more tokens, whereas many open models are closer to 256,000 tokens. This isn&#8217;t enough for many applications, so it&#8217;s important to design AI systems with context limitations in mind.</p><p>Also, like RAM, an LLM&#8217;s context doesn&#8217;t persist between sessions.</p><p>LLMs will only remember the context provided during a session. This means AI systems with long-term memory require a more persistent memory storage and retrieval system.</p><p>Context is managed by only keeping the tokens a model needs for a task.</p><p>To effectively manage context, consider:</p><ul><li><p><strong>Using subagents for specific tasks</strong>. A separate agent means a separate context window. That agent can process and summarize the context, then return it to our primary agent.</p></li><li><p><strong>Summarizing all information currently within an LLM&#8217;s context window</strong>, clearing the context window, and adding the summary back in. This stores the same information in a shorter context.</p></li><li><p><strong>Using external systems to store information</strong>. Information is only needed in context when it&#8217;s being used. It should be stored in a separate, accessible datastore otherwise.</p></li></ul><p>Every AI application built with LLMs needs to properly manage context.</p><h2><strong>4 Embeddings and Vector Databases</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2EKH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2EKH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!2EKH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!2EKH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!2EKH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2EKH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_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;:201783,&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://newsletter.systemdesign.one/i/192186526?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2EKH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!2EKH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!2EKH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!2EKH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b96b4e5-74fd-4de4-bbfb-4e26e996b3e2_1200x630.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 role="img" 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><title></title><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>You can&#8217;t fit everything into a model&#8217;s context window, so you need a way to find relevant information efficiently.</p><p>An <strong>embedding</strong> represents the meaning of data as a list of numbers, called a <strong>vector</strong>. An embedding can be created from text, audio, video, or any other data format to convey the meaning of that data. Items with similar embedding vectors are considered similar.</p><p>Consider a coordinate system in which each axis corresponds to a learned semantic dimension.</p><p><em>&#8220;Deploy a microservice&#8221;</em> and <em>&#8220;ship a container to production&#8221;</em> would be plotted close together. <em>&#8220;Deploy a microservice&#8221;</em> and <em>&#8220;quarterly revenue forecast&#8221;</em> would be far apart. Embeddings can do this across thousands of dimensions. Distance in this high-dimensional space equals similarity in meaning.</p><p>Vector databases<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-5" href="#footnote-5" target="_self">5</a> are built explicitly to store and query embeddings.</p><p>They use algorithms optimized for quickly finding the most similar vectors in the database. Those vectors are then added to a model&#8217;s context. This is comparable to retrieving data from a cache.</p><p>The process follows these steps:</p><ol><li><p><strong>Index</strong>: Convert documents into embeddings, store in a vector database</p></li><li><p><strong>Retrieve</strong>: Embed the query and find the most similar documents</p></li><li><p><strong>Augment</strong>: Pass those documents into the LLM&#8217;s context window with the user&#8217;s question</p></li><li><p><strong>Generate</strong>: LLM answers using retrieved information</p></li></ol><p>Almost every production AI engineering system will need a working memory solution.</p><p>Context will need to be augmented with a persistent data store. Embeddings and vector databases.</p><h2><strong>5 Time to First Token</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!g-Ix!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff332d3e0-2df1-49e0-99a5-7486eb6ac39a_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!g-Ix!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff332d3e0-2df1-49e0-99a5-7486eb6ac39a_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!g-Ix!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff332d3e0-2df1-49e0-99a5-7486eb6ac39a_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!g-Ix!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff332d3e0-2df1-49e0-99a5-7486eb6ac39a_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!g-Ix!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff332d3e0-2df1-49e0-99a5-7486eb6ac39a_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!g-Ix!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff332d3e0-2df1-49e0-99a5-7486eb6ac39a_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f332d3e0-2df1-49e0-99a5-7486eb6ac39a_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;:377887,&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://newsletter.systemdesign.one/i/192186526?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff332d3e0-2df1-49e0-99a5-7486eb6ac39a_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!g-Ix!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff332d3e0-2df1-49e0-99a5-7486eb6ac39a_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!g-Ix!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff332d3e0-2df1-49e0-99a5-7486eb6ac39a_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!g-Ix!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff332d3e0-2df1-49e0-99a5-7486eb6ac39a_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!g-Ix!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff332d3e0-2df1-49e0-99a5-7486eb6ac39a_1200x630.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 role="img" 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><title></title><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>There are many factors to consider when choosing a specific LLM for your production AI system. One of these requirements is latency: <em>your system must function fast enough to be useful.</em></p><p>AI systems must consider the key latency metrics of traditional software systems and the LLM latency metrics, such as:</p><ul><li><p><strong>Time to First Token (TTFT)</strong>: How long until the model starts responding. This determines perceived responsiveness. Smaller models respond in under a second, but larger models can take several seconds to generate anything.</p></li><li><p><strong>Tokens Per Second (Throughput)</strong>: How fast the model generates after starting. This varies significantly across model sizes and compute units, and also affects how quickly the model's response is output to the user.</p></li></ul><p>AI applications require concurrency to stream the output of an LLM call and reduce perceived latency.</p><p><a href="https://www.aiforswes.com/p/mle-metrics?utm_source=publication-search">Latency is an incredibly important metric</a> to understand the real-world functionality of an AI system.</p><p>This is like streaming services, which play the start of a video while loading the rest in the background. This enables the viewer to watch the video before the entire video loads.</p><h2><strong>6 Evals</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FYJN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813834d8-5814-46f2-a8f0-215141afbd65_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FYJN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813834d8-5814-46f2-a8f0-215141afbd65_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!FYJN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813834d8-5814-46f2-a8f0-215141afbd65_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!FYJN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813834d8-5814-46f2-a8f0-215141afbd65_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!FYJN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813834d8-5814-46f2-a8f0-215141afbd65_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FYJN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813834d8-5814-46f2-a8f0-215141afbd65_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/813834d8-5814-46f2-a8f0-215141afbd65_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;:184818,&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://newsletter.systemdesign.one/i/192186526?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813834d8-5814-46f2-a8f0-215141afbd65_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FYJN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813834d8-5814-46f2-a8f0-215141afbd65_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!FYJN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813834d8-5814-46f2-a8f0-215141afbd65_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!FYJN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813834d8-5814-46f2-a8f0-215141afbd65_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!FYJN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813834d8-5814-46f2-a8f0-215141afbd65_1200x630.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 role="img" 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><title></title><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><blockquote><p>&#8220;Evals are a new toolset for any and all AI engineers, and software engineers should also know about them. Move from guesswork to a systematic engineering process for improving AI quality.&#8221; - <a href="https://newsletter.pragmaticengineer.com/p/evals">Pragmatic Engineer, December 2025</a></p></blockquote><p>In traditional software, tests are written to ensure code function reliability.</p><p>In AI, traditional tests are <em>insufficient</em> for many parts of the system because of their non-deterministic nature. Instead, we write evaluations (evals for short).</p><p>Since assert statements won&#8217;t suffice for non-deterministic applications, evals are written using LLM-as-a-judge<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-6" href="#footnote-6" target="_self">6</a>.</p><p>Essentially, a dataset of inputs and their successful outputs is curated.</p><p>This dataset will be used to tell the judge what we&#8217;re looking for in our model's output. The LLM-as-a-judge will score how closely the tested model&#8217;s outputs resemble the successful output based on given criteria such as relevance, hallucinations, and accuracy.</p><p>For example, an eval can be used to assess whether an LLM effectively pulls the important information from a document when summarizing. A set of documents and summarization pairs is gathered as a solution set. The documents are run through the LLM we&#8217;re testing, and our LLM-as-a-judge compares the solution for that document to our LLM&#8217;s output.</p><p>Evals are vital because even the smallest changes in a non-deterministic system can change the user's output. The most common of these changes is model tweaks. Even a small tweak in model performance can drastically change the output of a system.</p><p>Evals are written to catch these changes.</p><h2><strong>7 Agent Loops</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1TB1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6483a3aa-045c-4ea8-80d8-63753e903ecd_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1TB1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6483a3aa-045c-4ea8-80d8-63753e903ecd_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!1TB1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6483a3aa-045c-4ea8-80d8-63753e903ecd_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!1TB1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6483a3aa-045c-4ea8-80d8-63753e903ecd_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!1TB1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6483a3aa-045c-4ea8-80d8-63753e903ecd_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1TB1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6483a3aa-045c-4ea8-80d8-63753e903ecd_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6483a3aa-045c-4ea8-80d8-63753e903ecd_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;:357847,&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://newsletter.systemdesign.one/i/192186526?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6483a3aa-045c-4ea8-80d8-63753e903ecd_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1TB1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6483a3aa-045c-4ea8-80d8-63753e903ecd_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!1TB1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6483a3aa-045c-4ea8-80d8-63753e903ecd_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!1TB1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6483a3aa-045c-4ea8-80d8-63753e903ecd_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!1TB1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6483a3aa-045c-4ea8-80d8-63753e903ecd_1200x630.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 role="img" 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><title></title><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>Agent loops<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-7" href="#footnote-7" target="_self">7</a> represent the shift from Software 2.0 to Software 3.0.</p><p>Software 1.0 to 2.0 was the change from logical control flow to probabilistic output. In the shift to Software 3.0, we see probabilistic output used as reasoning loops in an agentic system<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-8" href="#footnote-8" target="_self">8</a>.</p><p>Agent loops enable an LLM to continuously receive and act on information. An agent loop looks something like:</p><ol><li><p><strong>Thought</strong>: Model reasons about the current state and what it needs to do next</p></li><li><p><strong>Action</strong>: The model decides to call a tool</p></li><li><p><strong>Observation</strong>: Application executes the tool and returns the result</p></li><li><p><strong>Repeat</strong>: Model then reasons about the observation, takes another action, or provides a final answer</p></li></ol><p>This is the <a href="https://arxiv.org/abs/2210.03629">ReAct pattern</a> (Reason + Act), and it has become the default agent loop architecture.</p><p>ReAct merges Chain of Thought reasoning, where the model works through a problem step by step, with tool execution into a single loop. This means a model can not only reason to act, but also take its previous actions and their outputs into account, continuously acting until a task is complete.</p><p>For example, consider an AI travel agent tasked with booking a trip within a budget.</p><p>It first searches for flights and finds the cheapest option. It then reasons about how much budget remains and searches for hotels accordingly. The initial results are all outside the city center, so it adjusts its search criteria and finds a better option. It calculates the total, confirms it fits the budget, and presents the full itinerary.</p><p>An agent loop relies on the LLM to determine the next step continuously until it completes a task. This looping process enables an LLM to use its knowledge and context to do meaningful work.</p><p>This enables complex workflows that aren&#8217;t possible with written code alone.</p><h2><strong>8 Tool Calling</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SU62!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17803a9f-946d-4559-ac7a-e91ed81babf3_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SU62!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17803a9f-946d-4559-ac7a-e91ed81babf3_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!SU62!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17803a9f-946d-4559-ac7a-e91ed81babf3_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!SU62!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17803a9f-946d-4559-ac7a-e91ed81babf3_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!SU62!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17803a9f-946d-4559-ac7a-e91ed81babf3_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SU62!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17803a9f-946d-4559-ac7a-e91ed81babf3_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/17803a9f-946d-4559-ac7a-e91ed81babf3_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;:185870,&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://newsletter.systemdesign.one/i/192186526?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17803a9f-946d-4559-ac7a-e91ed81babf3_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SU62!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17803a9f-946d-4559-ac7a-e91ed81babf3_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!SU62!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17803a9f-946d-4559-ac7a-e91ed81babf3_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!SU62!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17803a9f-946d-4559-ac7a-e91ed81babf3_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!SU62!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17803a9f-946d-4559-ac7a-e91ed81babf3_1200x630.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 role="img" 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><title></title><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>Meaningful work is further enabled by tool calling<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-9" href="#footnote-9" target="_self">9</a> capabilities.</p><p>This gives the LLM the ability to <em>do something</em> as part of its action. While LLMs can always output natural language, tool calling enables that output to call functions that perform work.</p><p>LLMs cannot execute code, access the internet, or perform other work natively. Instead, tool calling must be enabled:</p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/ai-concepts">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Everything You Need to Know to Design GenAI Systems From Scratch]]></title><description><![CDATA[#137: Part 1 - Generative AI Masterclass]]></description><link>https://newsletter.systemdesign.one/p/generative-ai-system-design</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/generative-ai-system-design</guid><dc:creator><![CDATA[Louis-François Bouchard]]></dc:creator><pubDate>Tue, 07 Apr 2026 12:33:42 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/863a9f29-e5d1-4565-8f9e-6b3a355991ef_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://newsletter.systemdesign.one/subscribe?yearly=true" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RKN7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3689f342-2008-4ce6-b968-16461682508b_1280x300.png 424w, https://substackcdn.com/image/fetch/$s_!RKN7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3689f342-2008-4ce6-b968-16461682508b_1280x300.png 848w, https://substackcdn.com/image/fetch/$s_!RKN7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3689f342-2008-4ce6-b968-16461682508b_1280x300.png 1272w, https://substackcdn.com/image/fetch/$s_!RKN7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3689f342-2008-4ce6-b968-16461682508b_1280x300.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RKN7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3689f342-2008-4ce6-b968-16461682508b_1280x300.png" width="1280" height="300" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3689f342-2008-4ce6-b968-16461682508b_1280x300.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:300,&quot;width&quot;:1280,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:24224,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://newsletter.systemdesign.one/subscribe?yearly=true&quot;,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/192435842?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3689f342-2008-4ce6-b968-16461682508b_1280x300.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RKN7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3689f342-2008-4ce6-b968-16461682508b_1280x300.png 424w, https://substackcdn.com/image/fetch/$s_!RKN7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3689f342-2008-4ce6-b968-16461682508b_1280x300.png 848w, https://substackcdn.com/image/fetch/$s_!RKN7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3689f342-2008-4ce6-b968-16461682508b_1280x300.png 1272w, https://substackcdn.com/image/fetch/$s_!RKN7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3689f342-2008-4ce6-b968-16461682508b_1280x300.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/generative-ai-system-design/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><p>I have a big big announcement for those of you who want to become good at AI engineering.</p><p>INTRODUCING:<strong> GENERATIVE AI MASTERCLASS</strong></p><p>This is a <em><strong>monthly newsletter series</strong></em> that&#8217;ll teach you Generative AI system design.</p><p>By the end of this newsletter series, you&#8217;ll walk away with:</p><ul><li><p><strong>Simple breakdown of real-world architectures</strong></p></li><li><p>Frameworks you can plug into your work or business</p></li><li><p><strong>Proven systems behind ChatGPT, Perplexity, and Copilot</strong></p></li></ul><p><em>And here&#8217;s the best part:</em></p><p>You&#8217;ll go from knowing how to &#8220;use AI&#8221; to understanding how to design, build, and ship AI.</p><p>No AI/ML background needed. Each newsletter explains concepts in plain English, with visuals and real product examples.</p><p>If you want the maximum AI career leverage, join below:</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><h3><a href="https://agentfield.ai/blog/posts/beyond-vibe-coding/?utm_source=sys_design&amp;utm_medium=newsletter&amp;utm_campaign=sys_design-060407&amp;utm_id=sys_design-060407-blog-bvc-cta&amp;utm_content=blog-bvc-cta">New Open Source: Build and Scale Agents and Harnesses Like APIs (Partner)</a></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://agentfield.ai/blog/posts/beyond-vibe-coding/?utm_source=sys_design&amp;utm_medium=newsletter&amp;utm_campaign=sys_design-060407&amp;utm_id=sys_design-060407-blog-bvc-cta&amp;utm_content=blog-bvc-cta" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_ibW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47cf900f-e29b-4ef8-965f-17c733bcd2d3_1920x1920.webp 424w, https://substackcdn.com/image/fetch/$s_!_ibW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47cf900f-e29b-4ef8-965f-17c733bcd2d3_1920x1920.webp 848w, https://substackcdn.com/image/fetch/$s_!_ibW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47cf900f-e29b-4ef8-965f-17c733bcd2d3_1920x1920.webp 1272w, https://substackcdn.com/image/fetch/$s_!_ibW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47cf900f-e29b-4ef8-965f-17c733bcd2d3_1920x1920.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_ibW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47cf900f-e29b-4ef8-965f-17c733bcd2d3_1920x1920.webp" width="1456" height="1456" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/47cf900f-e29b-4ef8-965f-17c733bcd2d3_1920x1920.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1456,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:186332,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:&quot;https://agentfield.ai/blog/posts/beyond-vibe-coding/?utm_source=sys_design&amp;utm_medium=newsletter&amp;utm_campaign=sys_design-060407&amp;utm_id=sys_design-060407-blog-bvc-cta&amp;utm_content=blog-bvc-cta&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/179236490?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47cf900f-e29b-4ef8-965f-17c733bcd2d3_1920x1920.webp&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!_ibW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47cf900f-e29b-4ef8-965f-17c733bcd2d3_1920x1920.webp 424w, https://substackcdn.com/image/fetch/$s_!_ibW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47cf900f-e29b-4ef8-965f-17c733bcd2d3_1920x1920.webp 848w, https://substackcdn.com/image/fetch/$s_!_ibW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47cf900f-e29b-4ef8-965f-17c733bcd2d3_1920x1920.webp 1272w, https://substackcdn.com/image/fetch/$s_!_ibW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47cf900f-e29b-4ef8-965f-17c733bcd2d3_1920x1920.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 role="img" 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><title></title><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><code>One.harness()</code> call and orchestrate hundreds of Claude Code, Codex, and Gemini instances into a coordinated team. They discover each other at runtime, split work, cross-reference results, and converge autonomously. Go deeper on harness engineering &#8594; <a href="https://agentfield.ai/blog/posts/beyond-vibe-coding/?utm_source=sys_design&amp;utm_medium=newsletter&amp;utm_campaign=sys_design-060407&amp;utm_id=sys_design-060407-blog-bvc-cta&amp;utm_content=blog-bvc-cta">blog</a>.</p><p>No DAGs. No glue code. Agents work like APIs, Python, TypeScript &amp; Go.</p><p>We built production systems you can clone and run today:</p><p>&#8594; <a href="https://agentfield.ai/github/swe-af/?utm_source=github-readme&amp;utm_campaign=github-readme&amp;utm_id=github-readme-swe-af-repo">Autonomous Engineering Team</a>: 175 agents ship code end-to-end</p><p>&#8594; <a href="https://agentfield.ai/github/cloudsecurity/?utm_source=github-readme&amp;utm_campaign=github-readme&amp;utm_id=github-readme-cloudsec-repo">Deep Security Auditor</a>: 250 agents scan every CVE</p><p>&#8594; <a href="https://agentfield.ai/github/sec-af/?utm_source=github-readme&amp;utm_campaign=github-readme&amp;utm_id=github-readme-sec-af-repo">Adversarial Code Reviewer</a>: 50+ agents debate your PRs</p><p>Each runs on any model. Apache 2.0.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://agentfield.ai/github/?utm_source=sys_design&amp;utm_medium=newsletter&amp;utm_campaign=sys_design-060407&amp;utm_id=sys_design-060407-github-cta&amp;utm_content=github-cta&quot;,&quot;text&quot;:&quot;Clone a Recipe&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://agentfield.ai/github/?utm_source=sys_design&amp;utm_medium=newsletter&amp;utm_campaign=sys_design-060407&amp;utm_id=sys_design-060407-github-cta&amp;utm_content=github-cta"><span>Clone a Recipe</span></a></p><div><hr></div><p>We&#8217;ve all used ChatGPT.</p><p>From our user perspective, it looks simple: <em>type a question, get a response</em>. But there&#8217;s a lot more behind it than a large language model (LLM) with a chat interface.</p><p>Building a product like ChatGPT means choosing the right model from a growing landscape of options, preparing the data that trains it, running a multi-stage training pipeline, evaluating whether the outputs are actually good, adding safety controls to prevent harm, and wrapping it all in serving infrastructure that can handle millions of requests. The same is true for Perplexity, GitHub Copilot, and Midjourney.</p><p>The model is one piece of a much larger system.</p><p>Understanding these components is what separates someone who can use GenAI from someone who can design and build it. That&#8217;s what this newsletter series is for.</p><p>This first newsletter covers the foundation.</p><p>We walk through the model landscape, the data layer, the training pipeline, evaluation, safety, and the engineering that turns a model into a product.</p><p>Let&#8217;s start with a glossary of key terms that come up throughout this newsletter and the rest of the series. If you&#8217;re already comfortable with terms like tokens, embeddings, and context windows, skip ahead to <em>Part 1: The AI Model Landscape.</em></p><div><hr></div><p>I want to introduce <a href="https://louisbouchard.substack.com/">Louis-Fran&#231;ois Bouchard</a> as the author of this newsletter.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://louisbouchard.substack.com/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8ezx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bbacb1f-03da-4781-9a5e-b720e4af2e34_1100x220.png 424w, https://substackcdn.com/image/fetch/$s_!8ezx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bbacb1f-03da-4781-9a5e-b720e4af2e34_1100x220.png 848w, https://substackcdn.com/image/fetch/$s_!8ezx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bbacb1f-03da-4781-9a5e-b720e4af2e34_1100x220.png 1272w, https://substackcdn.com/image/fetch/$s_!8ezx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bbacb1f-03da-4781-9a5e-b720e4af2e34_1100x220.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8ezx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bbacb1f-03da-4781-9a5e-b720e4af2e34_1100x220.png" width="1100" height="220" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2bbacb1f-03da-4781-9a5e-b720e4af2e34_1100x220.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:220,&quot;width&quot;:1100,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://louisbouchard.substack.com/&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!8ezx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bbacb1f-03da-4781-9a5e-b720e4af2e34_1100x220.png 424w, https://substackcdn.com/image/fetch/$s_!8ezx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bbacb1f-03da-4781-9a5e-b720e4af2e34_1100x220.png 848w, https://substackcdn.com/image/fetch/$s_!8ezx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bbacb1f-03da-4781-9a5e-b720e4af2e34_1100x220.png 1272w, https://substackcdn.com/image/fetch/$s_!8ezx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bbacb1f-03da-4781-9a5e-b720e4af2e34_1100x220.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>He&#8217;s a best-selling author (<a href="https://amzn.to/4bqYU9b">Building LLMs for Production</a>), the co-founder of <a href="https://academy.towardsai.net/?ref=1f9b29">Towards AI</a>, and the creator of the YouTube Channel, <a href="https://www.youtube.com/@whatsai?sub_confirmation=1">What&#8217;s AI</a>, where he helps people understand AI and learn how to apply it in the real world. Through his development works with clients and his content, teaching, and AI training programs on the <a href="https://academy.towardsai.net/?ref=1f9b29">Towards AI Academy</a>, Louis focuses on making AI practical for builders, engineers, and curious learners alike.</p><p>At Towards AI, he and his team train AI engineers through courses built for every stage, from beginner to advanced. That educational mission and the real-world experience building for his clients are exactly why I wanted him in this newsletter series.</p><div><hr></div><h2><strong>Key Terms</strong></h2><p>You don&#8217;t need to learn these upfront.</p><p>Skim to get familiar, then refer back whenever you hit an unfamiliar term:</p><p><strong>Token</strong>: LLMs work with numbers, not words. Before processing any text, the model breaks it into small chunks, called tokens. A token can be a whole word (&#8220;the&#8221;), part of a word (&#8220;un&#8221;, &#8220;believ&#8221;, &#8220;able&#8221;), or punctuation. One token is roughly &#8776; 4 English characters, though this varies by language and model. API pricing, context limits, and cost are all measured in tokens.</p><p><strong>Embedding</strong>: A token ID alone (like 1023 for &#8220;What&#8221;) tells the model nothing about meaning. An embedding replaces that ID with a list of numbers (a vector) that captures what the word means and how it relates to other words. These vectors are what the model actually works with internally, processing and transforming them at every step to build up an understanding of the full input. Words with similar meaning end up with similar vectors: &#8220;king&#8221; and &#8220;queen&#8221; are close together, &#8220;king&#8221; and &#8220;banana&#8221; are far apart. This same property also powers search in GenAI products: when a user asks <em>&#8220;How do I reset my password?&#8221;</em>, the system can find documents on password resets, account recovery, and login issues, even if those documents never use that exact phrase.</p><p><strong>Parameter</strong>: These are internal variables inside a model, billions of them. At the start of training, they&#8217;re random. Each time the model makes an incorrect prediction, settings are nudged slightly. After trillions of such adjustments, they encode language patterns. GPT-3 had 175B parameters. Llama 4 comes in Scout (17B active) and Maverick (17B active). More parameters mean more capability, but also more memory: a large model can need 140GB or more just to load.</p><p><strong>Context Window</strong>: The maximum amount of text (in tokens) a model can see in one request. GPT-5 supports up to 400K tokens (272K input). Claude and Gemini support up to 1M tokens. Everything the model needs, system instructions, conversation history, retrieved documents, and the user&#8217;s question must fit within this window. Deciding what goes in and what gets cut is called <em>context engineering</em>.</p><p><strong>Inference</strong>: Every time someone sends a message to ChatGPT, the model runs to produce a response. That&#8217;s one inference call. At scale, this can mean millions of calls per day, and the cost adds up. Two key metrics define inference performance: <em>Time to First Token (<strong>TTFT</strong>)</em>, the time the user waits before the first word appears, and <em>Tokens per Second (<strong>TPS</strong>)</em>, the rate at which the rest of the response streams in after that.</p><p><strong>LLM (Large Language Model)</strong>: A neural network (a program that learns patterns from data) trained on one objective: to predict the next token. GPT, Claude, Llama, and Gemini are all LLMs. The objective is simple, but at a massive scale (trillions of tokens of training data), it produces the ability to follow instructions, write code, reason through problems, and hold conversations.</p><p><strong>Foundation Model</strong>: A large, general-purpose model trained on massive data that serves as the starting point for products. Both LLMs (GPT-5, Claude) and diffusion models (Stable Diffusion, Midjourney) are foundation models. These aren&#8217;t built from scratch for each product. You take one and adapt it through prompting, fine-tuning, or both.</p><p><strong>RAG (Retrieval-Augmented Generation)</strong>: A design approach where the system retrieves relevant documents at query time and includes them in the prompt, so the answer is grounded in real sources rather than what the model memorized during training. Products like Perplexity use this approach: search the web, feed the results to the model, and generate an answer with citations. It&#8217;s widely used in products that need up-to-date or domain-specific knowledge.</p><p><strong>Fine-tuning</strong>: Taking a foundation model and training it further on a smaller, task-specific dataset to specialize its behavior. For example, a model fine-tuned on customer support conversations learns the right tone, format, and escalation patterns for that domain. Fine-tuning changes <em>how</em> the model responds (style, format, tone), not <em>what</em> it knows. If the model needs to answer questions using knowledge not in its training data, retrieval-augmented generation (RAG) is the standard approach.</p><p><strong>Prompt</strong>: The full text input sent to a model for each request is a prompt. It typically includes a <em>system prompt</em> (developer-defined instructions that define the model&#8217;s role), the <em>conversation history</em> (previous messages), and the <em>user message</em> (the current question). In RAG systems, retrieved documents are also included. <em>Prompt engineering</em> is the practice of refining how this input is structured to get better results.</p><p><strong>Hallucination</strong>: When a model generates confident but factually wrong output, like citing a paper that doesn&#8217;t exist or inventing a URL. This isn&#8217;t a bug. These models are optimized to produce text that sounds plausible rather than factually correct, so hallucinations are a built-in trade-off, not a malfunction. The main ways to reduce hallucinations are <em>RAG</em> (retrieving real sources to ground the answer) and <em>evaluation</em> (testing the model&#8217;s outputs for accuracy).</p><p><strong>Transformer</strong>: The neural network architecture behind nearly all modern foundation models, introduced in 2017 (&#8220;Attention Is All You Need&#8221;). Its key innovation is the <em>attention mechanism</em>: instead of processing tokens sequentially, the model considers all tokens simultaneously and learns which are relevant to one another. In &#8220;The cat sat on the mat because it was tired,&#8221; attention connects &#8220;it&#8221; back to &#8220;cat&#8221; rather than &#8220;mat.&#8221; Some models extend this architecture with a <em>Mixture of Experts (<strong>MoE</strong>)</em>, where only a subset of the model&#8217;s parameters is used for each input rather than all of them, making the model faster and cheaper to run while maintaining high overall capability.</p><p><strong>GPU/TPU</strong>: The specialized hardware on which GenAI runs. <strong>GPUs</strong> (NVIDIA H100, A100, B200) handle the massive number of calculations required by models. A request that takes milliseconds on a GPU could take orders of magnitude longer on a regular CPU. Training a large model needs thousands of GPUs running for months. <strong>TPUs</strong> are Google&#8217;s custom chips for ML, used primarily within Google Cloud.</p><p><strong>Latency</strong>: How long the user waits for a response. Different products have different targets depending on what the user is doing. Autocomplete has to keep up with typing, so it typically needs a response in under 300ms. Chat users expect a short pause before the reply starts streaming. Image and video generation is much slower; users wait 10 to 60 seconds. These targets influence which model to use, whether to add caching, and how much the system can do before it starts to feel slow.</p><p>The first decision in designing any GenAI system is choosing the right model&#8230;</p><p>That starts with understanding what kinds of models exist and what each one is good at.</p><div><hr></div><h2><strong>Part 1: The AI Model Landscape</strong></h2><p>Not all generative models work the same way.</p><p>They differ in how they generate output, what kinds of output they produce, and how they&#8217;re built. This section breaks down the two core architectures, types of outputs they support, the internal structure of models, and how to choose between them.</p><h3><strong>Two Families of Generative Models</strong></h3><p>All generative AI models are built on one of two architectures:</p><p><strong>1 Autoregressive models</strong> generate text one token at a time.</p><p>Given the input &#8220;The capital of France is&#8221;, the model predicts the most likely next token: &#8220;Paris&#8221; in this case. It appends &#8220;Paris&#8221; to the sequence, and now uses &#8220;The capital of France is Paris&#8221; to predict the next token, i.e., &#8220;.&#8221; Then it uses the full sequence to predict the token, and so on. Each output feeds back as input. This is how GPT, Claude, Gemini, and Llama models work.</p><p>When you see a chatbot &#8220;typing&#8221; its response word by word, that&#8217;s not a UI animation; the model is actually producing tokens one after another.</p><p>Because generation is sequential, latency scales with output length: <em>a 500-token response takes roughly 500 generation steps</em>. Cost scales, too: <em>a 1,000-token response costs roughly 10x as much as a 100-token response</em>.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LNuG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea33f71-994a-449b-becd-7e5f6f110635_1600x180.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LNuG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea33f71-994a-449b-becd-7e5f6f110635_1600x180.png 424w, https://substackcdn.com/image/fetch/$s_!LNuG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea33f71-994a-449b-becd-7e5f6f110635_1600x180.png 848w, https://substackcdn.com/image/fetch/$s_!LNuG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea33f71-994a-449b-becd-7e5f6f110635_1600x180.png 1272w, https://substackcdn.com/image/fetch/$s_!LNuG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea33f71-994a-449b-becd-7e5f6f110635_1600x180.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LNuG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea33f71-994a-449b-becd-7e5f6f110635_1600x180.png" width="1456" height="164" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ea33f71-994a-449b-becd-7e5f6f110635_1600x180.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:164,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!LNuG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea33f71-994a-449b-becd-7e5f6f110635_1600x180.png 424w, https://substackcdn.com/image/fetch/$s_!LNuG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea33f71-994a-449b-becd-7e5f6f110635_1600x180.png 848w, https://substackcdn.com/image/fetch/$s_!LNuG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea33f71-994a-449b-becd-7e5f6f110635_1600x180.png 1272w, https://substackcdn.com/image/fetch/$s_!LNuG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea33f71-994a-449b-becd-7e5f6f110635_1600x180.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p style="text-align: center;"><em>Autoregressive generation: each token is produced one at a time, left to right.</em></p><p><strong>2 Diffusion models</strong> work completely differently.</p><p>Instead of producing one piece at a time, they start with pure random noise and gradually remove it over many steps until a coherent image (or video) emerges.</p><p>During training, the model sees millions of images with noise added at various levels and learns to predict what the clean version looks like. At generation time, it reverses the process step by step, typically 20 to 50 steps, removing a little noise each time until a clear image forms.</p><p>This is how Midjourney, Stable Diffusion, DALL-E, and Sora work.</p><p>The serving model is very different from text: image generation can take roughly 10 to 60 seconds, and video can take minutes, so products typically run generation as batch jobs with a queue rather than streaming.</p><p>A single image generation also costs roughly 10-100x as much compute as a typical ChatGPT response.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NtsK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F093fded3-ee7e-4917-871d-8803c37ae54c_1600x383.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NtsK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F093fded3-ee7e-4917-871d-8803c37ae54c_1600x383.png 424w, https://substackcdn.com/image/fetch/$s_!NtsK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F093fded3-ee7e-4917-871d-8803c37ae54c_1600x383.png 848w, https://substackcdn.com/image/fetch/$s_!NtsK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F093fded3-ee7e-4917-871d-8803c37ae54c_1600x383.png 1272w, https://substackcdn.com/image/fetch/$s_!NtsK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F093fded3-ee7e-4917-871d-8803c37ae54c_1600x383.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NtsK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F093fded3-ee7e-4917-871d-8803c37ae54c_1600x383.png" width="1456" height="349" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/093fded3-ee7e-4917-871d-8803c37ae54c_1600x383.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:349,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!NtsK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F093fded3-ee7e-4917-871d-8803c37ae54c_1600x383.png 424w, https://substackcdn.com/image/fetch/$s_!NtsK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F093fded3-ee7e-4917-871d-8803c37ae54c_1600x383.png 848w, https://substackcdn.com/image/fetch/$s_!NtsK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F093fded3-ee7e-4917-871d-8803c37ae54c_1600x383.png 1272w, https://substackcdn.com/image/fetch/$s_!NtsK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F093fded3-ee7e-4917-871d-8803c37ae54c_1600x383.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption"><em>Diffusion models iteratively denoise random noise into a coherent image.</em></figcaption></figure></div><h3><strong>Models Outputs</strong></h3><p>These two architectures cover a range of output types:</p><p><strong>1 Text generation</strong> (autoregressive): chat responses, code, summaries, translations, structured data extraction. This powers ChatGPT, Claude, GitHub Copilot, Perplexity.</p><p><strong>2 Text-to-image</strong> (diffusion): generate images from text prompts. Midjourney, DALL-E 3, Stable Diffusion.</p><p><strong>3 Text-to-video</strong> (diffusion): generate video clips from text or image prompts. Sora, Runway Gen-3, Kling.</p><p><strong>4 Text-to-audio</strong> (autoregressive + diffusion): generate speech, music, and sound effects. ElevenLabs, Suno, Bark.</p><p><strong>5 Vision-language models</strong> (autoregressive) process images alongside text. Upload a photo and ask the model to describe it, extract data from a receipt, or analyze a chart. GPT-5, Claude, and Gemini all support this.</p><h3><strong>Multimodality</strong></h3><p>Each of the output types above used to require its own dedicated model.</p><p>That&#8217;s changing; models like GPT-5 and Gemini now handle text, images, audio, and video within a single architecture. The question is how. How does a text prompt like <em>&#8220;a photo of a cat&#8221;</em> actually guide an image model to generate the right image?</p><p>Through <strong>cross-modal embeddings</strong>.</p><p>An embedding converts content into a list of numbers that captures its meaning. Cross-modal embeddings do this across different content types, text and images, placing them on the same map.</p><p><em>CLIP</em>, developed by OpenAI, is the most well-known example. It places both <em>&#8220;a photo of a cat&#8221;</em> (text) and an actual cat photo (image) side by side on this shared map. That shared representation enables a text description to guide image generation.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZFpI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa119134b-5712-46cb-992c-53942e0eab5f_1560x1074.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZFpI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa119134b-5712-46cb-992c-53942e0eab5f_1560x1074.png 424w, https://substackcdn.com/image/fetch/$s_!ZFpI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa119134b-5712-46cb-992c-53942e0eab5f_1560x1074.png 848w, https://substackcdn.com/image/fetch/$s_!ZFpI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa119134b-5712-46cb-992c-53942e0eab5f_1560x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!ZFpI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa119134b-5712-46cb-992c-53942e0eab5f_1560x1074.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZFpI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa119134b-5712-46cb-992c-53942e0eab5f_1560x1074.png" width="1456" height="1002" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a119134b-5712-46cb-992c-53942e0eab5f_1560x1074.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1002,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!ZFpI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa119134b-5712-46cb-992c-53942e0eab5f_1560x1074.png 424w, https://substackcdn.com/image/fetch/$s_!ZFpI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa119134b-5712-46cb-992c-53942e0eab5f_1560x1074.png 848w, https://substackcdn.com/image/fetch/$s_!ZFpI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa119134b-5712-46cb-992c-53942e0eab5f_1560x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!ZFpI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa119134b-5712-46cb-992c-53942e0eab5f_1560x1074.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 role="img" 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><title></title><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><figcaption class="image-caption"><em>Text and images mapped to the same vector space. Similar content lands nearby.</em></figcaption></figure></div><h3><strong>Model Architecture Variants</strong></h3><p>Not all foundation models are built the same way&#8230;</p><p>Most are based on the Transformer (covered in the glossary above), but they use it differently. The two main jobs of a language model are understanding input and generating output.</p><p>Different architectures handle these jobs in different ways:</p><p><strong>1 Decoder-only</strong> models focus entirely on generation: they take an input and produce text left-to-right, one token at a time. GPT, Claude, Llama, and Gemini are all decoder-only. This is the dominant architecture for text generation today.</p><p><strong>2 Encoder-only</strong> models (like BERT, an early Transformer&#8209;based language model) focus entirely on understanding: they read input and produce a numerical representation of its meaning, but don&#8217;t generate new text. Used for classification, sentiment analysis, and search ranking. For example, when a support system reads <em>&#8220;I&#8217;m furious about my broken order&#8221;</em> and classifies it as &#8220;negative sentiment, high urgency&#8221;, that&#8217;s an encoder-only model at work. In GenAI products, they play supporting roles, such as classifying user intent or detecting toxicity.</p><p><strong>3 Encoder-decoder</strong> models (like Google&#8217;s T5 and Meta&#8217;s BART) do both: one part reads and understands the input, the other generates the output. Suited for translation, summarization, and rewriting.</p><p><strong>4 Mixture of Experts (MoE)</strong> is a different kind of optimization.</p><p>Instead of a single large model where every parameter is used for every input, MoE splits the model into multiple specialized groups, called &#8220;experts.&#8221; For each input, a router determines which experts are relevant and activates only those. A question about Python code might activate code-specialized experts, while a question about French history might activate different experts. Models like Mistral&#8217;s Mixtral 8x7B use this approach, with 46.7 billion total parameters but only around 12.9 billion active per token. You get more capability per unit of compute, but you need more GPU memory to store all the experts.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2Gh9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f7ce967-d17b-4670-80d8-7b92b5014fbe_1600x308.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2Gh9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f7ce967-d17b-4670-80d8-7b92b5014fbe_1600x308.png 424w, https://substackcdn.com/image/fetch/$s_!2Gh9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f7ce967-d17b-4670-80d8-7b92b5014fbe_1600x308.png 848w, https://substackcdn.com/image/fetch/$s_!2Gh9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f7ce967-d17b-4670-80d8-7b92b5014fbe_1600x308.png 1272w, https://substackcdn.com/image/fetch/$s_!2Gh9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f7ce967-d17b-4670-80d8-7b92b5014fbe_1600x308.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2Gh9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f7ce967-d17b-4670-80d8-7b92b5014fbe_1600x308.png" width="1456" height="280" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6f7ce967-d17b-4670-80d8-7b92b5014fbe_1600x308.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:280,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!2Gh9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f7ce967-d17b-4670-80d8-7b92b5014fbe_1600x308.png 424w, https://substackcdn.com/image/fetch/$s_!2Gh9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f7ce967-d17b-4670-80d8-7b92b5014fbe_1600x308.png 848w, https://substackcdn.com/image/fetch/$s_!2Gh9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f7ce967-d17b-4670-80d8-7b92b5014fbe_1600x308.png 1272w, https://substackcdn.com/image/fetch/$s_!2Gh9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f7ce967-d17b-4670-80d8-7b92b5014fbe_1600x308.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption"><em>Most modern GenAI products use decoder-only or MoE architectures.</em></figcaption></figure></div><h3><strong>The Model Landscape: Proprietary, Open-Weight, and Open-Source</strong></h3><p>When choosing a model, there are three categories with different trade-offs:</p><p><strong>1 Proprietary models</strong> (GPT, Claude, Gemini) are accessed via API. They offer the highest capability and are the easiest to start with, but give users the least control. You can&#8217;t see the model&#8217;s internal parameters, modify its architecture, or run it on your own servers.</p><p><strong>2 Open-weight models</strong> (Llama, Mistral, Gemma) release their trained parameters publicly. You can download them, run them on your own GPUs, and fine-tune them. Training data and methods are typically not shared. This gives you full control over the model, but it also means you have to manage the infrastructure yourself.</p><p><strong>3 Open-source models</strong> go further by sharing not just weights but training code, data, and the full methodology behind how the model was built.</p><p>The gap between proprietary and open-source is narrowing&#8230;</p><p>By early 2025, models like Llama 4 Maverick and DeepSeek-V3 were competitive with proprietary models on many tasks. Most production systems use a mix: a proprietary model for complex tasks and an open-weight model for high-volume, simple ones.</p><h3><strong>Model Selection</strong></h3><p>Each model family offers a range of sizes (e.g., GPT-5 vs. GPT-5 mini, Claude Opus vs. Haiku, Llama 4 Maverick vs Scout).</p><p>Smaller models are faster and cheaper, but less capable. Beyond size, some models offer specialized variants. OpenAI&#8217;s GPT-5, for example, includes configurable reasoning effort, and Claude offers an extended thinking mode. These reasoning capabilities require more compute during inference to work through problems step by step, breaking complex questions into smaller parts before answering. This improves accuracy on tasks such as math, logic, and multi-step analysis, but it costs more per request and takes longer to respond.</p><p>This trade-off is another reason model routing matters: route simple questions to a faster model, and complex reasoning tasks to a model with these capabilities.</p><p>Public benchmarks help narrow down which specific model is best suited to a task. MMLU tests general knowledge across 57 subjects; HumanEval and MBPP focus on code generation; Chatbot Arena by LMSYS aggregates human preference scores from real conversations; and benchmarks like GPQA and ARC-AGI evaluate reasoning and problem-solving abilities.</p><p>But benchmarks have a well-known problem: contamination.</p><p>Models can be trained on benchmark test data, inflating scores. It&#8217;s like a student who memorized the answers to last year&#8217;s exam; they score high, but can&#8217;t solve newer problems. A model that tops MMLU may underperform on a specific task. Benchmarks are useful for narrowing the field, but final selection requires evaluating on your own data.</p><p>That covers the model landscape, what models exist, how they differ, and how to pick between them. All of these models, though, start with random parameters. What turns them into something useful is data.</p><div><hr></div><p><em><strong>Reminder: this is a teaser of the subscriber-only newsletter series, exclusive to my golden members.</strong></em></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://newsletter.systemdesign.one/subscribe?yearly=true" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3mfm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0002d397-a8f7-4519-a51c-f020e29ce8b3_1280x300.png 424w, https://substackcdn.com/image/fetch/$s_!3mfm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0002d397-a8f7-4519-a51c-f020e29ce8b3_1280x300.png 848w, https://substackcdn.com/image/fetch/$s_!3mfm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0002d397-a8f7-4519-a51c-f020e29ce8b3_1280x300.png 1272w, https://substackcdn.com/image/fetch/$s_!3mfm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0002d397-a8f7-4519-a51c-f020e29ce8b3_1280x300.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3mfm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0002d397-a8f7-4519-a51c-f020e29ce8b3_1280x300.png" width="1280" height="300" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0002d397-a8f7-4519-a51c-f020e29ce8b3_1280x300.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:300,&quot;width&quot;:1280,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:24224,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://newsletter.systemdesign.one/subscribe?yearly=true&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/192435842?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0002d397-a8f7-4519-a51c-f020e29ce8b3_1280x300.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3mfm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0002d397-a8f7-4519-a51c-f020e29ce8b3_1280x300.png 424w, https://substackcdn.com/image/fetch/$s_!3mfm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0002d397-a8f7-4519-a51c-f020e29ce8b3_1280x300.png 848w, https://substackcdn.com/image/fetch/$s_!3mfm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0002d397-a8f7-4519-a51c-f020e29ce8b3_1280x300.png 1272w, https://substackcdn.com/image/fetch/$s_!3mfm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0002d397-a8f7-4519-a51c-f020e29ce8b3_1280x300.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>Simple breakdown of real-world architectures</strong></p></li><li><p>Frameworks you can plug into your work or business</p></li><li><p><strong>Proven systems behind ChatGPT, Perplexity, and Copilot</strong></p></li></ul><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?yearly=true&quot;,&quot;text&quot;:&quot;Unlock Full Access&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?yearly=true"><span>Unlock Full Access</span></a></p><div><hr></div><h2><strong>Part 2: The Data Layer</strong></h2><p>A model&#8217;s capability comes entirely from the data it was trained on.</p><p>The quality of that data, how it&#8217;s collected, cleaned, and organized directly determines how well the model performs.</p><h3><strong>Training Data</strong></h3><p>Foundation models learn from massive datasets: trillions of tokens scraped from books, websites, code repositories, scientific papers, and forum posts. For diffusion models, training data consists of millions of images, each paired with a text description of its contents.</p><p>Raw data is never used directly.</p><p>It passes through a&nbsp;<strong>data pipeline</strong>&nbsp;that cleans, filters, deduplicates, and transforms the data before training begins. For example, the same news article might appear on hundreds of websites. Without deduplication, the model sees the same phrases hundreds of times and overlearns them.</p><p>The pipeline handles problems like near-duplicate web pages that inflate certain patterns, toxic or biased content the model would absorb, personally identifiable information (<strong>PII</strong>) that shouldn&#8217;t be memorized, and low-quality text that adds noise without a useful signal.</p><p>The quality of this pipeline directly determines the model's quality.</p><p><strong>Synthetic data generation</strong> is increasingly used to fill data gaps. An existing model generates additional training examples for areas where real data is scarce, such as specialized medical terminology, underrepresented languages, or edge-case code patterns. The quality of synthetic data depends on the model that generates it and how it&#8217;s validated.</p><p><strong>Bias detection</strong> starts here. If the training data overrepresents certain perspectives, demographics, or viewpoints, the model will reflect those imbalances. Data teams audit for representation gaps and offensive content before training begins, but detection is imperfect. Some biases only surface after the model is trained and tested.</p><p><strong>NSFW and harmful content</strong> requires explicit handling during this stage. Some pipelines filter it entirely. Others retain it in a controlled form so the model can later learn to recognize and refuse it. The approach depends on the product&#8217;s intended use.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pfnJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pfnJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.png 424w, https://substackcdn.com/image/fetch/$s_!pfnJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.png 848w, https://substackcdn.com/image/fetch/$s_!pfnJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.png 1272w, https://substackcdn.com/image/fetch/$s_!pfnJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pfnJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.png" width="1456" height="397" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:397,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:186851,&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://newsletter.systemdesign.one/i/192435842?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!pfnJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.png 424w, https://substackcdn.com/image/fetch/$s_!pfnJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.png 848w, https://substackcdn.com/image/fetch/$s_!pfnJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.png 1272w, https://substackcdn.com/image/fetch/$s_!pfnJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e31eb63-a6f0-4f1c-b036-26eea788218d_1999x545.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 role="img" 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><title></title><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><figcaption class="image-caption"><em>Data pipeline: raw data is cleaned through multiple stages before training.</em></figcaption></figure></div><h3><strong>Data Storage and Retrieval</strong></h3><p>Training and inference have very different data needs.</p><p>During training, the dataset can be terabytes or more in size, containing text, images, and code. Teams typically store this in distributed file systems like <strong>HDFS</strong> (Hadoop Distributed File System), which splits large files across a cluster of machines so they can be read in parallel, or cloud object storage like <strong>S3</strong> (Amazon&#8217;s Simple Storage Service), which stores files as objects in the cloud and is widely used because it&#8217;s cheap, scales without limits, and requires no infrastructure to manage. Training pipelines stream data from these systems to GPU clusters in batches, feeding the model continuously throughout training.</p><p>At inference time, the training data is no longer needed.</p><p>What matters is the model itself. The model&#8217;s parameters need to be loaded into GPU memory before it can serve any requests, and for large models, that means hundreds of gigabytes. Once loaded, the model takes in a prompt and generates tokens one at a time, streaming them back to the user.</p><p>The challenge is keeping sufficient GPU capacity available to handle many users simultaneously without long wait times.</p><p>Some GenAI systems also retrieve data at runtime, pulling in documents, search results, or database records when a user asks a question. This is how products like Perplexity stay current beyond the model&#8217;s training data.</p><p>In Part 6, we cover how this retrieval works, embeddings, vector databases, and structured data handling when we design the full product architecture.</p><p>But having clean, well-organized data is only the starting point.</p><p>The next question is what happens to that data, and how a pile of text becomes a model that can actually follow instructions&#8230;</p><p>Let&#8217;s keep going!</p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/generative-ai-system-design">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Amazon S3 - A Deep Dive]]></title><description><![CDATA[#136: How S3 Actually Works]]></description><link>https://newsletter.systemdesign.one/p/aws-s3-system-design</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/aws-s3-system-design</guid><dc:creator><![CDATA[Hayk]]></dc:creator><pubDate>Wed, 01 Apr 2026 12:04:35 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/b7180882-5e86-477b-b950-8a08d76a8ddc_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/aws-s3-system-design/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li><li><p><em>Block diagrams created using <a href="https://app.eraser.io/auth/sign-up?ref=neo">Eraser</a>.</em></p></li></ul><div><hr></div><p>Object storage isn&#8217;t just <em>&#8220;upload a file, get a URL back.&#8221;</em></p><p>That&#8217;s true for a small side project. It stops being true when you&#8217;re storing 100 trillion objects like AWS S3 does today.</p><p>Amazon Simple Storage Service (<strong>S3</strong>) launched in 2006.</p><p>In 2013, Amazon reported storing 2 trillion objects. By 2021, that number crossed 100 trillion. The system handling all of that doesn&#8217;t look anything like a file server or a relational database. It&#8217;s a fundamentally different class of infrastructure, built around a different set of tradeoffs.</p><p>This problem shows up in senior- and staff-level interviews at companies building storage-heavy products&#8230;</p><p>It tests the exact skills that separate mid-level engineers from seniors: <em>understanding why different storage types exist, designing for durability at a scale where hardware failures occur daily, and making smart trade-offs between consistency, cost, and performance.</em></p><p>We&#8217;re going to build this from scratch:</p><p>We&#8217;ll start with what object storage actually is and how it differs from other storage systems, then work through requirements, capacity estimation, the high-level architecture, disk-based data persistence, durability strategies, metadata design, object versioning<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a>, large-file uploads, and garbage collection.</p><p>At each step, we&#8217;ll explain the why behind each decision&#8230;</p><div><hr></div><h3><strong><a href="https://codenewsletter.ai/subscribe?utm_source=nl_ad_system">Find out why 150K+ engineers read The Code twice a week (Partner)</a></strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://codenewsletter.ai/subscribe?utm_source=nl_ad_system" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!w80U!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 424w, https://substackcdn.com/image/fetch/$s_!w80U!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 848w, https://substackcdn.com/image/fetch/$s_!w80U!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!w80U!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!w80U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg" width="1271" height="699" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:699,&quot;width&quot;:1271,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:303786,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:&quot;https://codenewsletter.ai/subscribe?utm_source=nl_ad_system&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/179236490?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!w80U!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 424w, https://substackcdn.com/image/fetch/$s_!w80U!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 848w, https://substackcdn.com/image/fetch/$s_!w80U!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!w80U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.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 role="img" 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><title></title><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>Tech moves fast, but you&#8217;re still playing catch-up?</p><p>That&#8217;s exactly why 150K+ engineers working at Google, Meta, and Apple read <a href="https://codenewsletter.ai/subscribe?utm_source=nl_ad_system">The Code</a> twice a week.</p><p>Here&#8217;s what you get:</p><ul><li><p><strong>Curated tech news that shapes your career </strong>- Filtered from thousands of sources so you know what&#8217;s coming 6 months early.</p></li><li><p><strong>Practical resources you can use immediately</strong> - Real tutorials and tools that solve actual engineering problems.</p></li><li><p><strong>Research papers and insights decoded</strong> - We break down complex tech so you understand what matters.</p></li></ul><p>All delivered twice a week in just 2 short emails.</p><p><strong>Sign up and get access to the Ultimate Claude code guide to ship 5X faster.</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://codenewsletter.ai/subscribe?utm_source=nl_ad_system&quot;,&quot;text&quot;:&quot;Join 150K+ Engineers&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://codenewsletter.ai/subscribe?utm_source=nl_ad_system"><span>Join 150K+ Engineers</span></a></p><p>(Thanks for partnering on this post and sharing the ultimate <a href="https://codenewsletter.ai/subscribe?utm_source=nl_ad_system">claude code guide</a>.)</p><div><hr></div><p>I want to reintroduce <a href="https://linkedin.com/in/hayksimonyan">Hayk Simonyan</a> as a guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://youtube.com/@hayk.simonyan" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TNRZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 424w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 848w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 1272w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TNRZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png" width="1456" height="600" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:387657,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://youtube.com/@hayk.simonyan&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/188825279?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!TNRZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 424w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 848w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 1272w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.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 role="img" 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><title></title><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>He&#8217;s a senior software engineer specializing in helping developers break through their career plateaus and secure senior roles.</p><p>If you want to master the essential system design skills and land senior developer roles, I highly recommend checking out Hayk&#8217;s <strong><a href="https://youtube.com/@hayk.simonyan">YouTube channel</a></strong>.</p><p>His approach focuses on what top employers actually care about: system design expertise, advanced project experience, and elite-level interview performance.</p><div><hr></div><h2><strong>What is Object Storage?</strong></h2><p>Before we design anything, we need to understand what object storage actually is&#8230;</p><p>Engineers often confuse the three main storage categories. Each one exists for a reason, and choosing the wrong one at design time is expensive to fix later.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eRmE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe80ed2-8937-4208-b353-e12f8908ef15_1600x906.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eRmE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe80ed2-8937-4208-b353-e12f8908ef15_1600x906.png 424w, https://substackcdn.com/image/fetch/$s_!eRmE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe80ed2-8937-4208-b353-e12f8908ef15_1600x906.png 848w, https://substackcdn.com/image/fetch/$s_!eRmE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe80ed2-8937-4208-b353-e12f8908ef15_1600x906.png 1272w, https://substackcdn.com/image/fetch/$s_!eRmE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe80ed2-8937-4208-b353-e12f8908ef15_1600x906.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eRmE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe80ed2-8937-4208-b353-e12f8908ef15_1600x906.png" width="1456" height="824" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8fe80ed2-8937-4208-b353-e12f8908ef15_1600x906.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:824,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!eRmE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe80ed2-8937-4208-b353-e12f8908ef15_1600x906.png 424w, https://substackcdn.com/image/fetch/$s_!eRmE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe80ed2-8937-4208-b353-e12f8908ef15_1600x906.png 848w, https://substackcdn.com/image/fetch/$s_!eRmE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe80ed2-8937-4208-b353-e12f8908ef15_1600x906.png 1272w, https://substackcdn.com/image/fetch/$s_!eRmE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe80ed2-8937-4208-b353-e12f8908ef15_1600x906.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 role="img" 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><title></title><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>Block Storage</strong></h3><p>Block storage is the oldest and lowest-level.</p><p>When you plug a hard drive or SSD into a server, the operating system (<strong>OS</strong>) sees it as a sequence of raw blocks, each typically 4KB in size. The OS decides how to format those blocks and build a file system on top of them. Some applications, such as databases and virtual machine engines, skip the file system entirely and manage blocks directly, which gives them maximum control and performance.</p><p>Block storage doesn&#8217;t have to be physically attached&#8230;</p><p>You can connect to block storage over a network using protocols like Fibre Channel or iSCSI<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>. The server still sees raw blocks, as if the drive were directly attached, but the data resides elsewhere on the network. This is how cloud providers like AWS offer Elastic Block Store (<strong>EBS</strong>): you attach a network drive to your VM, and it behaves like a local disk.</p><p>Block storage is fast and flexible, but it&#8217;s also expensive and doesn&#8217;t scale cheaply to petabytes.</p><h3><strong>File Storage</strong></h3><p>File storage is built on top of block storage.</p><p>It adds a layer that handles the complexity of managing blocks and gives you a familiar directory hierarchy: folders, subfolders, and files. You don&#8217;t deal with blocks at all. You just read and write files using paths like <code>/documents/report.pdf.</code></p><p>File storage becomes especially useful when many servers need to share the same files.</p><p>Protocols like NFS and SMB/CIFS<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a> allow many machines to mount the same file share and read and write to it concurrently. This is how shared drives inside organizations typically work, and it&#8217;s how many legacy enterprise applications store data.</p><p>File storage is easier to use than block storage, but it still doesn&#8217;t scale to the level object storage does. Hierarchical directory structures become slow and complex when you have billions of files.</p><h3><strong>Object Storage</strong></h3><p>Object storage is the newest of the three and the most different&#8230;</p><p>It makes a deliberate tradeoff: <em>give up performance and mutability in exchange for near-unlimited scalability, very high durability, and low cost.</em></p><p>There are no directories in object storage.</p><p>Everything lives in a flat namespace inside containers called buckets. Every object is accessed via a RESTful HTTP API using a unique key. You can&#8217;t partially update an object. If you want to change a file, you replace the entire object or create a new version. This immutability<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a> constraint sounds limiting, but it&#8217;s actually what makes object storage so cheap to operate at scale, because it simplifies replication and consistency considerably.</p><p>AWS S3, Google Cloud Storage, and Azure Blob Storage are all object storage systems. They&#8217;re the foundation of most modern cloud architectures: video files, backups, data lake storage, machine learning datasets, static website assets, and more.</p><h3><strong>Comparison Table</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bk1n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe044726-8beb-4aec-bc25-468b5794d782_1600x379.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bk1n!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe044726-8beb-4aec-bc25-468b5794d782_1600x379.png 424w, https://substackcdn.com/image/fetch/$s_!bk1n!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe044726-8beb-4aec-bc25-468b5794d782_1600x379.png 848w, https://substackcdn.com/image/fetch/$s_!bk1n!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe044726-8beb-4aec-bc25-468b5794d782_1600x379.png 1272w, https://substackcdn.com/image/fetch/$s_!bk1n!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe044726-8beb-4aec-bc25-468b5794d782_1600x379.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bk1n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe044726-8beb-4aec-bc25-468b5794d782_1600x379.png" width="1456" height="345" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/be044726-8beb-4aec-bc25-468b5794d782_1600x379.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:345,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!bk1n!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe044726-8beb-4aec-bc25-468b5794d782_1600x379.png 424w, https://substackcdn.com/image/fetch/$s_!bk1n!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe044726-8beb-4aec-bc25-468b5794d782_1600x379.png 848w, https://substackcdn.com/image/fetch/$s_!bk1n!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe044726-8beb-4aec-bc25-468b5794d782_1600x379.png 1272w, https://substackcdn.com/image/fetch/$s_!bk1n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe044726-8beb-4aec-bc25-468b5794d782_1600x379.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The key constraint to internalize: objects are immutable.</p><p>You cannot edit part of an object. You replace the whole thing, or you version it. This constraint is not an accident. It&#8217;s a deliberate design choice that enables the durability and scale properties that make object storage useful in the first place.</p><div><hr></div><h2><strong>Key Terms</strong></h2><p>These are the concepts you need to know before we get into the design:</p><h3><strong>Bucket</strong></h3><p>A bucket is a logical container for objects.</p><p>Think of it like a top-level folder, except it&#8217;s not really a folder since there&#8217;s no hierarchy inside it. Bucket names must be globally unique across all system users, not just within your account.</p><p>You have to create a bucket before you can store anything in it.</p><h3><strong>Object</strong></h3><p>An object is an individual piece of data stored in a bucket.</p><p>It has two parts:</p><ul><li><p>Payload is the actual data bytes, which can be anything: a photo, a video, a CSV file, a binary blob.</p></li><li><p>Metadata is a set of key-value pairs that describe an object, such as content type, creation timestamp, custom tags, and anything else the application needs to store alongside the data.</p></li></ul><p>The metadata is stored separately from the payload and is much smaller.</p><h3><strong>Object Key</strong></h3><p>Every object is identified by a key, which is just a string.</p><p>In S3, that key looks like a file path: <code>photos/2024/vacation.jpg</code>. But there are no actual directories. The entire string, slashes and all, is just the key. S3 lets you use slashes as a convention to simulate folders, but under the hood, it&#8217;s still a flat namespace.</p><p>This distinction matters when we design the listing feature later.</p><h3><strong>Versioning</strong></h3><p>Versioning is a bucket-level feature that keeps all previous versions of an object instead of overwriting them.</p><p>When versioning is enabled, uploading an object with the same key as an existing object doesn&#8217;t replace it. Instead, it creates a new version alongside the old one. You can retrieve, restore, or delete any version at any time.</p><p>This protects against accidental overwrites and deletions.</p><h3><strong>Durability SLA</strong></h3><p>S3 Standard storage class is designed for 99.999999999% durability, also known as eleven nines.</p><p>In practical terms, if you store 10 million objects for 10,000 years, you&#8217;d expect to lose one. That&#8217;s not an accident. It comes from specific engineering decisions around replication and error correction, which we&#8217;ll get into in the durability section.</p><div><hr></div><h2><strong>Clarifying Requirements</strong></h2><p>Before touching any design, you need to understand what you&#8217;re actually building and at what scale. Candidates who skip this step in interviews fail immediately, because they end up designing the wrong thing at the wrong scale&#8230;</p><h3><strong>Questions to Ask</strong></h3><ul><li><p>What are the core operations? Upload, download, delete, list?</p></li><li><p>Do we need versioning?</p></li><li><p>How much data do we need to store in year one?</p></li><li><p>What durability and availability targets do we need?</p></li><li><p>Do we need to support large file uploads, such as files over multiple gigabytes?</p></li><li><p>Any access control requirements? Do different users own different buckets?</p></li></ul><h3><strong>Our Assumptions</strong></h3><p>For this design, we&#8217;ll assume:</p><ul><li><p>Core operations: bucket creation, object upload and download, object versioning, and listing objects in a bucket by prefix</p></li><li><p>100 petabytes of total data</p></li><li><p>Durability target: six nines, which is 99.9999%</p></li><li><p>Availability target: four nines, which is 99.99%</p></li><li><p>Must handle both small objects (tens of kilobytes) and large objects (several gigabytes)</p></li></ul><p>Now, let&#8217;s figure out what these requirements actually mean for infrastructure&#8230;</p><div><hr></div><h2><strong>Capacity Estimation</strong></h2><p>Math matters in system design because it tells you what kind of infrastructure you need. Vague statements like <em>&#8220;we&#8217;ll need a distributed database&#8221;</em> aren&#8217;t useful without concrete numbers.</p><p>Let&#8217;s work through the estimates:</p><h3><strong>Object Size Distribution</strong></h3><p>In practice, object storage systems see a mix of object sizes. A reasonable assumption for a general-purpose system:</p><ul><li><p>20% of objects are small, under 1MB, with a median size of about 0.5MB. These might be thumbnails, config files, or short documents.</p></li><li><p>60% of objects are medium-sized, ranging from 1MB to 64MB, with a median of about 32MB. These might be images, audio files, or compressed datasets.</p></li><li><p>20% of objects are large (&gt;64MB), with a median of about 200MB. These might be videos, database backups, or large archives.</p></li></ul><h3><strong>Total Object Count</strong></h3><p>We&#8217;re targeting 100 petabytes of stored data.</p><p>In practice, storage systems don&#8217;t fill to capacity, so let&#8217;s assume 40% utilization, meaning we provision enough storage to hold 100PB when 40% full.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;9f89fa67-a6d0-4507-9c79-287873746c8a&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">100 PB = 10^11 MB

Weighted average object size: (0.2 x 0.5MB) + (0.6 x 32MB) + (0.2 x 200MB)

= 0.1 + 19.2 + 40.0

= 59.3 MB per object (average)

Total objects at 40% utilization: (10^11 x 0.4) / 59.3

= approximately 680 million objects</code></pre></div><p>680 million objects are a lot.</p><p>This tells us immediately that no single machine can store or index all of this. We need distributed storage and a distributed metadata index from day one.</p><h3><strong>Metadata Storage</strong></h3><p>Each object needs a metadata record. If we assume roughly 1KB per record (object name, bucket, timestamps, UUID, tags), then:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;c68210ce-24dd-409c-a907-a5f0d5b3a41c&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">680 million objects x 1KB = ~680GB of metadata</code></pre></div><p>680GB of metadata is manageable in a database, but the access patterns will require sharding as we scale. The metadata store is separate from the data store, which we&#8217;ll cover in the design.</p><h3><strong>IOPS Constraints</strong></h3><p>A standard SATA hard drive<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-5" href="#footnote-5" target="_self">5</a> spinning at 7200 RPM can handle roughly 100-150 random seeks per second.</p><p>This is called IOPS<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-6" href="#footnote-6" target="_self">6</a>, or input/output operations per second. At 680 million objects spread across many disks, the IOPS constraint becomes a real bottleneck, especially for small object workloads where you&#8217;re doing many small reads and writes rather than a few large sequential ones.</p><p>This is one reason we&#8217;ll later choose to merge many small objects into a single larger file on disk, instead of storing each object as its own file.</p><div><hr></div><h2><strong>Design Philosophy: Separating Metadata from Data</strong></h2><p>Before we look at the full architecture, there&#8217;s one core design principle that shapes everything else:<em> metadata and data are stored separately, and for good reason.</em></p><p>This idea comes from how UNIX file systems work:</p><p>In UNIX, when you save a file, the filename and the actual data bytes are not stored together. The filename and other file information (size, permissions, timestamps, disk location) live in a data structure called an inode<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-7" href="#footnote-7" target="_self">7</a>. The actual data bytes live in separate disk blocks that the inode points to.</p><p>Object storage works the same way.</p><p>The metadata store is like the inode layer. It holds the object name, bucket, size, and a UUID that points to the location of the actual bytes. The data store is like the disk. It holds the raw bytes, and it only knows about UUIDs, not names or paths.</p><p>So why separate them?</p><p>Because they have completely different characteristics. The data is immutable. Once written, it never changes. The metadata is mutable. You can update tags, rename objects (in some implementations), or add versioning records. They need different consistency guarantees, different storage engines, and different scaling strategies.</p><p>Keeping them separate lets us optimize each independently.</p><div><hr></div><h2><strong>High-Level Architecture</strong></h2><p>With that principle in mind, here&#8217;s how the full system is structured:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BBL9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ac43646-5c7a-439d-bac8-76dad7c2ae21_1600x1553.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BBL9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ac43646-5c7a-439d-bac8-76dad7c2ae21_1600x1553.png 424w, https://substackcdn.com/image/fetch/$s_!BBL9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ac43646-5c7a-439d-bac8-76dad7c2ae21_1600x1553.png 848w, https://substackcdn.com/image/fetch/$s_!BBL9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ac43646-5c7a-439d-bac8-76dad7c2ae21_1600x1553.png 1272w, https://substackcdn.com/image/fetch/$s_!BBL9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ac43646-5c7a-439d-bac8-76dad7c2ae21_1600x1553.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BBL9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ac43646-5c7a-439d-bac8-76dad7c2ae21_1600x1553.png" width="1456" height="1413" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ac43646-5c7a-439d-bac8-76dad7c2ae21_1600x1553.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1413,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!BBL9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ac43646-5c7a-439d-bac8-76dad7c2ae21_1600x1553.png 424w, https://substackcdn.com/image/fetch/$s_!BBL9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ac43646-5c7a-439d-bac8-76dad7c2ae21_1600x1553.png 848w, https://substackcdn.com/image/fetch/$s_!BBL9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ac43646-5c7a-439d-bac8-76dad7c2ae21_1600x1553.png 1272w, https://substackcdn.com/image/fetch/$s_!BBL9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ac43646-5c7a-439d-bac8-76dad7c2ae21_1600x1553.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 role="img" 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><title></title><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>Components</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ccAA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66ba3358-bf5a-4462-9ad0-9e84be6f0fd3_1600x716.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ccAA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66ba3358-bf5a-4462-9ad0-9e84be6f0fd3_1600x716.png 424w, https://substackcdn.com/image/fetch/$s_!ccAA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66ba3358-bf5a-4462-9ad0-9e84be6f0fd3_1600x716.png 848w, https://substackcdn.com/image/fetch/$s_!ccAA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66ba3358-bf5a-4462-9ad0-9e84be6f0fd3_1600x716.png 1272w, https://substackcdn.com/image/fetch/$s_!ccAA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66ba3358-bf5a-4462-9ad0-9e84be6f0fd3_1600x716.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ccAA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66ba3358-bf5a-4462-9ad0-9e84be6f0fd3_1600x716.png" width="1456" height="652" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/66ba3358-bf5a-4462-9ad0-9e84be6f0fd3_1600x716.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:652,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!ccAA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66ba3358-bf5a-4462-9ad0-9e84be6f0fd3_1600x716.png 424w, https://substackcdn.com/image/fetch/$s_!ccAA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66ba3358-bf5a-4462-9ad0-9e84be6f0fd3_1600x716.png 848w, https://substackcdn.com/image/fetch/$s_!ccAA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66ba3358-bf5a-4462-9ad0-9e84be6f0fd3_1600x716.png 1272w, https://substackcdn.com/image/fetch/$s_!ccAA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66ba3358-bf5a-4462-9ad0-9e84be6f0fd3_1600x716.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 role="img" 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><title></title><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>Upload Flow</strong></h3><p>Let&#8217;s trace exactly what happens when a user uploads a file named <code>report.pdf</code> to a bucket called <code>company-docs</code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6Ae2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8ba7f28-260d-4063-b9e0-64dabd429ea1_1600x1262.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6Ae2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8ba7f28-260d-4063-b9e0-64dabd429ea1_1600x1262.png 424w, https://substackcdn.com/image/fetch/$s_!6Ae2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8ba7f28-260d-4063-b9e0-64dabd429ea1_1600x1262.png 848w, https://substackcdn.com/image/fetch/$s_!6Ae2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8ba7f28-260d-4063-b9e0-64dabd429ea1_1600x1262.png 1272w, https://substackcdn.com/image/fetch/$s_!6Ae2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8ba7f28-260d-4063-b9e0-64dabd429ea1_1600x1262.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6Ae2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8ba7f28-260d-4063-b9e0-64dabd429ea1_1600x1262.png" width="1456" height="1148" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d8ba7f28-260d-4063-b9e0-64dabd429ea1_1600x1262.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1148,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!6Ae2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8ba7f28-260d-4063-b9e0-64dabd429ea1_1600x1262.png 424w, https://substackcdn.com/image/fetch/$s_!6Ae2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8ba7f28-260d-4063-b9e0-64dabd429ea1_1600x1262.png 848w, https://substackcdn.com/image/fetch/$s_!6Ae2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8ba7f28-260d-4063-b9e0-64dabd429ea1_1600x1262.png 1272w, https://substackcdn.com/image/fetch/$s_!6Ae2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8ba7f28-260d-4063-b9e0-64dabd429ea1_1600x1262.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 role="img" 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><title></title><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><ol><li><p>Client sends a <code>HTTP PUT /company-docs/report.pdf</code> request with the file bytes in the request body.</p></li><li><p>Request hits the load balancer and gets routed to one of the API service instances.</p></li><li><p>API service calls the IAM service<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-8" href="#footnote-8" target="_self">8</a> to confirm the user has WRITE permission on the <code>company-docs</code> bucket. If not, the request is rejected immediately with a 403 Forbidden.</p></li><li><p>API service forwards the file bytes to the data store. The data store persists the bytes and returns a UUID, a unique identifier for this specific object.</p></li><li><p>API service then writes a metadata record to the metadata store. This record contains the object name (<code>report.pdf</code>), bucket ID, UUID returned from the data store, file size, creation timestamp, and any metadata tags the user provided.</p></li><li><p>A <code>200 OK</code> response is returned to the client.</p></li></ol><p>The metadata record now serves as the bridge between the human-readable path (<code>company-docs/report.pdf</code>) and the actual bytes stored under the UUID in the data store.</p><h3><strong>Download Flow</strong></h3><p>Now, let&#8217;s trace what happens when someone requests the same file:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ySqR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01ea95e6-c6ae-4944-b89b-80817ef6c827_1600x1282.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ySqR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01ea95e6-c6ae-4944-b89b-80817ef6c827_1600x1282.png 424w, https://substackcdn.com/image/fetch/$s_!ySqR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01ea95e6-c6ae-4944-b89b-80817ef6c827_1600x1282.png 848w, https://substackcdn.com/image/fetch/$s_!ySqR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01ea95e6-c6ae-4944-b89b-80817ef6c827_1600x1282.png 1272w, https://substackcdn.com/image/fetch/$s_!ySqR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01ea95e6-c6ae-4944-b89b-80817ef6c827_1600x1282.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ySqR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01ea95e6-c6ae-4944-b89b-80817ef6c827_1600x1282.png" width="1456" height="1167" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/01ea95e6-c6ae-4944-b89b-80817ef6c827_1600x1282.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1167,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!ySqR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01ea95e6-c6ae-4944-b89b-80817ef6c827_1600x1282.png 424w, https://substackcdn.com/image/fetch/$s_!ySqR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01ea95e6-c6ae-4944-b89b-80817ef6c827_1600x1282.png 848w, https://substackcdn.com/image/fetch/$s_!ySqR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01ea95e6-c6ae-4944-b89b-80817ef6c827_1600x1282.png 1272w, https://substackcdn.com/image/fetch/$s_!ySqR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01ea95e6-c6ae-4944-b89b-80817ef6c827_1600x1282.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 role="img" 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><title></title><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><ol><li><p>Client sends a <code>GET /company-docs/report.pdf</code> request.</p></li><li><p>API service calls IAM to verify READ permission.</p></li><li><p>API service queries the metadata store: <em>&#8220;What is the UUID for the object named report.pdf in the bucket company-docs?&#8221;</em></p></li><li><p>API service then uses that UUID to fetch the actual bytes from the data store.</p></li><li><p>The bytes get returned to the client.</p></li></ol><p>Notice that the data store never knows the file was called <code>report.pdf</code>.</p><p>From its perspective, someone asked for the object with a specific UUID, and it returned the bytes. The translation from name to UUID always happens in the metadata store.</p><div><hr></div><p><em><strong>Reminder: this is a teaser of the subscriber-only newsletter series, exclusive to my golden members.</strong></em></p><p>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>High-level architecture of real-world systems.</strong></p></li><li><p>Deep dive into how popular real-world systems actually work.</p></li><li><p><strong>How real-world systems handle scale, reliability, and performance.</strong></p></li></ul><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><h2><strong>Deep Dive: Data Store</strong></h2><p>The data store is where most of the interesting engineering happens&#8230;</p><p>Let&#8217;s break down its internal architecture:</p><h3><strong>Internal Components</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5Oiu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5faa566c-99a2-4140-8087-253c6a27e6ca_1600x765.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5Oiu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5faa566c-99a2-4140-8087-253c6a27e6ca_1600x765.png 424w, https://substackcdn.com/image/fetch/$s_!5Oiu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5faa566c-99a2-4140-8087-253c6a27e6ca_1600x765.png 848w, https://substackcdn.com/image/fetch/$s_!5Oiu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5faa566c-99a2-4140-8087-253c6a27e6ca_1600x765.png 1272w, https://substackcdn.com/image/fetch/$s_!5Oiu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5faa566c-99a2-4140-8087-253c6a27e6ca_1600x765.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5Oiu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5faa566c-99a2-4140-8087-253c6a27e6ca_1600x765.png" width="1456" height="696" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5faa566c-99a2-4140-8087-253c6a27e6ca_1600x765.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:696,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!5Oiu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5faa566c-99a2-4140-8087-253c6a27e6ca_1600x765.png 424w, https://substackcdn.com/image/fetch/$s_!5Oiu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5faa566c-99a2-4140-8087-253c6a27e6ca_1600x765.png 848w, https://substackcdn.com/image/fetch/$s_!5Oiu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5faa566c-99a2-4140-8087-253c6a27e6ca_1600x765.png 1272w, https://substackcdn.com/image/fetch/$s_!5Oiu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5faa566c-99a2-4140-8087-253c6a27e6ca_1600x765.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 role="img" 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><title></title><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><h4><strong>Data Routing Service</strong></h4><p>The data routing service is the entry point into the data store&#8230;</p><p>It&#8217;s stateless, meaning it holds no state itself, so you can scale it horizontally by adding more instances. When a <em>write</em> comes in, the placement service determines which data node should receive the data, then sends the data there.</p><p>When a <em>read</em> comes in, it asks the placement service where the data lives, then fetches it.</p><h4><strong>Placement Service</strong></h4><p>The placement service<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-9" href="#footnote-9" target="_self">9</a> is responsible for knowing the physical layout of the entire storage cluster&#8230;</p><p>It maintains a virtual cluster map<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-10" href="#footnote-10" target="_self">10</a>, which is essentially a registry of every data node, including the rack and availability zone it&#8217;s in, how many disks it has, and how much space is used on each disk.</p><p>Placement service continuously receives heartbeat messages from every data node.</p><p>A heartbeat is a small message a node sends every few seconds, saying, <em>&#8220;I&#8217;m alive, here&#8217;s my current state.&#8221;</em> If the placement service doesn&#8217;t hear from a node within a configurable grace period (typically 15 seconds), it marks that node as down and stops sending new data to it.</p><p>Because the placement service is so critical, you run it as a cluster of 5 or 7 nodes using a consensus algorithm<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-11" href="#footnote-11" target="_self">11</a> like Raft or Paxos.</p><p>A consensus algorithm ensures the cluster agrees on a single consistent view of the world, even if some nodes fail. With a 7-node cluster, you can lose 3 nodes simultaneously, and the service keeps running. With a 5-node cluster, you can lose 2. You never run this as a single instance, because if it goes down, the entire storage cluster becomes unavailable for writes.</p><h4><strong>Data Nodes</strong></h4><p>Data nodes are where the actual bytes live&#8230;</p><p>Each data node manages one or more physical disks. Each node runs a daemon process that sends heartbeats to the placement service with information about disk count and available space. When the placement service receives a heartbeat from a new node it hasn&#8217;t seen before, it assigns that node an ID, adds it to the virtual cluster map, and tells the node where to replicate data.</p><p>Durability is the central promise of object storage and the hardest engineering problem in this design.</p><p>We'll get there.</p><p>But before we can talk about how data survives hardware failures and entire node outages, we need to understand exactly how a write moves through this system.</p><p>The decisions made in the next few steps determine whether durability can be guaranteed&#8230;</p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/aws-s3-system-design">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The 53 Concepts for Highly Effective Mobile System Design]]></title><description><![CDATA[#135: Part 1 - Client-Server Architecture, Push Notifications, Offline-First, and 16 others.]]></description><link>https://newsletter.systemdesign.one/p/mobile-system-design</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/mobile-system-design</guid><dc:creator><![CDATA[Shefali Jangid]]></dc:creator><pubDate>Wed, 25 Mar 2026 15:28:41 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/6c0254e3-929f-4131-9c21-1ba491cc0bb3_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/mobile-system-design/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>Since people are always asking me for more &#8220;practical&#8221; system design content:</p><p>Following is the free edition of a <em>premium</em> 3-part newsletter series... This covers how mobile apps work under the hood. And it&#8217;s explained in a simple, realistic, and useful way.</p><p>On with part 1 of the newsletter:</p><div><hr></div><h3><strong><a href="https://blog.sentry.io/monitoring-microservices-distributed-systems-with-sentry/?utm_source=systemdesign&amp;utm_medium=paid-community&amp;utm_campaign=debugging-fy27q1-microservices&amp;utm_content=newsletter-primary-microservices-blog-learnmore">Trying to debug a request that touched 5 services? (Partner)</a></strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://blog.sentry.io/monitoring-microservices-distributed-systems-with-sentry/?utm_source=systemdesign&amp;utm_medium=paid-community&amp;utm_campaign=debugging-fy27q1-microservices&amp;utm_content=newsletter-primary-microservices-blog-learnmore" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_dcB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44a91a4e-b8d3-4c6c-84f3-4acab1b4eddf_2520x945.jpeg 424w, https://substackcdn.com/image/fetch/$s_!_dcB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44a91a4e-b8d3-4c6c-84f3-4acab1b4eddf_2520x945.jpeg 848w, https://substackcdn.com/image/fetch/$s_!_dcB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44a91a4e-b8d3-4c6c-84f3-4acab1b4eddf_2520x945.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!_dcB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44a91a4e-b8d3-4c6c-84f3-4acab1b4eddf_2520x945.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_dcB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44a91a4e-b8d3-4c6c-84f3-4acab1b4eddf_2520x945.jpeg" width="1456" height="546" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/44a91a4e-b8d3-4c6c-84f3-4acab1b4eddf_2520x945.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:546,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:181803,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:&quot;https://blog.sentry.io/monitoring-microservices-distributed-systems-with-sentry/?utm_source=systemdesign&amp;utm_medium=paid-community&amp;utm_campaign=debugging-fy27q1-microservices&amp;utm_content=newsletter-primary-microservices-blog-learnmore&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/191673121?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44a91a4e-b8d3-4c6c-84f3-4acab1b4eddf_2520x945.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_dcB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44a91a4e-b8d3-4c6c-84f3-4acab1b4eddf_2520x945.jpeg 424w, https://substackcdn.com/image/fetch/$s_!_dcB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44a91a4e-b8d3-4c6c-84f3-4acab1b4eddf_2520x945.jpeg 848w, https://substackcdn.com/image/fetch/$s_!_dcB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44a91a4e-b8d3-4c6c-84f3-4acab1b4eddf_2520x945.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!_dcB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44a91a4e-b8d3-4c6c-84f3-4acab1b4eddf_2520x945.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 role="img" 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><title></title><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>Distributed systems help you move faster&#8230;until you have to debug them.</p><p>This <a href="https://blog.sentry.io/monitoring-microservices-distributed-systems-with-sentry/?utm_source=systemdesign&amp;utm_medium=paid-community&amp;utm_campaign=debugging-fy27q1-microservices&amp;utm_content=newsletter-primary-microservices-blog-learnmore">blog</a> shows how to use Sentry tracing and logging to follow a request end-to-end. You don&#8217;t need prior microservices experience to follow these steps.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://blog.sentry.io/monitoring-microservices-distributed-systems-with-sentry/?utm_source=systemdesign&amp;utm_medium=paid-community&amp;utm_campaign=debugging-fy27q1-microservices&amp;utm_content=newsletter-primary-microservices-blog-learnmore&quot;,&quot;text&quot;:&quot;Read the blog and start fixing&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://blog.sentry.io/monitoring-microservices-distributed-systems-with-sentry/?utm_source=systemdesign&amp;utm_medium=paid-community&amp;utm_campaign=debugging-fy27q1-microservices&amp;utm_content=newsletter-primary-microservices-blog-learnmore"><span>Read the blog and start fixing</span></a></p><p>(Thanks to <a href="https://blog.sentry.io/monitoring-microservices-distributed-systems-with-sentry/?utm_source=systemdesign&amp;utm_medium=paid-community&amp;utm_campaign=debugging-fy27q1-microservices&amp;utm_content=newsletter-primary-microservices-blog-learnmore">Sentry</a> for partnering on this post.)</p><div><hr></div><p>I want to reintroduce <a href="https://x.com/Shefali__J">Shefali Jangid</a> as a guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://x.com/Shefali__J" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9raK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd58707-3a96-4850-a5f0-6e3bd8429d06_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!9raK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd58707-3a96-4850-a5f0-6e3bd8429d06_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!9raK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd58707-3a96-4850-a5f0-6e3bd8429d06_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!9raK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd58707-3a96-4850-a5f0-6e3bd8429d06_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9raK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd58707-3a96-4850-a5f0-6e3bd8429d06_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/acd58707-3a96-4850-a5f0-6e3bd8429d06_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;:152918,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://x.com/Shefali__J&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/178020218?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd58707-3a96-4850-a5f0-6e3bd8429d06_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!9raK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd58707-3a96-4850-a5f0-6e3bd8429d06_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!9raK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd58707-3a96-4850-a5f0-6e3bd8429d06_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!9raK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd58707-3a96-4850-a5f0-6e3bd8429d06_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!9raK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd58707-3a96-4850-a5f0-6e3bd8429d06_1200x630.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 role="img" 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><title></title><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>She&#8217;s a web developer, technical writer, and content creator with a love for frontend architecture and building things that scale.</p><p>Check out her work and socials:</p><ul><li><p><a href="https://shefali.dev/">Shefali.dev</a></p></li><li><p><a href="https://github.com/WebdevShefali">GitHub</a></p></li><li><p><a href="https://x.com/Shefali__J">Twitter</a></p></li></ul><p>You&#8217;ll often find her writing about web development, sharing UI tips, and building tools that make developers&#8217; lives easier.</p><div><hr></div><p>Building &#8220;scalable mobile apps&#8221; is not just about writing frontend code and calling APIs&#8230;</p><p>It&#8217;s actually one of the toughest parts of software engineering!</p><p>Mobile apps don&#8217;t run in ideal environments. The network can go down, batteries run low, the operating system can close your app in the background, devices vary, and users still expect everything to work instantly, even offline.</p><p>When building mobile apps, you always have to think about limits. Every decision affects speed, stability, data safety, security, and user experience simultaneously. And making the right choices turns a simple app into a strong, production-ready package.</p><p>In this newsletter, we&#8217;ll focus on 19 concepts as the foundation:</p><ol><li><p>Client-Server Architecture,</p></li><li><p>WebSockets &amp; Persistent Connections,</p></li><li><p>Push Notifications,</p></li><li><p>Polling, Long Polling &amp; SSE,</p></li><li><p>REST vs GraphQL vs gRPC,</p></li><li><p>Network Resilience,</p></li><li><p>Idempotency in APIs,</p></li><li><p>Request Batching &amp; Payload Optimisation,</p></li><li><p>Resumable Uploads,</p></li><li><p>Handling Intermittent Connectivity,</p></li><li><p>On-Device Caching,</p></li><li><p>HTTP Caching (ETag, Cache-Control),</p></li><li><p>Offline-First Architecture,</p></li><li><p>CDN Strategy &amp; Media Optimisation,</p></li><li><p>Cache Invalidation Strategies,</p></li><li><p>Local Database Design,</p></li><li><p>Schema Migration Strategy,</p></li><li><p>Pagination (Cursor vs Offset vs Page Number),</p></li><li><p>Data Modeling for Mobile Constraints.</p></li></ol><p>(&#8230;and much more in parts 2 &amp; 3!)</p><p>For each concept, I&#8217;ll cover:</p><ul><li><p>What it is and how it works</p></li><li><p>Real-world example</p></li><li><p>The tradeoffs</p></li><li><p>Why it matters for mobile</p></li></ul><p>But before we get into the concepts, let&#8217;s first understand what mobile system design really means&#8230;</p><h4><strong>What is Mobile System Design?</strong></h4><p>Mobile system design is about planning how a mobile app works in the background.</p><p>It includes how the app connects to servers, saves and reads data, stays fast, keeps user data safe, and handles errors.</p><p>It&#8217;s not just about designing screens. It&#8217;s about understanding how data flows within the app, what happens when the network goes down, how the app runs in the background, and how it works across different devices.</p><p>Now that we understand what mobile system design means, let&#8217;s start with one of the most important parts: <em>how your app connects and communicates with the outside world.</em></p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get the full premium newsletter series and max your system design career leverage:</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><hr></div><h1><strong>Networking &amp; Real-Time Communication</strong></h1><p>This section explains how a mobile app connects to servers and handles real-time data&#8230;</p><p>You&#8217;ll learn how apps send and receive data, choose the right APIs, and handle slow or unstable networks so the app stays fast and reliable.</p><h3><strong>1. Client-Server Architecture (Thick vs Thin Clients)</strong></h3><p>When building a mobile app, an important question to ask is: <em>how much work should the phone handle, and how much should the server do?</em></p><p>There are two main approaches:</p><p><strong>a. Thick Client</strong></p><p>A thick client means the app does most of the work on the device.</p><p>It can:</p><ul><li><p>Save data on the phone</p></li><li><p>Handle some logic by itself</p></li><li><p>Sync data later in the background</p></li><li><p>Work without network connectivity</p></li></ul><p>Most modern apps use this approach because:</p><ul><li><p>The network is not always stable</p></li><li><p>Phones are powerful now</p></li><li><p>Users expect apps to work offline</p></li></ul><p><strong>b. Thin Client</strong></p><p>A thin client means the app does very little on the device.</p><p>It:</p><ul><li><p>Sends requests to the server</p></li><li><p>Waits for the server to process everything</p></li><li><p>Shows whatever the server returns</p></li></ul><p>If the network fails, the app mostly stops working.</p><h4><strong>Why It Matters</strong></h4><p>This decision affects your entire app design:</p><ul><li><p>Whether your app can work offline</p></li><li><p>How difficult syncing will be</p></li><li><p>How easily you can update features</p></li><li><p>How much important logic stays on the server</p></li></ul><h4><strong>Real-World Example</strong></h4><ul><li><p>Gmail is a &#8220;thick&#8221; client. You can read emails and write drafts even without network connectivity. It syncs later.</p></li><li><p>A simple app that only loads a website is a thin client. It&#8217;s useless without the network.</p></li></ul><h4><strong>Trade-offs</strong></h4><ul><li><p><strong>Thick client:</strong> Faster and works offline, but syncing and updates can be harder.</p></li><li><p><strong>Thin client:</strong> Easy to update and simpler to build, but it doesn&#8217;t work well with a bad network.</p></li></ul><h4><strong>Practical Advice</strong></h4><p>For most apps:</p><ul><li><p>Keep the main app logic thick (use local storage and background sync).</p></li><li><p>Keep sensitive logic on the server (like payments, login, pricing, fraud detection).</p></li></ul><p>This gives you the best balance between speed, reliability, and security.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-Iek!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be310ca-6d34-4958-ac62-e0634722213b_1600x716.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-Iek!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be310ca-6d34-4958-ac62-e0634722213b_1600x716.png 424w, https://substackcdn.com/image/fetch/$s_!-Iek!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be310ca-6d34-4958-ac62-e0634722213b_1600x716.png 848w, https://substackcdn.com/image/fetch/$s_!-Iek!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be310ca-6d34-4958-ac62-e0634722213b_1600x716.png 1272w, https://substackcdn.com/image/fetch/$s_!-Iek!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be310ca-6d34-4958-ac62-e0634722213b_1600x716.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-Iek!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be310ca-6d34-4958-ac62-e0634722213b_1600x716.png" width="1456" height="652" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0be310ca-6d34-4958-ac62-e0634722213b_1600x716.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:652,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!-Iek!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be310ca-6d34-4958-ac62-e0634722213b_1600x716.png 424w, https://substackcdn.com/image/fetch/$s_!-Iek!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be310ca-6d34-4958-ac62-e0634722213b_1600x716.png 848w, https://substackcdn.com/image/fetch/$s_!-Iek!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be310ca-6d34-4958-ac62-e0634722213b_1600x716.png 1272w, https://substackcdn.com/image/fetch/$s_!-Iek!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be310ca-6d34-4958-ac62-e0634722213b_1600x716.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 role="img" 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><title></title><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>Once you decide what the app and the server should handle, the next question to ask is: <em>How they should communicate, especially when you need real-time updates?</em></p><h3><strong>2. WebSockets &amp; Persistent Connections</strong></h3><p>Usually, mobile apps use HTTP requests to talk to a server.</p><p>That means:</p><ol><li><p>App asks for data</p></li><li><p>Server sends a response</p></li><li><p>Connection closes</p></li></ol><p>If the app needs new data, it has to ask again.</p><p><em>WebSocket</em> <em>works differently&#8230;</em></p><p>It creates a long-lasting connection between the app and the server.</p><p>Once connected:</p><ul><li><p>App can send data anytime</p></li><li><p>Server can also send data anytime</p></li><li><p>Connection stays open</p></li></ul><p>This is called <strong>real-time communication</strong>.</p><h4><strong>Why It Matters</strong></h4><p>With normal HTTP, the app must keep asking:</p><ul><li><p><em>&#8220;Any new messages?&#8221;</em></p></li><li><p><em>&#8220;Any updates?&#8221;</em></p></li></ul><p>With WebSockets, the server sends updates immediately when something happens.</p><p>This is very important for:</p><ul><li><p>Chat apps</p></li><li><p>Live sports scores</p></li><li><p>Stock price updates</p></li><li><p>Multiplayer games</p></li><li><p>Collaborative tools</p></li></ul><p>If updates are slow, users feel like the app is broken.</p><h4><strong>Real-World Example</strong></h4><p>Apps like Slack, WhatsApp, and Figma use WebSockets.</p><p>When someone sends a message, you see it instantly because the server pushes it directly to your app.</p><h4><strong>Important Things to Remember (For Mobile)</strong></h4><p>On mobile devices, keeping a connection open all the time can drain the battery, use more data, and cause the operating system to close it.</p><p>Instead:</p><ul><li><p>Send small &#8216;heartbeat&#8217; signals to keep it alive</p></li><li><p>Reconnect if the network drops</p></li><li><p>Close the connection when the app goes to the background</p></li></ul><p>Otherwise, the connection may appear active but stop working.</p><h4><strong>How It Works</strong></h4><ol><li><p>App starts with a normal HTTP request.</p></li><li><p>Server upgrades it to a WebSocket connection.</p></li><li><p>After that, both sides can send messages at any time.</p></li><li><p>Connection stays open until one side closes it.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5DET!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f987c94-15ac-4024-9396-64f7a879cdad_1600x706.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5DET!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f987c94-15ac-4024-9396-64f7a879cdad_1600x706.png 424w, https://substackcdn.com/image/fetch/$s_!5DET!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f987c94-15ac-4024-9396-64f7a879cdad_1600x706.png 848w, https://substackcdn.com/image/fetch/$s_!5DET!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f987c94-15ac-4024-9396-64f7a879cdad_1600x706.png 1272w, https://substackcdn.com/image/fetch/$s_!5DET!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f987c94-15ac-4024-9396-64f7a879cdad_1600x706.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5DET!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f987c94-15ac-4024-9396-64f7a879cdad_1600x706.png" width="1456" height="642" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2f987c94-15ac-4024-9396-64f7a879cdad_1600x706.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:642,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!5DET!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f987c94-15ac-4024-9396-64f7a879cdad_1600x706.png 424w, https://substackcdn.com/image/fetch/$s_!5DET!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f987c94-15ac-4024-9396-64f7a879cdad_1600x706.png 848w, https://substackcdn.com/image/fetch/$s_!5DET!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f987c94-15ac-4024-9396-64f7a879cdad_1600x706.png 1272w, https://substackcdn.com/image/fetch/$s_!5DET!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f987c94-15ac-4024-9396-64f7a879cdad_1600x706.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 role="img" 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><title></title><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><h4><strong>Trade-offs</strong></h4><p><strong>Pros</strong></p><ul><li><p>Very fast (low latency)</p></li><li><p>Instant updates</p></li><li><p>Two-way communication</p></li></ul><p><strong>Cons</strong></p><ul><li><p>Harder to manage</p></li><li><p>Needs reconnect logic</p></li><li><p>Can affect the battery if not handled properly</p></li></ul><p>In simple words, use WebSockets when your app needs instant updates. Just manage the connection carefully on mobile devices.</p><p>But not all updates require a constant open connection.</p><p><em>What if the app is completely closed?</em></p><p>That&#8217;s when push notifications become useful&#8230;</p><h3><strong>3. Push Notifications (APNs &amp; FCM)</strong></h3><p>Push notifications let your app send updates, such as <em>&#8220;Your order has been picked up&#8221;, &#8220;You got a new message&#8221;, &#8220;Your payment was successful&#8221;,</em> to users even when the app is closed.</p><p>But here&#8217;s the important part: Your app does not stay connected to your server all the time.</p><p>Instead, special services handle this for you:</p><ul><li><p><a href="https://en.wikipedia.org/wiki/Apple_Push_Notification_service">APNs (Apple Push Notification Service)</a> for iPhones</p></li><li><p><a href="https://firebase.google.com/docs/cloud-messaging">FCM (Firebase Cloud Messaging)</a> for Android</p></li></ul><p>These services act like messengers between your server and the user&#8217;s phone.</p><h4><strong>How It Works</strong></h4><ol><li><p>Something happens on the server (e.g., a new message).</p></li><li><p>Server sends the notification to APNs (iOS) or FCM (Android).</p></li><li><p>APNs/FCM deliver it to the user&#8217;s device.</p></li><li><p>The mobile phone&#8217;s operating system shows the notification.</p></li><li><p>If needed, the app wakes up in the background.</p></li></ol><p>Your app does NOT keep a permanent connection.</p><p>The phone&#8217;s operating system manages a &#8220;single&#8221; shared connection for all apps to conserve battery.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!G0e8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0af50997-a93d-4bdf-bf8c-eacb6bb6ee82_1600x781.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!G0e8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0af50997-a93d-4bdf-bf8c-eacb6bb6ee82_1600x781.png 424w, https://substackcdn.com/image/fetch/$s_!G0e8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0af50997-a93d-4bdf-bf8c-eacb6bb6ee82_1600x781.png 848w, https://substackcdn.com/image/fetch/$s_!G0e8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0af50997-a93d-4bdf-bf8c-eacb6bb6ee82_1600x781.png 1272w, https://substackcdn.com/image/fetch/$s_!G0e8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0af50997-a93d-4bdf-bf8c-eacb6bb6ee82_1600x781.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!G0e8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0af50997-a93d-4bdf-bf8c-eacb6bb6ee82_1600x781.png" width="1456" height="711" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0af50997-a93d-4bdf-bf8c-eacb6bb6ee82_1600x781.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:711,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!G0e8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0af50997-a93d-4bdf-bf8c-eacb6bb6ee82_1600x781.png 424w, https://substackcdn.com/image/fetch/$s_!G0e8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0af50997-a93d-4bdf-bf8c-eacb6bb6ee82_1600x781.png 848w, https://substackcdn.com/image/fetch/$s_!G0e8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0af50997-a93d-4bdf-bf8c-eacb6bb6ee82_1600x781.png 1272w, https://substackcdn.com/image/fetch/$s_!G0e8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0af50997-a93d-4bdf-bf8c-eacb6bb6ee82_1600x781.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 role="img" 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><title></title><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><h4><strong>Why It Matters</strong></h4><p>Without push notifications, your app would need to stay connected all the time and keep checking for new updates. Neither iOS nor Android allows this because it drains battery.</p><p>Push services solve this problem in a battery-efficient way.</p><h4><strong>Real-World Example</strong></h4><p>Imagine a food delivery app. When your order is picked up:</p><ol><li><p>The backend sends a push notification using FCM or APNs.</p></li><li><p>Your phone receives it instantly.</p></li><li><p>Even if the app is fully closed, you still get the update.</p></li></ol><h4><strong>Trade-offs</strong></h4><p><strong>Pros</strong></p><ul><li><p>Saves battery</p></li><li><p>Works even if the app is closed</p></li><li><p>Delivers updates quickly</p></li><li><p>No need for a constant background connection</p></li></ul><p><strong>Cons</strong></p><ul><li><p>Delivery is not 100% guaranteed</p></li><li><p>Can fail on a poor network</p></li><li><p>Limited message size</p></li><li><p>Should not be used for very critical data</p></li></ul><p>You should never assume the user received the notification. Always refresh or sync data when the app opens.</p><h4><strong>Pro Tip</strong></h4><p>You can send a <strong>silent push notification</strong> (background push).</p><p>This shows nothing to the user. It simply wakes the app in the background to fetch fresh data. So when the user opens the app, everything updates without a loading spinner.</p><p>Push notifications are useful for sending updates to users even when the app is closed. But in many cases, the app itself needs to fetch updates from the server while it&#8217;s running.</p><p>In such situations, use techniques such as polling, long polling, or Server-Sent Events.</p><h3><strong>4. Polling, Long Polling &amp; SSE</strong></h3><p>Sometimes apps need server updates, but using WebSockets isn&#8217;t always necessary or practical. In those cases, use simpler methods such as polling, Long Polling, or Server-Sent Events (<strong>SSE</strong>) to receive updates from the server.</p><p>Each method works a little differently.</p><h4><strong>Why It Matters</strong></h4><p>Not every feature needs instant real-time updates:</p><ul><li><p>Metrics dashboard might refresh every 30 seconds.</p></li><li><p>Notification count might update every few seconds.</p></li></ul><p>Using WebSockets for these cases can be unnecessary and complex. Choosing the right approach can save server resources and keep the system simple.</p><p><strong>a. Polling (Short Polling)</strong></p><p>Polling is the simplest method.</p><p>The app requests updates from the server at fixed intervals:</p><ol><li><p>Every 10 seconds, the app sends a request.</p></li><li><p>The server responds with new data (if any).</p></li></ol><p>So the process looks like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dyjt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefd3aa39-f851-4348-97a6-7e3a90216265_1600x406.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dyjt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefd3aa39-f851-4348-97a6-7e3a90216265_1600x406.png 424w, https://substackcdn.com/image/fetch/$s_!dyjt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefd3aa39-f851-4348-97a6-7e3a90216265_1600x406.png 848w, https://substackcdn.com/image/fetch/$s_!dyjt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefd3aa39-f851-4348-97a6-7e3a90216265_1600x406.png 1272w, https://substackcdn.com/image/fetch/$s_!dyjt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefd3aa39-f851-4348-97a6-7e3a90216265_1600x406.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dyjt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefd3aa39-f851-4348-97a6-7e3a90216265_1600x406.png" width="1456" height="369" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/efd3aa39-f851-4348-97a6-7e3a90216265_1600x406.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:369,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!dyjt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefd3aa39-f851-4348-97a6-7e3a90216265_1600x406.png 424w, https://substackcdn.com/image/fetch/$s_!dyjt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefd3aa39-f851-4348-97a6-7e3a90216265_1600x406.png 848w, https://substackcdn.com/image/fetch/$s_!dyjt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefd3aa39-f851-4348-97a6-7e3a90216265_1600x406.png 1272w, https://substackcdn.com/image/fetch/$s_!dyjt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefd3aa39-f851-4348-97a6-7e3a90216265_1600x406.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 role="img" 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><title></title><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>Problem:</strong></p><p>Most of the time, there's no new data, yet the app keeps asking the server. This wastes network and server resources.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!k5p9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc571bff7-e3b3-4f8f-a376-7608d59bf66a_1094x641.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!k5p9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc571bff7-e3b3-4f8f-a376-7608d59bf66a_1094x641.png 424w, https://substackcdn.com/image/fetch/$s_!k5p9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc571bff7-e3b3-4f8f-a376-7608d59bf66a_1094x641.png 848w, https://substackcdn.com/image/fetch/$s_!k5p9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc571bff7-e3b3-4f8f-a376-7608d59bf66a_1094x641.png 1272w, https://substackcdn.com/image/fetch/$s_!k5p9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc571bff7-e3b3-4f8f-a376-7608d59bf66a_1094x641.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!k5p9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc571bff7-e3b3-4f8f-a376-7608d59bf66a_1094x641.png" width="1094" height="641" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c571bff7-e3b3-4f8f-a376-7608d59bf66a_1094x641.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:641,&quot;width&quot;:1094,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!k5p9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc571bff7-e3b3-4f8f-a376-7608d59bf66a_1094x641.png 424w, https://substackcdn.com/image/fetch/$s_!k5p9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc571bff7-e3b3-4f8f-a376-7608d59bf66a_1094x641.png 848w, https://substackcdn.com/image/fetch/$s_!k5p9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc571bff7-e3b3-4f8f-a376-7608d59bf66a_1094x641.png 1272w, https://substackcdn.com/image/fetch/$s_!k5p9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc571bff7-e3b3-4f8f-a376-7608d59bf66a_1094x641.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 role="img" 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><title></title><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>b. Long Polling</strong></p><p>Long polling improves on basic polling.</p><p>Instead of responding immediately, the server keeps the request open until new data is available.</p><p>How it works:</p><ol><li><p>App sends a request.</p></li><li><p>Server waits until something changes.</p></li><li><p>When new data arrives, the server sends the response.</p></li><li><p>The app immediately sends another request.</p></li></ol><p>This reduces unnecessary requests compared to short polling.</p><p>Yet it still requires managing many open connections on the server.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZJ5Y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2847992c-09d8-4d49-9a9b-e32b07c95e38_1404x661.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZJ5Y!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2847992c-09d8-4d49-9a9b-e32b07c95e38_1404x661.png 424w, https://substackcdn.com/image/fetch/$s_!ZJ5Y!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2847992c-09d8-4d49-9a9b-e32b07c95e38_1404x661.png 848w, https://substackcdn.com/image/fetch/$s_!ZJ5Y!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2847992c-09d8-4d49-9a9b-e32b07c95e38_1404x661.png 1272w, https://substackcdn.com/image/fetch/$s_!ZJ5Y!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2847992c-09d8-4d49-9a9b-e32b07c95e38_1404x661.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZJ5Y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2847992c-09d8-4d49-9a9b-e32b07c95e38_1404x661.png" width="1404" height="661" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2847992c-09d8-4d49-9a9b-e32b07c95e38_1404x661.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:661,&quot;width&quot;:1404,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!ZJ5Y!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2847992c-09d8-4d49-9a9b-e32b07c95e38_1404x661.png 424w, https://substackcdn.com/image/fetch/$s_!ZJ5Y!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2847992c-09d8-4d49-9a9b-e32b07c95e38_1404x661.png 848w, https://substackcdn.com/image/fetch/$s_!ZJ5Y!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2847992c-09d8-4d49-9a9b-e32b07c95e38_1404x661.png 1272w, https://substackcdn.com/image/fetch/$s_!ZJ5Y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2847992c-09d8-4d49-9a9b-e32b07c95e38_1404x661.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 role="img" 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><title></title><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>c. Server-Sent Events (SSE)</strong></p><p>SSE allows the server to push updates to the client over a single open HTTP connection.</p><p>How it works:</p><ol><li><p>Client sends a request.</p></li><li><p>Connection stays open.</p></li><li><p>Server sends updates whenever something happens.</p></li></ol><p>The client keeps listening for these updates.</p><p>SSE also has automatic reconnection built into browsers through the <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource">EventSource API</a>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Y2ru!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf6b5441-56db-461c-83cd-c59b0f82aa93_1600x681.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Y2ru!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf6b5441-56db-461c-83cd-c59b0f82aa93_1600x681.png 424w, https://substackcdn.com/image/fetch/$s_!Y2ru!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf6b5441-56db-461c-83cd-c59b0f82aa93_1600x681.png 848w, https://substackcdn.com/image/fetch/$s_!Y2ru!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf6b5441-56db-461c-83cd-c59b0f82aa93_1600x681.png 1272w, https://substackcdn.com/image/fetch/$s_!Y2ru!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf6b5441-56db-461c-83cd-c59b0f82aa93_1600x681.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Y2ru!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf6b5441-56db-461c-83cd-c59b0f82aa93_1600x681.png" width="1456" height="620" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/af6b5441-56db-461c-83cd-c59b0f82aa93_1600x681.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:620,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!Y2ru!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf6b5441-56db-461c-83cd-c59b0f82aa93_1600x681.png 424w, https://substackcdn.com/image/fetch/$s_!Y2ru!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf6b5441-56db-461c-83cd-c59b0f82aa93_1600x681.png 848w, https://substackcdn.com/image/fetch/$s_!Y2ru!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf6b5441-56db-461c-83cd-c59b0f82aa93_1600x681.png 1272w, https://substackcdn.com/image/fetch/$s_!Y2ru!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf6b5441-56db-461c-83cd-c59b0f82aa93_1600x681.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 role="img" 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><title></title><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><h4><strong>Real-World Example</strong></h4><ul><li><p>GitHub uses SSE to stream live action logs.</p></li><li><p>Many analytics dashboards use polling every few seconds.</p></li><li><p>Early versions of Twitter used long polling for real-time updates.</p></li></ul><h4><strong>Trade-offs</strong></h4><ul><li><p>Short Polling: Simple to implement, but wastes resources if there are no updates.</p></li><li><p>Long Polling: More efficient than polling, but harder to manage on the server.</p></li><li><p>SSE: Efficient for real-time updates and simple compared to WebSockets, but communication is one-way (server &#8594; client only).</p></li></ul><p><strong>The bottom line:</strong></p><ul><li><p><strong>Polling:</strong> Client repeatedly asks for updates.</p></li><li><p><strong>Long Polling:</strong> Server waits until new data appears.</p></li><li><p><strong>SSE:</strong> Server pushes updates over a single open connection.</p></li></ul><p>These approaches are useful when WebSockets are unnecessary or unavailable, which helps you keep the system simple and efficient.</p><p>Once you understand how apps receive updates from the server, the next step is deciding how the app requests data from the server.</p><p>This is where API design becomes important.</p><p>APIs define how the mobile app and server communicate, what data is requested, and how that data is returned.</p><h3><strong>5. REST vs GraphQL vs gRPC</strong></h3><p>There are different ways to design APIs.</p><p>Three common approaches are <em>REST, GraphQL, and gRPC</em>. Each one has its own advantages depending on the type of app you&#8217;re building.</p><h4><strong>REST</strong></h4><p>REST (Representational State Transfer) is the most common and widely used API style:</p><ol><li><p>App calls specific endpoints like <code>/users, /orders, /products</code>.</p></li><li><p>Server returns predefined data.</p></li></ol><p>It is simple and easy to understand, which is why many mobile apps use it.</p><p>But REST can sometimes return too much or too little data.</p><p>For example, a screen needs only the user&#8217;s name and profile photo, but the API returns email, address, preferences, and more. This is called <strong>over-fetching</strong>.</p><p>Sometimes the opposite happens: the app needs multiple API requests to load one screen. This is called <strong>under-fetching</strong>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zVqQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd964e467-df7d-4b63-b1b1-90c1b78c4eed_1344x459.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zVqQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd964e467-df7d-4b63-b1b1-90c1b78c4eed_1344x459.png 424w, https://substackcdn.com/image/fetch/$s_!zVqQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd964e467-df7d-4b63-b1b1-90c1b78c4eed_1344x459.png 848w, https://substackcdn.com/image/fetch/$s_!zVqQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd964e467-df7d-4b63-b1b1-90c1b78c4eed_1344x459.png 1272w, https://substackcdn.com/image/fetch/$s_!zVqQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd964e467-df7d-4b63-b1b1-90c1b78c4eed_1344x459.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zVqQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd964e467-df7d-4b63-b1b1-90c1b78c4eed_1344x459.png" width="1344" height="459" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d964e467-df7d-4b63-b1b1-90c1b78c4eed_1344x459.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:459,&quot;width&quot;:1344,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!zVqQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd964e467-df7d-4b63-b1b1-90c1b78c4eed_1344x459.png 424w, https://substackcdn.com/image/fetch/$s_!zVqQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd964e467-df7d-4b63-b1b1-90c1b78c4eed_1344x459.png 848w, https://substackcdn.com/image/fetch/$s_!zVqQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd964e467-df7d-4b63-b1b1-90c1b78c4eed_1344x459.png 1272w, https://substackcdn.com/image/fetch/$s_!zVqQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd964e467-df7d-4b63-b1b1-90c1b78c4eed_1344x459.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 role="img" 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><title></title><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><h4><strong>GraphQL</strong></h4><p>GraphQL was designed to address the problems of over-fetching and under-fetching.</p><p>With GraphQL:</p><ol><li><p>Client asks for exactly the data it needs.</p></li><li><p>Server returns only that data.</p></li></ol><p>Example request:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;6fe40942-3070-44e3-bff0-d2742e7a0486&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">GetUser {
  name
  profilePhoto
}</code></pre></div><p>This makes GraphQL very useful for complex mobile interfaces where different screens need different types of data. Yet GraphQL can be harder to cache and secure compared to REST.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jSpL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66f14610-031e-4746-af5c-e674daa7a769_1464x450.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jSpL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66f14610-031e-4746-af5c-e674daa7a769_1464x450.png 424w, https://substackcdn.com/image/fetch/$s_!jSpL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66f14610-031e-4746-af5c-e674daa7a769_1464x450.png 848w, https://substackcdn.com/image/fetch/$s_!jSpL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66f14610-031e-4746-af5c-e674daa7a769_1464x450.png 1272w, https://substackcdn.com/image/fetch/$s_!jSpL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66f14610-031e-4746-af5c-e674daa7a769_1464x450.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jSpL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66f14610-031e-4746-af5c-e674daa7a769_1464x450.png" width="1456" height="448" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/66f14610-031e-4746-af5c-e674daa7a769_1464x450.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:448,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!jSpL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66f14610-031e-4746-af5c-e674daa7a769_1464x450.png 424w, https://substackcdn.com/image/fetch/$s_!jSpL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66f14610-031e-4746-af5c-e674daa7a769_1464x450.png 848w, https://substackcdn.com/image/fetch/$s_!jSpL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66f14610-031e-4746-af5c-e674daa7a769_1464x450.png 1272w, https://substackcdn.com/image/fetch/$s_!jSpL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66f14610-031e-4746-af5c-e674daa7a769_1464x450.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 role="img" 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><title></title><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><h4><strong>gRPC</strong></h4><p>gRPC is another approach focused on high performance.</p><p>Instead of sending JSON data like REST or GraphQL, gRPC uses a binary format called <strong>Protocol Buffers</strong>, which is smaller and faster.</p><p>It runs over HTTP/2, which allows faster communication between services. Because of this, gRPC is often used for internal microservices, backend communication, and high-performance mobile systems.</p><p>But it requires special tooling and is less common for public APIs.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SnKU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b3bfc60-15f7-4db0-82d6-c0b0fa0390df_1600x438.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SnKU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b3bfc60-15f7-4db0-82d6-c0b0fa0390df_1600x438.png 424w, https://substackcdn.com/image/fetch/$s_!SnKU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b3bfc60-15f7-4db0-82d6-c0b0fa0390df_1600x438.png 848w, https://substackcdn.com/image/fetch/$s_!SnKU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b3bfc60-15f7-4db0-82d6-c0b0fa0390df_1600x438.png 1272w, https://substackcdn.com/image/fetch/$s_!SnKU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b3bfc60-15f7-4db0-82d6-c0b0fa0390df_1600x438.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SnKU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b3bfc60-15f7-4db0-82d6-c0b0fa0390df_1600x438.png" width="1456" height="399" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b3bfc60-15f7-4db0-82d6-c0b0fa0390df_1600x438.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:399,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!SnKU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b3bfc60-15f7-4db0-82d6-c0b0fa0390df_1600x438.png 424w, https://substackcdn.com/image/fetch/$s_!SnKU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b3bfc60-15f7-4db0-82d6-c0b0fa0390df_1600x438.png 848w, https://substackcdn.com/image/fetch/$s_!SnKU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b3bfc60-15f7-4db0-82d6-c0b0fa0390df_1600x438.png 1272w, https://substackcdn.com/image/fetch/$s_!SnKU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b3bfc60-15f7-4db0-82d6-c0b0fa0390df_1600x438.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 role="img" 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><title></title><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><h4><strong>Why It Matters</strong></h4><p>The API style you choose affects network speed, battery usage, number of requests, and app performance.</p><p>If an API returns too much data, it wastes bandwidth and battery. If it returns too little, the app needs more requests, which increases latency. Choosing the right approach helps keep the app fast and efficient.</p><h4><strong>Real-World Example</strong></h4><ul><li><p>Facebook created GraphQL because its mobile apps needed many REST requests to load a single screen.</p></li><li><p>GitHub moved its public API to GraphQL.</p></li><li><p>Google uses gRPC internally for inter-service communication.</p></li></ul><h4><strong>Trade-offs</strong></h4><ul><li><p>REST: Simple, widely supported, and easy to cache, but sometimes returns too much or too little data.</p></li><li><p>GraphQL:  Clients request exactly the data they need and great for complex UIs, but caching and security can be more complicated.</p></li><li><p>gRPC: Very fast, efficient, and great for internal services, but requires HTTP/2 and special tooling.</p></li></ul><h4><strong>Practical Advice</strong></h4><p>A common approach in real systems is:</p><ul><li><p>REST for simple CRUD APIs.</p></li><li><p>GraphQL for complex UI data requirements.</p></li><li><p>gRPC for internal communication between services where performance matters most.</p></li></ul><p>Once you decide how the app will request data from the server, the next step is making sure those requests still work properly when the internet connection is unstable.</p><h3><strong>6. Network Resilience (Exponential Backoff &amp; Retry Strategy)</strong></h3><p>Mobile networks can be slow, unstable, or unavailable.</p><p>As a result, requests may fail due to weak signals, timeouts, or temporary server issues. Instead of failing immediately, most apps retry the request after a short delay.</p><p>Yet retrying requests often can cause serious problems.</p><h4><strong>Why It Matters</strong></h4><p>Imagine thousands of mobile apps trying to reconnect at the same time after a server outage.</p><p>If every app retries instantly, the server suddenly receives a huge number of requests at once. This can overload the server again, causing another failure. This situation is called the <strong>thundering herd problem,</strong> when many clients try at the same time and overwhelm the system.</p><p>A good retry strategy spreads these retries over time so the server can recover&#8230;</p><h4><strong>Exponential Backoff (The Common Solution)</strong></h4><p>To avoid retrying too aggressively, apps use exponential backoff. This means the app waits longer between each retry:</p><ul><li><p>First retry &#8594; wait 1 second</p></li><li><p>Second retry &#8594; wait 2 seconds</p></li><li><p>Third retry &#8594; wait 4 seconds</p></li><li><p>Fourth retry &#8594; wait 8 seconds</p></li></ul><p>Each retry waits longer than the previous one. Thus reducing pressure on the server.</p><h4><strong>Adding Jitter</strong></h4><p>If every app waited the exact same time, they would still retry together.</p><p>To avoid that, add <strong>jitter</strong>, which is a small random delay. For example, retry after 4 seconds + random delay.</p><p>This spreads the requests over time instead of sending them all at once.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Y_wh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d787a8f-d96c-4f3f-a961-e803393f16ef_1600x453.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Y_wh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d787a8f-d96c-4f3f-a961-e803393f16ef_1600x453.png 424w, https://substackcdn.com/image/fetch/$s_!Y_wh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d787a8f-d96c-4f3f-a961-e803393f16ef_1600x453.png 848w, https://substackcdn.com/image/fetch/$s_!Y_wh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d787a8f-d96c-4f3f-a961-e803393f16ef_1600x453.png 1272w, https://substackcdn.com/image/fetch/$s_!Y_wh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d787a8f-d96c-4f3f-a961-e803393f16ef_1600x453.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Y_wh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d787a8f-d96c-4f3f-a961-e803393f16ef_1600x453.png" width="1456" height="412" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7d787a8f-d96c-4f3f-a961-e803393f16ef_1600x453.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:412,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!Y_wh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d787a8f-d96c-4f3f-a961-e803393f16ef_1600x453.png 424w, https://substackcdn.com/image/fetch/$s_!Y_wh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d787a8f-d96c-4f3f-a961-e803393f16ef_1600x453.png 848w, https://substackcdn.com/image/fetch/$s_!Y_wh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d787a8f-d96c-4f3f-a961-e803393f16ef_1600x453.png 1272w, https://substackcdn.com/image/fetch/$s_!Y_wh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d787a8f-d96c-4f3f-a961-e803393f16ef_1600x453.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 role="img" 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><title></title><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><h4><strong>Real-World Example</strong></h4><p>Many popular services, such as AWS SDK, Google Cloud client libraries, and Stripe API clients, use this strategy by default. This approach is considered the standard for reliable network communication.</p><h4><strong>Trade-offs</strong></h4><p>Retry strategies must balance reliability and user experience.</p><p>If the app takes too long to retry, the user may wait too long for a response. If it retries too quickly, it might overload the server.</p><p>To handle this, many systems use a <strong>circuit breaker</strong>.</p><p>A circuit breaker stops retrying after several failures and shows a clear error message instead of retrying forever.</p><p>After adding retries to handle network failures, another challenge arises: <em>what happens if the same request is sent many times?</em></p><p>Sometimes a request reaches the server successfully, but the response never reaches the app because the network drops.</p><p>If the app retries the request, it could perform the same action again&#8230;</p><h3><strong>7. Idempotency in APIs (Safe Retries)</strong></h3><p>In mobile apps, network requests can fail halfway through.</p><p>For example:</p><ol><li><p>App sends a request to the server</p></li><li><p>Server successfully processes it</p></li><li><p>But the response never reaches the app because the internet connection drops</p></li></ol><p>From the app&#8217;s perspective, the request appears to have failed, so it retries it. If the server processes the request again, the action may happen twice.</p><p>This is where <em>idempotency</em> becomes important.</p><p>Idempotency means sending the same request many times produces the same result, rather than repeating the action.</p><h4><strong>How Idempotency Works</strong></h4><p>To make retries safe, the client sends a unique identifier with each request, called an <strong>idempotency key</strong>. This key is usually a <strong>unique ID (UUID)</strong> generated by the app.</p><p>Example request header:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;9d58a35d-7e89-4dec-89db-42f1d512a615&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">Idempotency-Key: 8f3c2c2e-92f1-4f9b-b8b0-1b0f1b1a3e3f</code></pre></div><p>When the server receives a request:</p><ol><li><p>It checks whether this key was used before.</p></li><li><p>If the key is new, the server processes the request normally.</p></li><li><p>If the same key appears again, the server <strong>does NOT repeat the action</strong>. Instead, it returns the previous response.</p></li></ol><p>This prevents duplicate operations.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6ZuB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bc6cc48-71c4-4b91-8c65-9ef16db57d6b_1600x367.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6ZuB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bc6cc48-71c4-4b91-8c65-9ef16db57d6b_1600x367.png 424w, https://substackcdn.com/image/fetch/$s_!6ZuB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bc6cc48-71c4-4b91-8c65-9ef16db57d6b_1600x367.png 848w, https://substackcdn.com/image/fetch/$s_!6ZuB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bc6cc48-71c4-4b91-8c65-9ef16db57d6b_1600x367.png 1272w, https://substackcdn.com/image/fetch/$s_!6ZuB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bc6cc48-71c4-4b91-8c65-9ef16db57d6b_1600x367.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6ZuB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bc6cc48-71c4-4b91-8c65-9ef16db57d6b_1600x367.png" width="1456" height="334" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4bc6cc48-71c4-4b91-8c65-9ef16db57d6b_1600x367.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:334,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!6ZuB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bc6cc48-71c4-4b91-8c65-9ef16db57d6b_1600x367.png 424w, https://substackcdn.com/image/fetch/$s_!6ZuB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bc6cc48-71c4-4b91-8c65-9ef16db57d6b_1600x367.png 848w, https://substackcdn.com/image/fetch/$s_!6ZuB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bc6cc48-71c4-4b91-8c65-9ef16db57d6b_1600x367.png 1272w, https://substackcdn.com/image/fetch/$s_!6ZuB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bc6cc48-71c4-4b91-8c65-9ef16db57d6b_1600x367.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4><strong>Why It Matters</strong></h4><p>Imagine a user taps the <strong>&#8220;</strong>Pay<strong>&#8221;</strong> button.</p><ol><li><p>The payment request reaches the server.</p></li><li><p>Server processes the payment successfully.</p></li><li><p>But the response never reaches the phone because the network drops.</p></li></ol><p>So the user taps <strong>&#8220;</strong>Pay<strong>&#8221;</strong> again!</p><p>Without idempotency, the user might be charged twice.</p><p>This is why idempotency is extremely important for operations that change data.</p><h4><strong>Real-World Example</strong></h4><p>Many large systems rely on idempotency:</p><ul><li><p>Stripe requires an Idempotency-Key for payment API calls.</p></li><li><p>Uber uses idempotency keys for ride requests.</p></li><li><p>Most financial systems use this approach to prevent duplicate transactions.</p></li></ul><h4><strong>Trade-offs</strong></h4><p>To support idempotency, the server must store previously used keys and their responses for a period of time (typically 24 hours).</p><p>This requires some storage, but the cost is small compared to the problems caused by duplicate operations.</p><p>It&#8217;s also important to design the key carefully, usually combining:</p><ul><li><p>user ID</p></li><li><p>operation type</p></li><li><p>unique request ID</p></li></ul><h4><strong>Practical Tip</strong></h4><p>The idempotency key should be generated on the client before the request is sent. The app should also save the key locally.</p><p>If the app crashes or restarts, it can retry the request using the same key, ensuring the action is not repeated.</p><p>After making retries safe, the next step is to improve the app's efficiency when communicating with the server. One important way to do this is by reducing the number of network requests the app sends.</p><h3><strong>8. Request Batching &amp; Payload Optimisation</strong></h3><p>Every time a mobile app sends a request to the server, it adds latency and uses battery.</p><p>The total time for a request to reach the server and its response to return is called a <strong>network round-trip</strong>.</p><p>If an app sends many small requests separately, it can slow down the app and drain the device&#8217;s battery.</p><p>To solve this, use these two techniques:</p><ul><li><p>Request batching</p></li><li><p>Payload optimisation</p></li></ul><p><strong>a. Request Batching</strong></p><p>Request batching combines multiple requests into a single request.</p><p>Instead of doing this:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;380c69b6-60a6-4e09-99e8-dd2271ea4219&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">App &#8594; Request 1
App &#8594; Request 2
App &#8594; Request 3</code></pre></div><p>The app sends one combined request:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;8c637ab1-4ce4-4d80-ba70-f2aa1d355925&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">App &#8594; Batch Request (Request 1 + Request 2 + Request 3)</code></pre></div><p>This reduces the number of times the app needs to communicate with the server.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SqRP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff752d8ca-cbff-4fce-ba31-53c2b264c996_1341x617.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SqRP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff752d8ca-cbff-4fce-ba31-53c2b264c996_1341x617.png 424w, https://substackcdn.com/image/fetch/$s_!SqRP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff752d8ca-cbff-4fce-ba31-53c2b264c996_1341x617.png 848w, https://substackcdn.com/image/fetch/$s_!SqRP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff752d8ca-cbff-4fce-ba31-53c2b264c996_1341x617.png 1272w, https://substackcdn.com/image/fetch/$s_!SqRP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff752d8ca-cbff-4fce-ba31-53c2b264c996_1341x617.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SqRP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff752d8ca-cbff-4fce-ba31-53c2b264c996_1341x617.png" width="1341" height="617" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f752d8ca-cbff-4fce-ba31-53c2b264c996_1341x617.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:617,&quot;width&quot;:1341,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!SqRP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff752d8ca-cbff-4fce-ba31-53c2b264c996_1341x617.png 424w, https://substackcdn.com/image/fetch/$s_!SqRP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff752d8ca-cbff-4fce-ba31-53c2b264c996_1341x617.png 848w, https://substackcdn.com/image/fetch/$s_!SqRP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff752d8ca-cbff-4fce-ba31-53c2b264c996_1341x617.png 1272w, https://substackcdn.com/image/fetch/$s_!SqRP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff752d8ca-cbff-4fce-ba31-53c2b264c996_1341x617.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 role="img" 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><title></title><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>b. Payload Optimisation</strong></p><p>Payload is the data sent between the app and the server.</p><p>Payload optimisation focuses on reducing the amount of data being transferred.</p><p>This can be achieved by:</p><ul><li><p>Compression (like gzip or Brotli)</p></li><li><p>Sending only the needed fields</p></li><li><p>Using efficient formats like binary data instead of large text formats</p></li></ul><p>Reducing the app's payload size helps it load faster and use less network data.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZpSR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60bdad54-c059-43c4-83cf-171fb9ec77de_1494x550.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZpSR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60bdad54-c059-43c4-83cf-171fb9ec77de_1494x550.png 424w, https://substackcdn.com/image/fetch/$s_!ZpSR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60bdad54-c059-43c4-83cf-171fb9ec77de_1494x550.png 848w, https://substackcdn.com/image/fetch/$s_!ZpSR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60bdad54-c059-43c4-83cf-171fb9ec77de_1494x550.png 1272w, https://substackcdn.com/image/fetch/$s_!ZpSR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60bdad54-c059-43c4-83cf-171fb9ec77de_1494x550.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZpSR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60bdad54-c059-43c4-83cf-171fb9ec77de_1494x550.png" width="1456" height="536" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/60bdad54-c059-43c4-83cf-171fb9ec77de_1494x550.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:536,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!ZpSR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60bdad54-c059-43c4-83cf-171fb9ec77de_1494x550.png 424w, https://substackcdn.com/image/fetch/$s_!ZpSR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60bdad54-c059-43c4-83cf-171fb9ec77de_1494x550.png 848w, https://substackcdn.com/image/fetch/$s_!ZpSR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60bdad54-c059-43c4-83cf-171fb9ec77de_1494x550.png 1272w, https://substackcdn.com/image/fetch/$s_!ZpSR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60bdad54-c059-43c4-83cf-171fb9ec77de_1494x550.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 role="img" 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><title></title><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><h4><strong>Why It Matters</strong></h4><p>On mobile devices, sending a request wakes up the device&#8217;s <strong>network radio</strong> (the hardware responsible for communication).</p><p>This wake-up process takes time and consumes battery.</p><p>For example:</p><ul><li><p>Sending 10 separate requests means the radio wakes up 10 times.</p></li><li><p>Sending 1 batched request wakes the radio only once.</p></li></ul><p>So batching requests can significantly reduce both latency and battery usage.</p><h4><strong>Real-World Example</strong></h4><p>Many popular apps use batching to improve performance.</p><ul><li><p>Facebook batches many GraphQL queries into a single HTTP request.</p></li><li><p>Instagram loads images gradually but fetches data for the next screen in a single batched request.</p></li></ul><p>This makes the app feel faster and smoother.</p><h4><strong>Trade-offs</strong></h4><p>Batching improves efficiency but also introduces challenges.</p><ul><li><p>If the app waits too long to collect requests before batching them, it can add extra delay.</p></li><li><p>Another challenge is handling errors. For example, if a batched request contains 10 operations and 3 fail, the system must handle those failures properly.</p></li></ul><p>To balance this, many systems use a short batching window, usually around 50&#8211;100 milliseconds, to collect requests before sending them together.</p><p>After reducing the number of network requests, another challenge appears when apps need to upload large files, such as photos, videos, or documents.</p><p>Large uploads can easily fail on mobile networks because connections may drop or become unstable. To handle this, apps use a technique called <strong>resumable uploads</strong>.</p><h3><strong>9. Resumable Uploads (Chunked Uploads)</strong></h3><p>When a mobile app uploads a large file, such as a 100MB video, sending the entire file in a single request is risky.</p><p>If the network disconnects halfway through the upload, the whole upload may fail. The app would have to start again from the beginning.</p><p>To avoid this problem, use resumable uploads, also called <em>chunked uploads</em>.</p><h4><strong>How Chunked Uploads Work</strong></h4><p>Instead of uploading the entire file at once, it&#8217;s split into smaller parts, called <strong>chunks</strong>.</p><p>For example, a 100MB file might be divided into 10 chunks of 10MB each, and each chunk is uploaded separately.</p><p>The process usually works like this:</p><ol><li><p>App starts the upload and creates an <strong>upload session</strong>.</p></li><li><p>Server returns a <strong>session ID </strong>or<strong> upload URL</strong>.</p></li><li><p>App uploads the file <strong>chunk by chunk</strong>.</p></li><li><p>Server keeps track of how much data it has already received.</p></li><li><p>If the network fails, the app asks the server <strong>where the upload stopped</strong>.</p></li><li><p>The upload continues from that point instead of starting from the beginning.</p></li></ol><p>This makes large uploads much more reliable on mobile networks.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!w3W4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93c356ff-1dbd-44f9-801a-f9b4299c6c04_1600x303.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!w3W4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93c356ff-1dbd-44f9-801a-f9b4299c6c04_1600x303.png 424w, https://substackcdn.com/image/fetch/$s_!w3W4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93c356ff-1dbd-44f9-801a-f9b4299c6c04_1600x303.png 848w, https://substackcdn.com/image/fetch/$s_!w3W4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93c356ff-1dbd-44f9-801a-f9b4299c6c04_1600x303.png 1272w, https://substackcdn.com/image/fetch/$s_!w3W4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93c356ff-1dbd-44f9-801a-f9b4299c6c04_1600x303.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!w3W4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93c356ff-1dbd-44f9-801a-f9b4299c6c04_1600x303.png" width="1456" height="276" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/93c356ff-1dbd-44f9-801a-f9b4299c6c04_1600x303.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:276,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!w3W4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93c356ff-1dbd-44f9-801a-f9b4299c6c04_1600x303.png 424w, https://substackcdn.com/image/fetch/$s_!w3W4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93c356ff-1dbd-44f9-801a-f9b4299c6c04_1600x303.png 848w, https://substackcdn.com/image/fetch/$s_!w3W4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93c356ff-1dbd-44f9-801a-f9b4299c6c04_1600x303.png 1272w, https://substackcdn.com/image/fetch/$s_!w3W4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93c356ff-1dbd-44f9-801a-f9b4299c6c04_1600x303.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4><strong>Why It Matters</strong></h4><p>Mobile networks are often unstable.</p><p>Imagine uploading a 200MB video that reaches 99% when the network suddenly disconnects, causing the upload to fail&#8230;</p><p>Without resumable uploads, the app would have to restart the entire upload from the beginning, which wastes time, data, and battery.</p><p>With resumable uploads, the app can resume uploading from where it left off instead of starting over.</p><h4><strong>Real-World Example</strong></h4><p>Many popular apps use resumable uploads:</p><ul><li><p>YouTube for video uploads</p></li><li><p>Google Drive for file uploads</p></li><li><p>Dropbox for syncing files</p></li></ul><p>Any app that allows users to upload media usually uses this approach.</p><p>Even with reliable upload systems, mobile apps still face a major challenge: <em>network connections can drop at any time.</em></p><p>Users may lose connectivity when entering a subway tunnel, switching to airplane mode, or moving to an area with poor network coverage. Because of this, mobile apps must be designed to handle unstable or missing network connections without breaking.</p><h3><strong>10. Handling Intermittent Connectivity</strong></h3><p>Mobile apps should continue working as smoothly as possible even when the internet connection is weak or temporarily unavailable. Instead of failing immediately, the app should adapt to the network situation and recover when the connection returns.</p><p>Use these techniques to handle this:</p><p><strong>a. Local Request Queuing</strong></p><p>When the device is offline, the app can store user actions locally rather than sending them to the server immediately.</p><p>For example:</p><ol><li><p>A user sends a message.</p></li><li><p>The app saves the message locally.</p></li><li><p>When the internet connection returns, the app sends it to the server.</p></li></ol><p>This is called <strong>request queuing</strong>. The app keeps a list of pending actions and processes them once the network is available again.</p><p><strong>b. Optimistic UI</strong></p><p>Another common technique is optimistic UI.</p><p>With optimistic UI, the app updates the interface immediately, assuming the request will succeed.</p><p>For example:</p><ul><li><p>A user likes a post.</p></li><li><p>App shows the post as liked instantly.</p></li><li><p>Request is sent to the server in the background.</p></li></ul><p>If the request fails later, the app can correct the state.</p><p>This makes the app feel fast and responsive, even when the network is slow.</p><p><strong>c. Network State Awareness</strong></p><p>Apps can also monitor the device&#8217;s network status.</p><p>This allows the app to know when it is online, offline, or on a slow connection.</p><p>Based on this information, the app can adjust its behaviour. For example, it might delay data syncing while offline and resume syncing when connectivity returns.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!P2_3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb05560eb-49fb-42ea-b215-6bb5dc1a60e4_1600x524.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!P2_3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb05560eb-49fb-42ea-b215-6bb5dc1a60e4_1600x524.png 424w, https://substackcdn.com/image/fetch/$s_!P2_3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb05560eb-49fb-42ea-b215-6bb5dc1a60e4_1600x524.png 848w, https://substackcdn.com/image/fetch/$s_!P2_3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb05560eb-49fb-42ea-b215-6bb5dc1a60e4_1600x524.png 1272w, https://substackcdn.com/image/fetch/$s_!P2_3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb05560eb-49fb-42ea-b215-6bb5dc1a60e4_1600x524.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!P2_3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb05560eb-49fb-42ea-b215-6bb5dc1a60e4_1600x524.png" width="1456" height="477" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b05560eb-49fb-42ea-b215-6bb5dc1a60e4_1600x524.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:477,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!P2_3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb05560eb-49fb-42ea-b215-6bb5dc1a60e4_1600x524.png 424w, https://substackcdn.com/image/fetch/$s_!P2_3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb05560eb-49fb-42ea-b215-6bb5dc1a60e4_1600x524.png 848w, https://substackcdn.com/image/fetch/$s_!P2_3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb05560eb-49fb-42ea-b215-6bb5dc1a60e4_1600x524.png 1272w, https://substackcdn.com/image/fetch/$s_!P2_3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb05560eb-49fb-42ea-b215-6bb5dc1a60e4_1600x524.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 role="img" 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><title></title><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><h4><strong>Why It Matters</strong></h4><p>Users frequently lose internet access during normal usage.</p><p>For example, in subway tunnels, on airplanes, or in areas with weak network coverage. If an app crashes, freezes, or loses user data, it feels unreliable.</p><p>Properly handling connectivity problems makes the app feel stable and trustworthy.</p><h4><strong>Real-World Example</strong></h4><p>Many modern apps handle intermittent connectivity this way:</p><ul><li><p>Notion queues edits locally and syncs them later.</p></li><li><p>Google Docs allows you to continue editing even when offline.</p></li><li><p>Messaging apps show a &#8220;sending&#8221; or &#8220;pending&#8221; status until the message is delivered.</p></li></ul><h4><strong>Practical Tip</strong></h4><p>Mobile operating systems provide built-in tools to monitor network connectivity:</p><ul><li><p><a href="https://developer.apple.com/documentation/network/nwpathmonitor">NWPathMonitor</a> on iOS</p></li><li><p><a href="https://developer.android.com/reference/android/net/ConnectivityManager">ConnectivityManager</a> on Android</p></li></ul><p>These tools notify the app when the network status changes.</p><p>This approach is event-driven and battery-efficient, unlike constantly checking the network in a loop.</p><p>Even with reliable networking strategies, mobile apps cannot always depend on an internet connection. To keep the app fast and usable even without internet access, developers use caching.</p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get the full premium newsletter series and max your system design career leverage:</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><hr></div><h1><strong>Caching &amp; Offline</strong></h1><p>This section focuses on how mobile apps store and reuse data to reduce network requests and improve performance.</p><p>You&#8217;ll learn how caching strategies and offline-first approaches help apps stay fast and usable even when the internet is slow or unavailable.</p><h3><strong>11. On-Device Caching (Memory vs Disk)</strong></h3><p>Mobile apps usually store cached data in two places on the device:</p><ul><li><p>Memory (RAM)</p></li><li><p>Disk (device storage)</p></li></ul><p>Using both together creates a two-layer caching system.</p><p><strong>a. Memory Cache (RAM)</strong></p><p>Memory cache stores data in device RAM, which is extremely fast to access.</p><p>When data is stored in memory:</p><ul><li><p>App can load it almost instantly.</p></li><li><p>It avoids making a network request.</p></li></ul><p>Yet memory has a limitation:</p><ul><li><p>Data disappears when the app closes.</p></li><li><p>Operating system may remove cached data if the device runs low on memory.</p></li></ul><p>So memory caching is fast but temporary.</p><p><strong>b. Disk Cache (Storage)</strong></p><p>Disk cache stores data on the device&#8217;s permanent storage.</p><p>This means:</p><ul><li><p>Data remains available even after the app restarts.</p></li><li><p>App can load previously downloaded data without contacting the server again.</p></li></ul><p>But disk access is slower than memory access.</p><p>So disk caching is slower than RAM but more persistent.</p><h4><strong>Why It Matters</strong></h4><p>Fetching data from the server can take 50&#8211;500 milliseconds, depending on the network. But reading data from memory happens in nanoseconds, which is almost instantaneous.</p><p>So if the app can load data from the cache instead of the network, the user interface feels much faster. For example, profile pictures, app configurations, or recently viewed content.</p><p>These are perfect candidates for caching.</p><h4><strong>Real-World Example</strong></h4><p>Many image-loading libraries use this two-layer caching approach. For example, SDWebImage and Kingfisher.</p><p>When an image is requested:</p><ol><li><p>App first checks the <em>memory cache.</em></p></li><li><p>If it&#8217;s not there, it checks the <em>disk cache.</em></p></li><li><p>Only if both are missing does it requests image from the network.</p></li></ol><p>This makes images load almost instantly.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jshU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa9ecfb5-c5f3-4b64-b8c0-fc88de3a1201_1600x515.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jshU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa9ecfb5-c5f3-4b64-b8c0-fc88de3a1201_1600x515.png 424w, https://substackcdn.com/image/fetch/$s_!jshU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa9ecfb5-c5f3-4b64-b8c0-fc88de3a1201_1600x515.png 848w, https://substackcdn.com/image/fetch/$s_!jshU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa9ecfb5-c5f3-4b64-b8c0-fc88de3a1201_1600x515.png 1272w, https://substackcdn.com/image/fetch/$s_!jshU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa9ecfb5-c5f3-4b64-b8c0-fc88de3a1201_1600x515.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jshU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa9ecfb5-c5f3-4b64-b8c0-fc88de3a1201_1600x515.png" width="1456" height="469" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aa9ecfb5-c5f3-4b64-b8c0-fc88de3a1201_1600x515.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:469,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!jshU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa9ecfb5-c5f3-4b64-b8c0-fc88de3a1201_1600x515.png 424w, https://substackcdn.com/image/fetch/$s_!jshU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa9ecfb5-c5f3-4b64-b8c0-fc88de3a1201_1600x515.png 848w, https://substackcdn.com/image/fetch/$s_!jshU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa9ecfb5-c5f3-4b64-b8c0-fc88de3a1201_1600x515.png 1272w, https://substackcdn.com/image/fetch/$s_!jshU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa9ecfb5-c5f3-4b64-b8c0-fc88de3a1201_1600x515.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 role="img" 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><title></title><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><h4><strong>Trade-offs</strong></h4><p>Both types of caching have advantages and limitations:</p><ul><li><p><strong>Memory Cache:</strong> Extremely fast, but cleared when the app closes.</p></li><li><p><strong>Disk Cache:</strong> Data remains available after restarting the app, but reading from disk is slower than memory.</p></li></ul><p>Cache size also needs to be controlled carefully.</p><p>If too much memory is used for caching, the operating system may remove the cached data or close the app to free memory.</p><h4><strong>Practical Tip</strong></h4><p>Mobile platforms provide built-in caching tools that automatically manage memory. For example, NSCache on iOS and LruCache on Android.</p><p>These systems automatically remove older items from memory when the device is running low on resources. This helps prevent the app from using too much memory.</p><p>Using simple data structures like dictionaries or hash maps for caching is NOT ideal, because they do not automatically respond to memory pressure. As a result, they may keep too much data in memory, increasing the risk that the app will be terminated by the operating system.</p><p>Local caching stores data on the device, which helps apps load faster.</p><p>But the internet itself also has built-in caching mechanisms that can reduce unnecessary network requests. This is where HTTP caching becomes useful.</p><h3><strong>12. HTTP Caching (ETag, Cache-Control)</strong></h3><p>HTTP caching allows apps and browsers to reuse previously downloaded responses instead of requesting the same data again.</p><p>This is controlled using special HTTP headers, <code>Cache-Control</code>, and <code>ETag</code>. These headers tell the app two important things:</p><ul><li><p>How long can cached data be reused</p></li><li><p>How to check if the data has changed</p></li></ul><p><strong>a. Cache-Control</strong></p><p>This header tells the app how long it can reuse the cached data before asking the server again.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;30915655-115f-46f2-88f3-06395de74a23&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">Cache-Control: max-age=300</code></pre></div><p>This means the response can be reused for 300 seconds (5 minutes).</p><p>During those 5 minutes, the app can load the data directly from cache instead of making a new request to the server.</p><p>This improves speed and reduces network usage.</p><p><strong>b. ETag</strong></p><p>An ETag is a unique identifier that represents a specific version of the data.</p><p>When the server sends a response, it also includes an ETag value:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;e492e2de-6397-4716-b569-d25c84598b74&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">ETag: &#8220;abc123&#8221;</code></pre></div><p>When the app requests the same data again, it sends that value back to the server:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;f4246bd4-52c8-43bc-a34f-fc2a1fe458d6&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">If-None-Match: &#8220;abc123&#8221;</code></pre></div><p>The server checks whether the data has changed:</p><ul><li><p>If the data has NOT changed, the server returns <code>304 Not Modified</code> with no response body.</p></li><li><p>If the data has changed, the server sends the new data.</p></li></ul><p>This saves bandwidth because the server does NOT need to resend the entire response.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XC3I!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f9ce961-68e7-4111-a302-aa7b1dc50f55_1600x699.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XC3I!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f9ce961-68e7-4111-a302-aa7b1dc50f55_1600x699.png 424w, https://substackcdn.com/image/fetch/$s_!XC3I!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f9ce961-68e7-4111-a302-aa7b1dc50f55_1600x699.png 848w, https://substackcdn.com/image/fetch/$s_!XC3I!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f9ce961-68e7-4111-a302-aa7b1dc50f55_1600x699.png 1272w, https://substackcdn.com/image/fetch/$s_!XC3I!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f9ce961-68e7-4111-a302-aa7b1dc50f55_1600x699.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XC3I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f9ce961-68e7-4111-a302-aa7b1dc50f55_1600x699.png" width="1456" height="636" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9f9ce961-68e7-4111-a302-aa7b1dc50f55_1600x699.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:636,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!XC3I!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f9ce961-68e7-4111-a302-aa7b1dc50f55_1600x699.png 424w, https://substackcdn.com/image/fetch/$s_!XC3I!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f9ce961-68e7-4111-a302-aa7b1dc50f55_1600x699.png 848w, https://substackcdn.com/image/fetch/$s_!XC3I!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f9ce961-68e7-4111-a302-aa7b1dc50f55_1600x699.png 1272w, https://substackcdn.com/image/fetch/$s_!XC3I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f9ce961-68e7-4111-a302-aa7b1dc50f55_1600x699.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 role="img" 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><title></title><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><h4><strong>Why It Matters</strong></h4><p>HTTP caching reduces unnecessary network requests.</p><p>For example, if an API response is 200 KB, returning a <code>304 Not Modified</code> response avoids downloading that 200 KB again.</p><p>This helps improve app performance, network efficiency, and battery usage. The best part is that HTTP caching works automatically when the correct headers are set.</p><h4><strong>Real-World Example</strong></h4><p>A news app might load a list of articles using an API. The server might return a header like this:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;ccec6c50-4ba7-4d51-980b-6aec6e4b0f70&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">Cache-Control: max-age=60, stale-while-revalidate=300</code></pre></div><p>This means cached response can be used for 60 seconds. After that, the app can still show the cached content while checking for updates in the background.</p><p>As a result, the articles appear instantly without showing a loading spinner.</p><h4><strong>Trade-offs</strong></h4><p>Different caching strategies have different advantages:</p><ul><li><p><strong>Strong caching (long max-age): </strong>Faster loading and fewer network requests, but the data may become outdated.</p></li><li><p><strong>Weak caching (ETag validation): </strong>Always checks if data is fresh, but still requires a small network request.</p></li></ul><p>Because of this, cache durations should match the frequency of data changes.</p><p>Caching helps apps load data faster, but it still depends on the network at some point. When the network connection disappears completely, caching alone cannot solve the problem.</p><p>To keep apps usable even without a network connection, many apps use a design approach called <em>offline-first architecture.</em></p><h3><strong>13. Offline-First Architecture</strong></h3><p>Offline-first architecture means the app is designed to work normally even without a network connection.</p><p>Instead of always asking the server for data, the app mainly works with data stored locally on the device. The app shows and updates local data first, and then synchronises changes with the server when the network becomes available.</p><p>This approach helps the app stay fast and responsive, even when the network is slow or unavailable.</p><h4><strong>How It Works</strong></h4><p>In an offline-first system, the app reads and writes data from local storage first.</p><p>The process usually works like this:</p><ol><li><p>The app reads data from the local database instead of requesting it from the server.</p></li><li><p>When the user makes a change, the app updates the local database immediately.</p></li><li><p>A background process then sends those changes to the server when a connection is available.</p></li><li><p>If the server has new updates, the app downloads them and updates the local database.</p></li><li><p>When the local data changes, the app automatically updates the user interface.</p></li></ol><p>Because the UI always reads from local data, the app feels fast and responsive.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L_ER!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e35bc1-ca02-4cc4-975c-1e1ad1f8f505_1411x662.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L_ER!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e35bc1-ca02-4cc4-975c-1e1ad1f8f505_1411x662.png 424w, https://substackcdn.com/image/fetch/$s_!L_ER!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e35bc1-ca02-4cc4-975c-1e1ad1f8f505_1411x662.png 848w, https://substackcdn.com/image/fetch/$s_!L_ER!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e35bc1-ca02-4cc4-975c-1e1ad1f8f505_1411x662.png 1272w, https://substackcdn.com/image/fetch/$s_!L_ER!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e35bc1-ca02-4cc4-975c-1e1ad1f8f505_1411x662.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L_ER!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e35bc1-ca02-4cc4-975c-1e1ad1f8f505_1411x662.png" width="1411" height="662" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/96e35bc1-ca02-4cc4-975c-1e1ad1f8f505_1411x662.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:662,&quot;width&quot;:1411,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!L_ER!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e35bc1-ca02-4cc4-975c-1e1ad1f8f505_1411x662.png 424w, https://substackcdn.com/image/fetch/$s_!L_ER!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e35bc1-ca02-4cc4-975c-1e1ad1f8f505_1411x662.png 848w, https://substackcdn.com/image/fetch/$s_!L_ER!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e35bc1-ca02-4cc4-975c-1e1ad1f8f505_1411x662.png 1272w, https://substackcdn.com/image/fetch/$s_!L_ER!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e35bc1-ca02-4cc4-975c-1e1ad1f8f505_1411x662.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 role="img" 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><title></title><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><h4><strong>Why It Matters</strong></h4><p>Apps that depend entirely on the network often feel slow.</p><p>Every action requires a request to the server, which can take 100&#8211;300 milliseconds or more. This delay often appears as loading spinners.</p><p>Offline-first apps avoid this problem.</p><p>Since the UI reads from local data, interactions feel instant, while the network syncing happens quietly in the background.</p><h4><strong>Real-World Example</strong></h4><p>Many popular apps use an offline-first architecture:</p><ul><li><p>Spotify downloads playlists so they can be played without internet.</p></li><li><p>Notion saves edits locally and syncs them later.</p></li><li><p>Google Maps stores map tiles for offline navigation.</p></li></ul><p>Apps dealing with media, productivity, or travel benefit from this approach.</p><h4><strong>Trade-offs</strong></h4><p>Offline-first systems provide a better user experience, but they are complex to build.</p><p>They require:</p><ul><li><p>Local database to store data</p></li><li><p>Sync system to send and receive updates</p></li><li><p>A way to handle conflicts when local and server data differ</p></li><li><p>Plan for updating the data structure over time</p></li></ul><p>Because of this complexity, an offline-first design usually needs to be planned early in app development.</p><p>Caching helps apps reuse data locally, but another challenge is delivering large files like images and videos efficiently. These files often make up most of the data in app downloads.</p><p>To improve speed and reduce data usage, use techniques like CDNs and media optimisation.</p><h3><strong>14. CDN Strategy &amp; Media Optimisation</strong></h3><p>Images and videos usually make up a large part of the data used by mobile apps.</p><p>To deliver this content quickly and efficiently, apps often rely on Content Delivery Networks (<strong>CDNs</strong>) and various optimisation techniques. A CDN is a network of servers distributed around the world. Instead of downloading content from a central server, the app downloads it from the nearest server, reducing load time.</p><p>While media files can be optimised, the app only downloads what it actually needs.</p><h4><strong>What a CDN Does</strong></h4><p>When a user opens an app and requests an image/video:</p><ol><li><p>The request is sent to the closest CDN server.</p></li><li><p>CDN returns the file from a nearby location instead of a distant server.</p></li><li><p>The content loads faster because the distance and network delay are reduced.</p></li></ol><p>This speeds up and improves the reliability of content delivery, especially for users in different parts of the world.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bpIB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6788c34d-b98c-4d80-a1a8-aef1f92338ad_1451x575.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bpIB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6788c34d-b98c-4d80-a1a8-aef1f92338ad_1451x575.png 424w, https://substackcdn.com/image/fetch/$s_!bpIB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6788c34d-b98c-4d80-a1a8-aef1f92338ad_1451x575.png 848w, https://substackcdn.com/image/fetch/$s_!bpIB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6788c34d-b98c-4d80-a1a8-aef1f92338ad_1451x575.png 1272w, https://substackcdn.com/image/fetch/$s_!bpIB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6788c34d-b98c-4d80-a1a8-aef1f92338ad_1451x575.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bpIB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6788c34d-b98c-4d80-a1a8-aef1f92338ad_1451x575.png" width="1451" height="575" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6788c34d-b98c-4d80-a1a8-aef1f92338ad_1451x575.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:575,&quot;width&quot;:1451,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!bpIB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6788c34d-b98c-4d80-a1a8-aef1f92338ad_1451x575.png 424w, https://substackcdn.com/image/fetch/$s_!bpIB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6788c34d-b98c-4d80-a1a8-aef1f92338ad_1451x575.png 848w, https://substackcdn.com/image/fetch/$s_!bpIB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6788c34d-b98c-4d80-a1a8-aef1f92338ad_1451x575.png 1272w, https://substackcdn.com/image/fetch/$s_!bpIB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6788c34d-b98c-4d80-a1a8-aef1f92338ad_1451x575.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 role="img" 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><title></title><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><h4><strong>Media Optimisation</strong></h4><p>Another important improvement is optimising the size and format of images and videos.</p><p>Some common techniques include:</p><ul><li><p><strong>Image resizing:</strong> Instead of sending a large image (e.g., 4K), the server sends a smaller version that fits the device screen, such as 200&#215;200 pixels.</p></li><li><p><strong>Modern image formats:</strong> Newer formats like WebP or AVIF store images more efficiently than older formats like JPEG or PNG. They provide similar image quality with smaller file sizes.</p></li><li><p><strong>Lazy loading:</strong> Images are loaded only when they are about to appear on the screen. This avoids downloading content that the user might never see.</p></li></ul><p>Together, these techniques significantly reduce data usage and improve loading speed.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WM5e!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3509288-42cf-43d4-9180-acb2aa16f469_1600x478.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WM5e!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3509288-42cf-43d4-9180-acb2aa16f469_1600x478.png 424w, https://substackcdn.com/image/fetch/$s_!WM5e!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3509288-42cf-43d4-9180-acb2aa16f469_1600x478.png 848w, https://substackcdn.com/image/fetch/$s_!WM5e!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3509288-42cf-43d4-9180-acb2aa16f469_1600x478.png 1272w, https://substackcdn.com/image/fetch/$s_!WM5e!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3509288-42cf-43d4-9180-acb2aa16f469_1600x478.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WM5e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3509288-42cf-43d4-9180-acb2aa16f469_1600x478.png" width="1456" height="435" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f3509288-42cf-43d4-9180-acb2aa16f469_1600x478.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:435,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!WM5e!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3509288-42cf-43d4-9180-acb2aa16f469_1600x478.png 424w, https://substackcdn.com/image/fetch/$s_!WM5e!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3509288-42cf-43d4-9180-acb2aa16f469_1600x478.png 848w, https://substackcdn.com/image/fetch/$s_!WM5e!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3509288-42cf-43d4-9180-acb2aa16f469_1600x478.png 1272w, https://substackcdn.com/image/fetch/$s_!WM5e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3509288-42cf-43d4-9180-acb2aa16f469_1600x478.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 role="img" 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><title></title><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><h4><strong>Why It Matters</strong></h4><p>Large media files can slow down apps and consume a lot of mobile data.</p><p>For example, loading a 4MB image on a small phone screen wastes most of its pixels because the device only displays a small portion of the image&#8217;s resolution.</p><p>Serving images that match the device size <a href="https://imageengine.io/improve-pagespeed-image-cdn-vs-traditional-cdn/">can reduce total data usage by up to 80%</a>, making the app faster and more efficient.</p><h4><strong>Real-World Example</strong></h4><p>Many popular apps rely on CDN and media optimisation:</p><ul><li><p>Cloudinary and Imgix dynamically resize images based on URL parameters.</p></li><li><p>Instagram serves images that match the exact resolution of the user&#8217;s device.</p></li><li><p>On modern Android devices, Instagram also uses the AVIF format to reduce image size.</p></li></ul><h4><strong>Trade-offs</strong></h4><p>Using a CDN improves performance but introduces additional cost, as CDN providers charge based on data transfer.</p><p>As a result, CDN assets are usually cached for long periods. Apps often use versioned or hashed URLs to update assets. This process ensures that the new version gets downloaded when needed.</p><h4><strong>Practical Tip</strong></h4><p>To make images appear faster, apps often show a temporary low-quality preview while the full image loads.</p><p>Techniques like <a href="https://blurha.sh/">BlurHash</a> or <a href="https://cloudinary.com/blog/low_quality_image_placeholders_lqip_explained">LQIP (Low Quality Image Placeholder)</a> display a blurred or low-resolution version first. This makes the page feel fast, even before the high-quality image finishes loading.</p><p>Even with strong caching and efficient content delivery, one important challenge remains: <em>keeping cached data accurate and up to date.</em></p><h3><strong>15. Cache Invalidation Strategies</strong></h3><p>Caching helps apps load data faster by storing it locally.</p><p>But cached data can become outdated when the original data on the server changes. Because of this, apps need a way to update or remove old cached data. This process is called <strong>cache invalidation</strong>.</p><p>In simple terms, cache invalidation means deciding when cached data should no longer be used and needs to be refreshed.</p><h4><strong>Why It Matters</strong></h4><p>If outdated data stays in the cache for too long, the app may show incorrect information.</p><p>For example, a user might see an old product price, a deleted message, or an outdated address. In these situations, showing stale cached data can be worse than not using a cache at all.</p><p>That&#8217;s why managing cached data correctly is very important!</p><h4><strong>Common Cache Invalidation Strategies</strong></h4><p>There are several common ways to control when cached data should expire or update:</p><p><strong>a. TTL (Time-To-Live)</strong></p><p>TTL means cached data is only valid for a certain amount of time.</p><p>For example, if a cache has a TTL of 5 minutes, the app will reuse the cached data for five minutes. After that, it must fetch fresh data from the server.</p><p>This approach is simple but may briefly show outdated data.</p><p><strong>b. Event-Driven Invalidation</strong></p><p>In this approach, the server actively tells the app when cached data is no longer valid.</p><p>For example, a product price changes, and the server sends an event to clear or update the cache.</p><p>This ensures the app always shows the latest data, but it requires more complex systems to send these updates.</p><p><strong>c. Stale-While-Revalidate</strong></p><p>This strategy allows the app to show cached data immediately, even if it is slightly outdated.</p><p>The app quietly requests fresh data in the background. When the new data arrives, the cache is updated.</p><p>This approach improves the user experience by loading the app instantly while keeping data up to date.</p><p><strong>d. Versioned URLs</strong></p><p>Sometimes cached assets like images or style sheets are stored for a very long time.</p><p>To update them safely, the filename or URL includes a version or hash.</p><p>Example:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;36849cbe-157e-4e80-82ff-5b71caac2b92&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">style.abc123.css</code></pre></div><p>When the file changes, the version in the URL changes. Because the URL is different, the cache automatically downloads the new file.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eQk5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d7bb3ca-e3b2-4196-929f-f0a1cf9a9173_1471x843.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eQk5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d7bb3ca-e3b2-4196-929f-f0a1cf9a9173_1471x843.png 424w, https://substackcdn.com/image/fetch/$s_!eQk5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d7bb3ca-e3b2-4196-929f-f0a1cf9a9173_1471x843.png 848w, https://substackcdn.com/image/fetch/$s_!eQk5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d7bb3ca-e3b2-4196-929f-f0a1cf9a9173_1471x843.png 1272w, https://substackcdn.com/image/fetch/$s_!eQk5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d7bb3ca-e3b2-4196-929f-f0a1cf9a9173_1471x843.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eQk5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d7bb3ca-e3b2-4196-929f-f0a1cf9a9173_1471x843.png" width="1456" height="834" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8d7bb3ca-e3b2-4196-929f-f0a1cf9a9173_1471x843.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:834,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!eQk5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d7bb3ca-e3b2-4196-929f-f0a1cf9a9173_1471x843.png 424w, https://substackcdn.com/image/fetch/$s_!eQk5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d7bb3ca-e3b2-4196-929f-f0a1cf9a9173_1471x843.png 848w, https://substackcdn.com/image/fetch/$s_!eQk5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d7bb3ca-e3b2-4196-929f-f0a1cf9a9173_1471x843.png 1272w, https://substackcdn.com/image/fetch/$s_!eQk5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d7bb3ca-e3b2-4196-929f-f0a1cf9a9173_1471x843.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 role="img" 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><title></title><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><h4><strong>Real-World Example</strong></h4><p>An e-commerce app might use different caching strategies depending on the data.</p><p>For example:</p><ul><li><p>Product listings may use a TTL of 5 minutes, since a short delay in updates is acceptable.</p></li><li><p>Inventory or pricing data may use event-driven invalidation because it must always be accurate.</p></li><li><p>Static assets, such as images or stylesheets, can use versioned URLs, allowing them to be cached for a long time.</p></li></ul><h4><strong>Trade-offs</strong></h4><p>Each caching strategy has its advantages and limitations:</p><ul><li><p><strong>TTL-based caching:</strong> Simple to implement, but cached data may briefly become outdated.</p></li><li><p><strong>Event-driven invalidation:</strong> Keeps data accurate but requires more complex infrastructure.</p></li><li><p><strong>Stale-while-revalidate:</strong> Makes the app feel fast, but temporarily shows slightly outdated data.</p></li></ul><h4><strong>Important Tip</strong></h4><p>Caches should never have infinite expiration times for data that changes frequently.</p><p>If cached data never expires, the app may continue showing outdated information, making it difficult to detect and debug.</p><p>Once data is cached or fetched, the app also needs a reliable way to store and organise that data locally, which leads to the next part: <em>storage and database design.</em></p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get the full premium newsletter series and max your system design career leverage:</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><hr></div><h1><strong>Storage &amp; Data</strong></h1><p>Mobile apps need efficient ways to store and manage data on the device.</p><p>This section explains how local databases, schema design, and pagination help apps handle large datasets while maintaining smooth performance on resource-limited devices.</p><h3><strong>16. Local Database Design (Schema Modeling)</strong></h3><p>Mobile apps often store data locally on the device so they can load information quickly and continue working even when the network is slow or unavailable.</p><p>To do this, apps use local databases such as SQLite, which is commonly used on both Android and iOS. A database schema simply describes how data is organised in the database. It defines tables, columns, and how different pieces of data are connected.</p><p>Good schema design is important because it helps the app load and display data quickly.</p><h4><strong>How Data Is Often Structured on Mobile</strong></h4><p>On servers, databases are usually designed to avoid duplicating data across many places. This approach is called <strong>normalisation</strong>.</p><p>But mobile apps often use a slightly different approach called <strong>denormalisation</strong>.</p><p>Denormalisation involves storing related data in the same table, enabling quick reads without complex queries.</p><p>This helps mobile apps load data faster because the app does NOT need to combine multiple tables every time it displays information.</p><h4><strong>Why It Matters</strong></h4><p>Mobile apps need to display data quickly.</p><p>For example, imagine an app showing a list of 50,000 messages. If the database is poorly designed, finding the right messages might take much longer than expected.</p><p>A missing <strong>index</strong> (a structure that helps the database locate data quickly) can cause the database to scan every row in a table. This can turn a 1-millisecond query into a 500-millisecond query, causing visible delays or lag in the user interface.</p><p>So the way a database is designed directly affects how smooth the app feels.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KAJK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c075758-73c7-42b9-a870-b96a1d14dc2a_1600x539.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KAJK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c075758-73c7-42b9-a870-b96a1d14dc2a_1600x539.png 424w, https://substackcdn.com/image/fetch/$s_!KAJK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c075758-73c7-42b9-a870-b96a1d14dc2a_1600x539.png 848w, https://substackcdn.com/image/fetch/$s_!KAJK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c075758-73c7-42b9-a870-b96a1d14dc2a_1600x539.png 1272w, https://substackcdn.com/image/fetch/$s_!KAJK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c075758-73c7-42b9-a870-b96a1d14dc2a_1600x539.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KAJK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c075758-73c7-42b9-a870-b96a1d14dc2a_1600x539.png" width="1456" height="490" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6c075758-73c7-42b9-a870-b96a1d14dc2a_1600x539.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:490,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!KAJK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c075758-73c7-42b9-a870-b96a1d14dc2a_1600x539.png 424w, https://substackcdn.com/image/fetch/$s_!KAJK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c075758-73c7-42b9-a870-b96a1d14dc2a_1600x539.png 848w, https://substackcdn.com/image/fetch/$s_!KAJK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c075758-73c7-42b9-a870-b96a1d14dc2a_1600x539.png 1272w, https://substackcdn.com/image/fetch/$s_!KAJK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c075758-73c7-42b9-a870-b96a1d14dc2a_1600x539.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 role="img" 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><title></title><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><h4><strong>Real-World Example</strong></h4><p>Consider a messaging app.</p><p>Instead of storing only a user ID with each message, the app may also store the sender&#8217;s name and profile image directly inside the message record.</p><p>This means the app can display messages immediately without looking up additional data from another table.</p><p>This approach speeds up loading when thousands of messages need to be shown quickly.</p><h4><strong>Trade-offs</strong></h4><p>Each database design approach has advantages and disadvantages:</p><ul><li><p><strong>Denormalised structure: </strong>Faster data reading and works well for displaying lists in the UI, but updating repeated data can be harder. For example, if a user changes their name, multiple records may need to be updated.</p></li><li><p><strong>Normalised structure: </strong>Cleaner, more organised, and easier to maintain consistent data, but requires more complex queries, which may slow down UI rendering.</p></li></ul><p>Because mobile apps mostly read data to display it on the screen, they often prefer denormalised structures for faster reads.</p><h4><strong>Practical Tip</strong></h4><p>When writing many records to the database, it&#8217;s usually faster to group them into a single transaction.</p><p>Instead of saving each item one by one, the app saves many items together in a single operation. This reduces overhead and makes database writes much more efficient.</p><p>As apps grow and evolve over time, the database structure may need to change as well. Because of this, apps must handle database schema updates carefully, which leads to the next topic: <em>schema migration strategies.</em></p><h3><strong>17. Schema Migration Strategy</strong></h3><p>Mobile apps often store data in a local database on the device.</p><p>Over time, the app may change how this data is structured. For example, a new version of the app might add a new column, change a table, or introduce new data fields.</p><p>When this happens, the database structure must be updated safely. This process is called <strong>schema migration</strong>.</p><p>A schema migration ensures that the existing database on a user&#8217;s device is updated to match the new version of the app.</p><h4><strong>Why It Matters</strong></h4><p>Unlike a web server, mobile databases exist on millions of individual devices that developers cannot directly control.</p><p>Some users may update the app immediately, while others may skip several versions before updating. For example, a user installs version 1 of an app and later updates directly to version 5.</p><p>The database must correctly apply every change that happened between those versions. So the migrations must run step-by-step:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;b17fbb8a-048a-4455-a49f-9b445d37fb20&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">1 &#8594; 2 &#8594; 3 &#8594; 4 &#8594; 5</code></pre></div><p>If a migration fails, the app may crash on launch. Because the database exists on the user&#8217;s device, fixing it later can be difficult&#8230;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qDff!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e41d26f-d812-4eb4-9d94-78b3ae1c39db_1600x599.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qDff!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e41d26f-d812-4eb4-9d94-78b3ae1c39db_1600x599.png 424w, https://substackcdn.com/image/fetch/$s_!qDff!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e41d26f-d812-4eb4-9d94-78b3ae1c39db_1600x599.png 848w, https://substackcdn.com/image/fetch/$s_!qDff!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e41d26f-d812-4eb4-9d94-78b3ae1c39db_1600x599.png 1272w, https://substackcdn.com/image/fetch/$s_!qDff!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e41d26f-d812-4eb4-9d94-78b3ae1c39db_1600x599.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qDff!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e41d26f-d812-4eb4-9d94-78b3ae1c39db_1600x599.png" width="1456" height="545" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7e41d26f-d812-4eb4-9d94-78b3ae1c39db_1600x599.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:545,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!qDff!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e41d26f-d812-4eb4-9d94-78b3ae1c39db_1600x599.png 424w, https://substackcdn.com/image/fetch/$s_!qDff!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e41d26f-d812-4eb4-9d94-78b3ae1c39db_1600x599.png 848w, https://substackcdn.com/image/fetch/$s_!qDff!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e41d26f-d812-4eb4-9d94-78b3ae1c39db_1600x599.png 1272w, https://substackcdn.com/image/fetch/$s_!qDff!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e41d26f-d812-4eb4-9d94-78b3ae1c39db_1600x599.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 role="img" 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><title></title><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><h4><strong>Real-World Example</strong></h4><p>Many mobile frameworks provide tools to manage database migrations.</p><p>For example, Room on Android requires every database version to define how the schema should be updated.</p><p>This helps prevent mistakes where the app changes the database structure without providing a safe upgrade path.</p><h4><strong>Trade-offs</strong></h4><p>There are two main ways to handle schema changes:</p><p><strong>a. Destructive Migration</strong></p><p>In this approach, the app deletes the existing database and creates a new one.</p><p>This is simple and safe for the app structure, but it removes all locally stored data.</p><p><strong>b. Additive Migration</strong></p><p>In this approach, the database is updated without deleting existing data.</p><p>For example, adding new columns, adding new tables, and keeping old data intact.</p><p>This method is usually preferred because it preserves user data.</p><h4><strong>Practical Tip</strong></h4><p>Sometimes migrations may fail due to issues like a corrupted database.</p><p>In these situations, it is better for the app to reset the database and re-download the data from the server rather than crash. Losing cached data can be recovered, but an app that keeps crashing when it starts creates a much worse experience.</p><p>As apps handle larger amounts of stored data, another important challenge appears: loading and displaying large datasets efficiently, which is where pagination becomes useful.</p><h3><strong>18. Pagination (Cursor vs Offset vs Page Number)</strong></h3><p>Mobile apps often display long lists of data, such as messages, posts, products, or search results.</p><p>Sometimes these lists can contain thousands of items.</p><p>Loading all of that data at once would be slow and would use a lot of memory. Because of this, apps usually load data in smaller chunks called <strong>pages</strong>. This technique is called <strong>pagination</strong>.</p><p>Pagination helps apps load content gradually as users scroll, keeping the app fast and responsive.</p><h4><strong>How It Works</strong></h4><p>Instead of loading everything at once, the app requests a small set of items at a time.</p><p>For example:</p><ol><li><p>App requests page 1 of data.</p></li><li><p>The server returns the first group of items.</p></li><li><p>When the user scrolls further, the app requests the next page.</p></li></ol><p>This process continues until the user reaches the end of the list&#8230;</p><h4><strong>Common Pagination Methods</strong></h4><p>There are three common ways to implement pagination:</p><p><strong>a. Page Number Pagination</strong></p><p>This is the simplest method. The client requests data using page numbers.</p><p>For example:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;0d9e305f-49d1-40ac-ba44-a2ae93b7ab5d&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">?page=1
?page=2
?page=3</code></pre></div><p>Each page contains a fixed number of items.</p><p>This approach is easy to understand and works well for things like search results or product listings.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5J9w!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41040c41-f786-4d9f-848a-d25bead94c58_1376x530.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5J9w!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41040c41-f786-4d9f-848a-d25bead94c58_1376x530.png 424w, https://substackcdn.com/image/fetch/$s_!5J9w!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41040c41-f786-4d9f-848a-d25bead94c58_1376x530.png 848w, https://substackcdn.com/image/fetch/$s_!5J9w!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41040c41-f786-4d9f-848a-d25bead94c58_1376x530.png 1272w, https://substackcdn.com/image/fetch/$s_!5J9w!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41040c41-f786-4d9f-848a-d25bead94c58_1376x530.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5J9w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41040c41-f786-4d9f-848a-d25bead94c58_1376x530.png" width="1376" height="530" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/41040c41-f786-4d9f-848a-d25bead94c58_1376x530.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:530,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!5J9w!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41040c41-f786-4d9f-848a-d25bead94c58_1376x530.png 424w, https://substackcdn.com/image/fetch/$s_!5J9w!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41040c41-f786-4d9f-848a-d25bead94c58_1376x530.png 848w, https://substackcdn.com/image/fetch/$s_!5J9w!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41040c41-f786-4d9f-848a-d25bead94c58_1376x530.png 1272w, https://substackcdn.com/image/fetch/$s_!5J9w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41040c41-f786-4d9f-848a-d25bead94c58_1376x530.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 role="img" 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><title></title><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>b. Offset Pagination</strong></p><p>Offset pagination retrieves data starting from a specific position.</p><p>For example:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;56c6dff5-cfe3-422a-b9e7-8f2273a3da26&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">?limit=20&amp;offset=40</code></pre></div><p>This means skip the first 40 items and return the next 20 items.</p><p>This method works well for static data, but dynamically adding new items while the user is browsing can cause problems.</p><p>For example, if new posts appear at the top of a feed, the list may show duplicate items or skip items.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L_0v!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465bb9eb-0156-4845-a4bb-1cbcc2d4d375_1204x646.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L_0v!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465bb9eb-0156-4845-a4bb-1cbcc2d4d375_1204x646.png 424w, https://substackcdn.com/image/fetch/$s_!L_0v!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465bb9eb-0156-4845-a4bb-1cbcc2d4d375_1204x646.png 848w, https://substackcdn.com/image/fetch/$s_!L_0v!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465bb9eb-0156-4845-a4bb-1cbcc2d4d375_1204x646.png 1272w, https://substackcdn.com/image/fetch/$s_!L_0v!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465bb9eb-0156-4845-a4bb-1cbcc2d4d375_1204x646.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L_0v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465bb9eb-0156-4845-a4bb-1cbcc2d4d375_1204x646.png" width="1204" height="646" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/465bb9eb-0156-4845-a4bb-1cbcc2d4d375_1204x646.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:646,&quot;width&quot;:1204,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!L_0v!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465bb9eb-0156-4845-a4bb-1cbcc2d4d375_1204x646.png 424w, https://substackcdn.com/image/fetch/$s_!L_0v!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465bb9eb-0156-4845-a4bb-1cbcc2d4d375_1204x646.png 848w, https://substackcdn.com/image/fetch/$s_!L_0v!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465bb9eb-0156-4845-a4bb-1cbcc2d4d375_1204x646.png 1272w, https://substackcdn.com/image/fetch/$s_!L_0v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465bb9eb-0156-4845-a4bb-1cbcc2d4d375_1204x646.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 role="img" 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><title></title><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>c. Cursor Pagination</strong></p><p>Cursor pagination uses a <strong>cursor token</strong> that represents the last item the user has seen. Instead of requesting a page number, the app requests the next items after a specific position.</p><p>For example:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;49268bda-9d4c-4dd7-8d9e-abc8bfcb380a&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">next_cursor = &#8220;abc123&#8221;</code></pre></div><p>Then the next request might look like:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;100a9965-3647-4caa-9c40-b67138417ae6&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">?after=abc123</code></pre></div><p>The cursor usually represents a stable value, such as the ID or timestamp of the last item. This approach works well for data that constantly changes, such as social media feeds.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!27_3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b12a6d8-c01a-4f7b-967c-a714b152ce3a_1146x513.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!27_3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b12a6d8-c01a-4f7b-967c-a714b152ce3a_1146x513.png 424w, https://substackcdn.com/image/fetch/$s_!27_3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b12a6d8-c01a-4f7b-967c-a714b152ce3a_1146x513.png 848w, https://substackcdn.com/image/fetch/$s_!27_3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b12a6d8-c01a-4f7b-967c-a714b152ce3a_1146x513.png 1272w, https://substackcdn.com/image/fetch/$s_!27_3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b12a6d8-c01a-4f7b-967c-a714b152ce3a_1146x513.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!27_3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b12a6d8-c01a-4f7b-967c-a714b152ce3a_1146x513.png" width="1146" height="513" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1b12a6d8-c01a-4f7b-967c-a714b152ce3a_1146x513.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:513,&quot;width&quot;:1146,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!27_3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b12a6d8-c01a-4f7b-967c-a714b152ce3a_1146x513.png 424w, https://substackcdn.com/image/fetch/$s_!27_3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b12a6d8-c01a-4f7b-967c-a714b152ce3a_1146x513.png 848w, https://substackcdn.com/image/fetch/$s_!27_3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b12a6d8-c01a-4f7b-967c-a714b152ce3a_1146x513.png 1272w, https://substackcdn.com/image/fetch/$s_!27_3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b12a6d8-c01a-4f7b-967c-a714b152ce3a_1146x513.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 role="img" 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><title></title><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><h4><strong>Why It Matters</strong></h4><p>Imagine a social feed with 10,000 posts. If the app tried to load everything at once:</p><ul><li><p>The request would take a long time</p></li><li><p>Rendering the UI would be slow</p></li><li><p>Device might run out of memory</p></li></ul><p>Pagination solves this by loading only a small portion of the data at a time, which keeps scrolling smooth.</p><h4><strong>Real-World Example</strong></h4><p>Many popular apps, such as Twitter, Instagram, and TikTok, rely on cursor-based pagination.</p><p>These apps load new posts as the user scrolls, using a cursor that points to the last item that was displayed.</p><p>This ensures the feed remains stable even when new posts appear&#8230;</p><h4><strong>Trade-offs</strong></h4><p>Each pagination method has advantages and limitations:</p><ul><li><p><strong>Page number pagination: </strong>Simple to understand and works well for search results, but less efficient for large datasets.</p></li><li><p><strong>Offset pagination: </strong>Easy to implement and allows jumping to any position, but it can break when new data is inserted.</p></li><li><p><strong>Cursor pagination: </strong>Stable and efficient for live feeds and prevents duplicates and skipped items, but does not easily support jumping directly to a specific page.</p></li></ul><p>Because mobile devices have limited memory and storage, loading and storing data must be done carefully! Therefore, it&#8217;s important to design efficient data models that work well within these constraints.</p><h3><strong>19. Data Modeling for Mobile Constraints</strong></h3><p>Mobile apps often store data locally on the device so they can load information quickly and continue working even when the network is slow.</p><p>Yet mobile devices have limited storage, CPU power, and battery, so the way data is structured must be carefully designed.</p><p>Because of these limits, mobile apps usually store and organise data to help the UI load quickly, even if it means repeating some information.</p><h4><strong>Things Mobile Data Models Must Consider</strong></h4><p>When designing data models for mobile apps, several important constraints should be considered:</p><p><strong>a. Limited storage</strong></p><p>Mobile devices cannot store unlimited data.</p><p>Apps should avoid caching everything and instead remove old or unused data after a period of time. For example, an app might store cached data for a few hours or days, then automatically delete it.</p><p><strong>b. CPU performance</strong></p><p>Complex database queries can slow down the app.</p><p>Queries that join many tables may take longer to process. To keep the app fast, store related data together so the app can read it quickly without performing complicated queries.</p><p><strong>c. Battery usage</strong></p><p>Every time an app writes data to disk, it uses battery power.</p><p>Frequent database writes can drain the battery over time. Because of this, apps try to minimise unnecessary writes and batch operations when possible.</p><h4><strong>Why It Matters</strong></h4><p>Data models used on backend servers are usually designed to save storage space and keep data perfectly structured.</p><p>But mobile apps have a different goal: <em>fast rendering on the screen</em>.</p><p>This means the data model on mobile may look different from the backend data model, because it&#8217;s optimised for speed and user experience rather than strict structure.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!T5xu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66021ef4-e515-4be6-aa4d-eb034dc30976_1450x726.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!T5xu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66021ef4-e515-4be6-aa4d-eb034dc30976_1450x726.png 424w, https://substackcdn.com/image/fetch/$s_!T5xu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66021ef4-e515-4be6-aa4d-eb034dc30976_1450x726.png 848w, https://substackcdn.com/image/fetch/$s_!T5xu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66021ef4-e515-4be6-aa4d-eb034dc30976_1450x726.png 1272w, https://substackcdn.com/image/fetch/$s_!T5xu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66021ef4-e515-4be6-aa4d-eb034dc30976_1450x726.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!T5xu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66021ef4-e515-4be6-aa4d-eb034dc30976_1450x726.png" width="1450" height="726" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/66021ef4-e515-4be6-aa4d-eb034dc30976_1450x726.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:726,&quot;width&quot;:1450,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!T5xu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66021ef4-e515-4be6-aa4d-eb034dc30976_1450x726.png 424w, https://substackcdn.com/image/fetch/$s_!T5xu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66021ef4-e515-4be6-aa4d-eb034dc30976_1450x726.png 848w, https://substackcdn.com/image/fetch/$s_!T5xu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66021ef4-e515-4be6-aa4d-eb034dc30976_1450x726.png 1272w, https://substackcdn.com/image/fetch/$s_!T5xu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66021ef4-e515-4be6-aa4d-eb034dc30976_1450x726.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 role="img" 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><title></title><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><h4><strong>Real-World Example</strong></h4><p>Imagine a contacts app that shows a list of people.</p><p>Instead of calculating everything each time the list loads, the app may store some information in advance, such as display name, profile picture URL, and the first letter used for alphabetical sections.</p><p>Because this information is already stored, the app can render the list instantly without performing extra calculations.</p><h4><strong>Trade-offs</strong></h4><p>Storing extra or pre-computed data improves speed, but it also has some downsides.</p><p>Pre-computed data uses more storage space and must be updated whenever the original data changes.</p><p>Yet this trade-off is usually acceptable because storage is relatively cheap, while slow or laggy interfaces are immediately noticeable to users.</p><div><hr></div><h2><strong>Final Words</strong></h2><p>None of these concepts works on its own.</p><p>The choices you make in one area affect everything else. Networking affects caching, caching affects sync, and sync affects how conflicts are handled.</p><p>It&#8217;s all connected.</p><p>The best engineers aren&#8217;t the ones who know the most concepts. They&#8217;re the ones who understand the tradeoffs and know when to use what.</p><p>So remember this:</p><p><em>Start simple. Add complexity only when you really need it. And when that time comes, you&#8217;ll know what to use.</em></p><div><hr></div><p>&#128075; I&#8217;d like to thank <strong><a href="https://x.com/Shefali__J">Shefali</a></strong> for writing this newsletter!</p><p>Plus, don&#8217;t forget to check out her work and socials:</p><ul><li><p><a href="https://shefali.dev/">Shefali.dev</a></p></li><li><p><a href="https://github.com/WebdevShefali">GitHub</a></p></li><li><p><a href="https://x.com/Shefali__J">Twitter</a></p></li></ul><p>You&#8217;ll often find her writing about web development, sharing UI tips, and building tools that make developers&#8217; lives easier.</p><div><hr></div><p>Get the full <em>premium</em> newsletter series and max your system design career leverage:</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p><p>Plus, there are <a href="http://newsletter.systemdesign.one/subscribe?group=true">group discounts</a>, <a href="http://newsletter.systemdesign.one/subscribe?gift=true">gift options</a>, and <a href="https://newsletter.systemdesign.one/leaderboard">referral rewards</a> available.</p><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://www.linkedin.com/in/nk-systemdesign-one/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png" width="152" height="152" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:320,&quot;width&quot;:320,&quot;resizeWidth&quot;:152,&quot;bytes&quot;:74009,&quot;alt&quot;:&quot;Author Neo Kim; System design case studies&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://www.linkedin.com/in/nk-systemdesign-one/&quot;,&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="Author Neo Kim; System design case studies" title="Author Neo Kim; System design case studies" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption"><strong>&#128075; Find me on <a href="https://www.linkedin.com/in/nk-systemdesign-one/">LinkedIn</a> | <a href="https://x.com/intent/follow?screen_name=systemdesignone">Twitter</a> | <a href="https://www.threads.net/@systemdesignone">Threads</a> | <a href="https://www.instagram.com/systemdesignone/">Instagram</a></strong></figcaption></figure></div><div><hr></div><p><strong>Want to reach 210K+ tech professionals at scale? </strong>&#128240;</p><p>If your company wants to reach 210K+ tech professionals, <a href="https://newsletter.systemdesign.one/p/sponsorship">advertise with me</a>.</p><div><hr></div><p>Thank you for supporting this newsletter.</p><p>You are now 210,001+ readers strong, very close to 210k. Let&#8217;s try to get 211k readers by 27 March. Consider sharing this post with your friends and get rewards.</p><p>Y&#8217;all are the best.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6oWl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" width="590" height="368.75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:800,&quot;resizeWidth&quot;:590,&quot;bytes&quot;:87878,&quot;alt&quot;:&quot;system design newsletter&quot;,&quot;title&quot;:&quot;system design newsletter&quot;,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/163380418?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="system design newsletter" title="system design newsletter" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.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 role="img" 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><title></title><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 class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/mobile-system-design?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/mobile-system-design?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><ul><li><p>Block diagrams created using <a href="https://app.eraser.io/auth/sign-up?ref=neo">Eraser</a>.</p></li></ul>]]></content:encoded></item><item><title><![CDATA[The Mobile Engineer's Guide to System Design Interviews]]></title><description><![CDATA[#134: Mobile System Design Interview]]></description><link>https://newsletter.systemdesign.one/p/mobile-system-design-interview</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/mobile-system-design-interview</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Tue, 24 Mar 2026 13:40:42 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/6968c1a0-7187-4c26-ab1b-c0c731466554_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/mobile-system-design-interview/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>You&#8217;ve probably been there: You&#8217;re sitting across from two engineers (or staring at them through a webcam), and they&#8217;ve just asked you to design Instagram&#8217;s feed. Or a ride-sharing app. Or some chat system with offline support and end-to-end encryption.</p><p>The clock is ticking&#8230;</p><p>You have 45 minutes to turn a vague prompt into something that looks like you know what you&#8217;re doing.</p><p>Your mind races: <em>Where do I even start? Do I draw boxes first? Ask about the user numbers? Talk about databases? What if I forget something critical?</em></p><p>Most mobile engineers don&#8217;t realize this about system design interviews: <strong>They&#8217;re NOT testing whether you can build Instagram.</strong> They&#8217;re testing whether you can take something fuzzy and turn it into something concrete.</p><p>This is the same skill you use every day when your PM says, <em>&#8220;We need push notifications,&#8221;</em> or your designer drops a Figma file in Slack with the message <em>&#8220;Thoughts?</em>&#8221; in your day job.</p><div><hr></div><h4 style="text-align: justify;"><strong><a href="https://platform.minimax.io/">12% OFF MiniMax M2.7 - The SOTA Cowork Agent Model That Just Outranked Opus and Gemini 3.1. (Partner)</a></strong></h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://platform.minimax.io" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4CuL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61da77e5-6a17-4176-9714-ed285e414a98_1600x795.png 424w, https://substackcdn.com/image/fetch/$s_!4CuL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61da77e5-6a17-4176-9714-ed285e414a98_1600x795.png 848w, https://substackcdn.com/image/fetch/$s_!4CuL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61da77e5-6a17-4176-9714-ed285e414a98_1600x795.png 1272w, https://substackcdn.com/image/fetch/$s_!4CuL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61da77e5-6a17-4176-9714-ed285e414a98_1600x795.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4CuL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61da77e5-6a17-4176-9714-ed285e414a98_1600x795.png" width="1456" height="723" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/61da77e5-6a17-4176-9714-ed285e414a98_1600x795.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:723,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://platform.minimax.io&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!4CuL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61da77e5-6a17-4176-9714-ed285e414a98_1600x795.png 424w, https://substackcdn.com/image/fetch/$s_!4CuL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61da77e5-6a17-4176-9714-ed285e414a98_1600x795.png 848w, https://substackcdn.com/image/fetch/$s_!4CuL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61da77e5-6a17-4176-9714-ed285e414a98_1600x795.png 1272w, https://substackcdn.com/image/fetch/$s_!4CuL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61da77e5-6a17-4176-9714-ed285e414a98_1600x795.png 1456w" sizes="100vw" loading="lazy" 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 role="img" 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><title></title><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 style="text-align: justify;"><strong><a href="https://platform.minimax.io/subscribe/coding-plan?code=KGlGYHegnw&amp;source=link">MiniMax M2.7</a></strong> is here, and it&#8217;s unlike any agent model released before it.</p><p style="text-align: justify;">Built on their proprietary SOTA Cowork Agent Model architecture, M2.7 shows early echoes of self-evolution: the ability to follow complex, layered instructions across long workflows without losing the thread.</p><p style="text-align: justify;">At 5 tools, every model looks sharp.</p><p style="text-align: justify;">At 40, almost all fall apart silently.</p><p style="text-align: justify;">Wrong tool invoked. Step missed. No error thrown. You find out 3 days post-deploy.</p><p style="text-align: justify;">M2.7 was tested across 40 complex skills, each exceeding 2,000 tokens.<br>Skill adherence rate: 97%.</p><p style="text-align: justify;">Here&#8217;s what that looks like in production:</p><ul><li><p>Alert fires &#8594; metrics correlated &#8594; root cause traced across systems</p></li><li><p>DB queried to verify &#8594; fix submitted</p></li><li><p>Recovery time: under 3 minutes. Manual process: 4+ hours.</p></li></ul><p style="text-align: justify;">Most models are built to write code.</p><p style="text-align: justify;">M2.7 is built to understand your production systems.</p><p style="text-align: justify;">And it ships inside something new: the world&#8217;s first subscription plan for an all-modality-capable model. One API key covers M2.7, Speech, Image, Video, and Music generation; the full stack, no provider switching.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://platform.minimax.io/subscribe/coding-plan?code=KGlGYHegnw&amp;source=link&quot;,&quot;text&quot;:&quot;MiniMax Token Plan 12% OFF&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://platform.minimax.io/subscribe/coding-plan?code=KGlGYHegnw&amp;source=link"><span>MiniMax Token Plan 12% OFF</span></a></p><div><hr></div><p>I want to introduce <strong><a href="https://www.linkedin.com/in/tjeerdintveen/">Tjeerd in &#8216;t Veen</a></strong> as the guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://www.mobilesystemdesign.com/book" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cuNb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb1c7e4b-6898-4d5c-98c1-79db5b9a9675_1238x581.png 424w, https://substackcdn.com/image/fetch/$s_!cuNb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb1c7e4b-6898-4d5c-98c1-79db5b9a9675_1238x581.png 848w, https://substackcdn.com/image/fetch/$s_!cuNb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb1c7e4b-6898-4d5c-98c1-79db5b9a9675_1238x581.png 1272w, https://substackcdn.com/image/fetch/$s_!cuNb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb1c7e4b-6898-4d5c-98c1-79db5b9a9675_1238x581.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cuNb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb1c7e4b-6898-4d5c-98c1-79db5b9a9675_1238x581.png" width="1238" height="581" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/db1c7e4b-6898-4d5c-98c1-79db5b9a9675_1238x581.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:581,&quot;width&quot;:1238,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://www.mobilesystemdesign.com/book&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!cuNb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb1c7e4b-6898-4d5c-98c1-79db5b9a9675_1238x581.png 424w, https://substackcdn.com/image/fetch/$s_!cuNb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb1c7e4b-6898-4d5c-98c1-79db5b9a9675_1238x581.png 848w, https://substackcdn.com/image/fetch/$s_!cuNb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb1c7e4b-6898-4d5c-98c1-79db5b9a9675_1238x581.png 1272w, https://substackcdn.com/image/fetch/$s_!cuNb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb1c7e4b-6898-4d5c-98c1-79db5b9a9675_1238x581.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 role="img" 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><title></title><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>He recently released the <strong><a href="https://www.mobilesystemdesign.com/book">Mobile System Design book bundle</a></strong> based on years of interviewing mobile engineers and building large-scale mobile apps. This newsletter distills the core process (framework) from the books into something you can use to prep for interviews or plan features at work.</p><p>If you want to go deeper, the <a href="https://www.mobilesystemdesign.com/book">full book bundle</a> has more examples, detailed architecture patterns, and code-level implementation strategies. </p><div><hr></div><h2>What this newsletter covers</h2><p>There are plenty of great general system design guides. This one is about mobile constraints and how they shape the architecture.</p><p>This newsletter walks through the actual process:</p><ul><li><p>How to take a vague prompt and figure out what the interviewer <em>actually</em> wants</p></li><li><p>How to uncover the hidden requirements nobody mentioned (because they&#8217;re testing if <em>you&#8217;ll</em> think of them)</p></li><li><p>How to structure your thinking so you don&#8217;t forget the mobile-specific stuff (offline state, battery drain, app lifecycle, memory constraints)</p></li><li><p>How to turn abstract architecture talk into concrete implementation details</p></li></ul><p>This works whether you&#8217;re in an interview or planning a real feature at work.</p><p>The process is the same.</p><div><hr></div><h2>Who this is for</h2><p>If you&#8217;re a mobile engineer (iOS, Android, Flutter, React Native, etc.) and you need to:</p><ul><li><p>Prepare for system design interviews</p></li><li><p>Stop feeling like you&#8217;re fumbling when asked to &#8220;design something.&#8221;</p></li><li><p>Learn how to think through mobile architecture in a structured way</p></li><li><p>Get good at turning vague requirements into actual plans</p></li></ul><p>Then this is for you&#8230;</p><p>I&#8217;m assuming you already know how to develop mobile apps. You understand the basics of networking, data persistence, and why you shouldn&#8217;t do heavy work on the main thread. You&#8217;ve shipped something to production and dealt with the consequences.</p><p>What you might not have is a structured way to <em>think</em> about system design. That&#8217;s what we&#8217;re covering here&#8230;</p><div><hr></div><h1>Interview Structure</h1><p>Let&#8217;s talk about what actually happens in a mobile system design interview:</p><p>The format can vary wildly between companies. Some give you 45 minutes, others give you 60. Some want you on a whiteboard, others use tools like <a href="https://codesignal.com">CodeSignal</a> or <a href="https://www.hackerrank.com">HackerRank</a>. Some companies even ask backend system design questions in mobile interviews, which is a separate discussion entirely.</p><p>But most mobile-focused interviews follow a similar arc.</p><p>Here&#8217;s what you can typically expect&#8230;</p><div><hr></div><h2>Typical flow</h2><p>Most interviews break down roughly like this:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mmwm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F961017fd-3581-4a7e-8f46-d141979a981a_1052x181.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mmwm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F961017fd-3581-4a7e-8f46-d141979a981a_1052x181.png 424w, https://substackcdn.com/image/fetch/$s_!mmwm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F961017fd-3581-4a7e-8f46-d141979a981a_1052x181.png 848w, https://substackcdn.com/image/fetch/$s_!mmwm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F961017fd-3581-4a7e-8f46-d141979a981a_1052x181.png 1272w, https://substackcdn.com/image/fetch/$s_!mmwm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F961017fd-3581-4a7e-8f46-d141979a981a_1052x181.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mmwm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F961017fd-3581-4a7e-8f46-d141979a981a_1052x181.png" width="1052" height="181" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/961017fd-3581-4a7e-8f46-d141979a981a_1052x181.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:181,&quot;width&quot;:1052,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!mmwm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F961017fd-3581-4a7e-8f46-d141979a981a_1052x181.png 424w, https://substackcdn.com/image/fetch/$s_!mmwm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F961017fd-3581-4a7e-8f46-d141979a981a_1052x181.png 848w, https://substackcdn.com/image/fetch/$s_!mmwm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F961017fd-3581-4a7e-8f46-d141979a981a_1052x181.png 1272w, https://substackcdn.com/image/fetch/$s_!mmwm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F961017fd-3581-4a7e-8f46-d141979a981a_1052x181.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>At a high level, the flow is:</p><ul><li><p>Requirements and scope (5-10 minutes): clarify what you&#8217;re designing and the constraints</p></li><li><p>API and data needs (5-10 minutes): define what the app needs from the server</p></li><li><p>Architecture (10-15 minutes): outline client components and data flow</p></li><li><p>Deep dive (15-20 minutes): walk one critical flow or adjust for a new constraint</p></li><li><p>Wrap-up (1-5 minutes): summarize decisions and tradeoffs</p></li></ul><p>I&#8217;ll go deep on how to execute each phase in the next section&#8230;</p><div><hr></div><h2>What&#8217;s expected at different levels</h2><p>Interviewers don&#8217;t judge all mobile engineers the same way.</p><p>Here&#8217;s what interviewers are actually looking for based on your level:</p><h3>Junior to mid-level engineers</h3><p>You&#8217;re expected to:</p><ul><li><p>Ask clarifying questions (even if they seem obvious)</p></li><li><p>Draw a reasonable architecture diagram without major gaps</p></li><li><p>Explain common mobile patterns (caching, background tasks, handling lifecycle)</p></li><li><p>Discuss basic tradeoffs - <em>&#8221;This approach is simpler but uses more memory.&#8221;</em></p></li></ul><p>You&#8217;re <em>not</em> expected to:</p><ul><li><p>Know every edge case off the top of your head</p></li><li><p>Have opinions on monorepo versus multi-repo</p></li><li><p>Design for 100 million users on day one</p></li></ul><p><strong>If you get stuck on something complex (like offline conflict resolution), just say so. </strong><em>&#8220;I haven&#8217;t built a system that merges offline edits before, but I&#8217;d start with last-write-wins and ask about requirements,&#8221;</em> is fine.</p><p>Honesty beats bullshitting.</p><h3>Senior engineers</h3><p>Everything from junior/mid, plus:</p><ul><li><p>Proactively uncover hidden requirements without prompting - <em>&#8221;What about users on limited data plans?&#8221;</em></p></li><li><p>Propose architecture with clear reasoning for your choices - <em>&#8221;I&#8217;m using a repository pattern here because we need to support offline-first&#8221;</em></p></li><li><p>Demonstrate deep knowledge of mobile-specific challenges (app lifecycle, memory pressure, battery drain, offline sync)</p></li><li><p>Adapt when requirements change mid-interview - <em>&#8221;Okay, if we need to support 50MB video uploads, we&#8217;ll need background upload with chunking&#8230;&#8221;</em></p></li></ul><p><em><strong>You should drive the conversation.</strong></em></p><p>The interviewer shouldn&#8217;t have to pull answers out of you.</p><h3>Staff and principal engineers</h3><p>Everything from senior, plus:</p><ul><li><p>Frame the problem: <em>&#8220;Before we design this, let&#8217;s talk about whether we even need offline support for this use case.&#8221;</em></p></li><li><p>Consider team structure: <em>&#8220;If we structure this as a separate module, we can have one team own it independently.&#8221;</em></p></li><li><p>Think long-term: <em>&#8220;This works for v1, but if we add feature X later, we&#8217;ll need to refactor. Let&#8217;s design for that now.&#8221;</em></p></li><li><p>Make architectural tradeoffs at the system level: modularization strategy, build times, deployment, backward compatibility</p></li></ul><p><strong>You&#8217;re expected to think like a tech lead or architect</strong>, not just an IC implementing a feature. The interviewer wants to see if you can make decisions that affect the entire team or org.</p><p>Now that you know what the interview <em>structure</em> looks like, let&#8217;s talk about the actual <em>process</em> you&#8217;ll use during those 45 minutes.</p><div><hr></div><h1>Core Process</h1><p>The interview structure gives you the timeline. But what do you actually <em>do</em> in each phase?</p><p>This is the process you&#8217;ll follow, roughly in order, during the first 30-40 minutes of the interview. Think of it as a checklist for making sure you forget nothing critical.</p><p>You won&#8217;t always do these steps in exactly this order. Sometimes you&#8217;ll jump back and forth. Sometimes the interviewer will steer you in a different direction. That&#8217;s fine.</p><p>But this is the general flow that works:</p><div><hr></div><h2>A reusable pattern (applies to every step)</h2><p>Most steps look different, but the rhythm is the same:</p><ul><li><p>Ask 2-3 high-impact questions before designing.</p></li><li><p>Restate what you heard and get a clear &#8220;<em>yes</em>.&#8221;</p></li><li><p>Write down decisions: constraints, must-haves versus nice-to-haves, and open questions.</p></li><li><p>Call out red flags early instead of waiting.</p></li><li><p>You don&#8217;t have to solve everything on the spot. Show you see the issue, pick a reasonable tradeoff, and move on.</p></li></ul><div><hr></div><h2>Capturing the briefing</h2><p>Here&#8217;s how most system design interviews start:</p><p>The interviewer says something like, <em>&#8220;Design a feed for a social media app,&#8221; </em>or<em> &#8220;Build a way for users to share photos with friends.&#8221;</em></p><p>And your brain immediately starts racing: <em>Should I ask about the backend? Should I start drawing? What if I forget to mention caching?</em></p><p>Before you do any of that, pause.</p><p><em><strong>Your first job is not to design anything. It&#8217;s understanding what you&#8217;re being asked to design.</strong></em></p><p>This sounds obvious, but most candidates blow past this step in 60 seconds and then spend 40 minutes designing the wrong thing&#8230;</p><div><hr></div><h3>What you&#8217;re actually trying to do</h3><p>In the first 5-10 minutes, you&#8217;re trying to turn a vague prompt into something concrete enough that you know what problem you&#8217;re solving.</p><p>You&#8217;re not trying to get <em>every</em> detail. You&#8217;re trying to get <em>enough</em> clarity that you&#8217;re not completely guessing.</p><p>Think of it like this: If someone asks you to &#8220;<em>design a messaging feature</em>,&#8221; do they want:</p><ul><li><p>WhatsApp (end-to-end encrypted, real-time, requires phone number)</p></li><li><p>Slack (threaded, searchable, integrates with other tools)</p></li><li><p>Twitter/X DMs (simple, text-only, tied to social graph)</p></li></ul><p>All of those are &#8220;messaging.&#8221; They&#8217;re also completely different architectures.</p><p><em><strong>So your job is to ask questions that reveal which one they actually want.</strong></em></p><div><hr></div><h3>Questions that actually matter</h3><p>Here&#8217;s what you should ask:</p><p><strong>About success criteria:</strong></p><ul><li><p>&#8220;What does success look like for this feature?&#8221; (Are we optimizing for speed? Reliability? Simplicity?)</p></li><li><p>&#8220;What&#8217;s the most important thing this needs to do well?&#8221; (If we could only do one thing right, what would it be?)</p></li></ul><p><strong>About scope:</strong></p><ul><li><p>&#8220;Is this the whole app, or are we focusing on one part?&#8221; (Don&#8217;t design all of Instagram if they just want the feed)</p></li><li><p>&#8220;What platforms are we targeting?&#8221; (iOS only? Android? Cross-platform?)</p></li></ul><p><strong>About constraints:</strong></p><ul><li><p>&#8220;What network conditions should we plan for?&#8221; (Always online? Intermittent? Fully offline?)</p></li><li><p>&#8220;Are there any technical constraints I should know about?&#8221; (Existing systems we need to integrate with? Legacy code?)</p></li></ul><p><strong>About users:</strong></p><ul><li><p>&#8220;Who are the primary users?&#8221; (Consumers? Enterprise? Internal tools?)</p></li><li><p>&#8220;What devices are they on?&#8221; (Flagship phones? Low-end Android? Tablets?)</p></li></ul><p><em><strong>Don&#8217;t ask everything.</strong></em></p><p>Pick the questions that will most change your design. You have limited time.</p><div><hr></div><h3>A bad and a good example</h3><p><strong>Bad example:</strong></p><blockquote><p>Interviewer: &#8220;Design a feed for a social media app.&#8221;</p><p>You: &#8220;Okay, so I&#8217;ll use MVVM for the architecture. We&#8217;ll have a ViewModel that fetches data from a Repository, which talks to both a local database and a REST API. UI will be built with&#8212;&#8221;</p><p>Interviewer (internally): <em>They didn&#8217;t ask a single question. Do they even know what they&#8217;re designing?</em></p></blockquote><p>You just spent 3 minutes designing an architecture without knowing:</p><ul><li><p>Whether it needs to work offline</p></li><li><p>Whether it&#8217;s a text-based feed or heavy on images and video</p></li><li><p>Whether it requires pre-caching for a smoother scrolling experience</p></li></ul><p>That&#8217;s a red flag. Interviewers are <em>explicitly</em> looking for whether you ask questions.</p><p><strong>Good example:</strong></p><blockquote><p>Interviewer: &#8220;Design a feed for a social media app.&#8221;</p><p>You: &#8220;Okay, let me make sure I understand what we&#8217;re designing. Is this feed mostly images and video, or mostly text? That affects caching and pre-fetching on mobile.&#8221;</p><p>Interviewer: &#8220;Mostly images, some video.&#8221;</p><p>You: &#8220;Got it. For mobile, I&#8217;d plan on disk caching images (and maybe short videos) and pre-fetching upcoming content so the feed loads fast and works offline. Is that aligned with what you want?&#8221;</p><p>Interviewer: &#8220;Yes, basic offline support for previously loaded content is important.&#8221;</p><p>You: &#8220;Makes sense. One more thing: do we need live updates, or is pull-to-refresh enough for v1?&#8221;</p><p>Interviewer: &#8220;Pull-to-refresh is fine.&#8221;</p><p>You: &#8220;Perfect. So, to summarize: we&#8217;re designing a media-heavy feed with basic offline support. We&#8217;ll cache images (and maybe short videos), pre-fetch upcoming content for fast loads, and start with pull-to-refresh for updates. Does that sound right?&#8221;</p><p>Interviewer: &#8220;Yep, that&#8217;s it.&#8221;</p></blockquote><div><hr></div><p><em><strong>Reminder: this is a teaser of the subscriber-only newsletter series, exclusive to my golden members.</strong></em></p><p>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>High-level architecture of real-world systems.</strong></p></li><li><p>Deep dive into how popular real-world systems actually work.</p></li><li><p><strong>How real-world systems handle scale, reliability, and performance.</strong></p></li></ul><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><h2>Briefing wrap-up (red flags + next steps)</h2><p>Sometimes the briefing is incomplete or contradictory. Call it out early instead of guessing&#8230;</p><p><strong>Common red flags:</strong></p><ul><li><p>Requirements that are vague or overly broad - <em>&#8221;make it fast.&#8221;</em></p></li><li><p>Contradictory statements -<em> &#8221;we want it simple, but also highly customizable.&#8221;</em></p></li><li><p>Missing critical info (no mention of offline, auth, or data sources)</p></li></ul><p><strong>When you spot these, call them out:</strong></p><p><em>&#8220;You mentioned we want it to be &#8216;fast.&#8217; Can you be more specific? Are we talking about load time under 1 second, smooth scrolling, or something else?&#8221;</em></p><p><em>&#8220;I&#8217;m noticing we haven&#8217;t talked about where the data comes from. Should I assume we&#8217;re pulling from a REST API, or is there a different data source?&#8221;</em></p><p>Don&#8217;t rush ahead, hoping it&#8217;ll become clear later. It won&#8217;t. You&#8217;ll end up designing something that doesn&#8217;t match what they wanted&#8230;</p><p><strong>Next steps once the briefing is clear:</strong></p><ul><li><p>Write down key constraints in the shared doc or on the whiteboard (&#8221;Offline support required&#8221;, &#8220;100k users&#8221;, &#8220;Existing auth system&#8221;)</p></li><li><p>Mentally categorize what is a must-have versus a nice-to-have</p></li><li><p>Identify the biggest unknowns you&#8217;ll need to address</p></li></ul><p><em><strong>Lesson: Don&#8217;t start designing until you know what you&#8217;re designing.</strong></em></p><p>This can feel slow, but it&#8217;s faster than designing the wrong thing&#8230;</p><div><hr></div><h2>Defining scope and requirements</h2><p>Okay, so you&#8217;ve asked your questions, and you have a basic understanding of what you&#8217;re designing. Now comes the hard part: figuring out what you&#8217;re <em>actually</em> going to design.</p><p>Here&#8217;s the problem: If someone asks you to <em>&#8220;design a messaging feature,&#8221;</em> there are about 47 different things they could mean. Do they want read receipts? Typing indicators? Group chats? Voice messages? End-to-end encryption? Reactions? Threads?</p><p>You can&#8217;t fit all of that into v1. You probably can&#8217;t even fit half of it.</p><p><em><strong>So your job is to separate what&#8217;s essential from what&#8217;s nice-to-have.</strong></em></p><p>This is where most people mess up. They either:</p><ol><li><p>Try to include everything at once and run out of time</p></li><li><p>Design the wrong things and miss what actually matters</p></li><li><p>Don&#8217;t ask at all and just guess</p></li></ol><p>All three are bad. Let&#8217;s talk about how to do this right:</p><div><hr></div><h3>What you&#8217;re trying to figure out</h3><p>You need to answer these questions:</p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/mobile-system-design-interview">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[RAG - A Deep Dive]]></title><description><![CDATA[#133: Understanding Retrieval-Augmented Generation]]></description><link>https://newsletter.systemdesign.one/p/how-rag-works</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/how-rag-works</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Mon, 23 Mar 2026 11:45:50 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/8d630c6b-2576-4b38-8561-e3b88cf47d0e_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/how-rag-works/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>Every large language model<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a> (<strong>LLM</strong>) you use has lied to you with confidence, fluency, and frequency&#8230;</p><p>Ask any model about something that happened last week. It doesn&#8217;t know. It can&#8217;t know. Its knowledge was frozen months ago. They might try, and if they do, they will hallucinate.</p><p>This isn&#8217;t a bug.</p><p>It&#8217;s a fundamental architectural limitation. LLMs keep knowledge in their parameters<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>. These are billions of numerical weights learned during training. Once training ends, the knowledge is locked. The model doesn&#8217;t know what it doesn&#8217;t know, so it fills the gaps with confident fabrication. Studies show that hallucination<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a> rates can be as low as 1% for simple summarization tasks. However, they can exceed 58% for complex work.</p><p>This is exactly what Retrieval-Augmented Generation<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a> (<strong>RAG</strong>) solves.</p><p>RAG doesn&#8217;t bake knowledge into the model. Instead, it pulls in relevant context when you ask a question. The model stays smart, your data stays current, and every answer is traceable back to its source.</p><p>This is the architectural pattern that makes AI actually useful.</p><p>Here&#8217;s how it works, why it works, and how to build it:</p><div><hr></div><h2><a href="https://link.outskill.com/NEOKIMMAR4">Still juggling 10 different tools? Learn AI workflows and replace 80% of them (Partner)</a></h2><p>Perplexity&#8217;s new computer thinks, designs, codes, and manages projects &#8212; all without you lifting a finger to switch tools.</p><p>This is where AI is headed: one place to get everything done. Smarter, faster, and built to make you 10x more productive.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://link.outskill.com/NEOKIMMAR4" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!knkf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3234eb1b-ca33-4b13-bc85-4e599170e1d4_1600x902.png 424w, https://substackcdn.com/image/fetch/$s_!knkf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3234eb1b-ca33-4b13-bc85-4e599170e1d4_1600x902.png 848w, https://substackcdn.com/image/fetch/$s_!knkf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3234eb1b-ca33-4b13-bc85-4e599170e1d4_1600x902.png 1272w, https://substackcdn.com/image/fetch/$s_!knkf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3234eb1b-ca33-4b13-bc85-4e599170e1d4_1600x902.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!knkf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3234eb1b-ca33-4b13-bc85-4e599170e1d4_1600x902.png" width="1456" height="821" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3234eb1b-ca33-4b13-bc85-4e599170e1d4_1600x902.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:821,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://link.outskill.com/NEOKIMMAR4&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!knkf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3234eb1b-ca33-4b13-bc85-4e599170e1d4_1600x902.png 424w, https://substackcdn.com/image/fetch/$s_!knkf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3234eb1b-ca33-4b13-bc85-4e599170e1d4_1600x902.png 848w, https://substackcdn.com/image/fetch/$s_!knkf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3234eb1b-ca33-4b13-bc85-4e599170e1d4_1600x902.png 1272w, https://substackcdn.com/image/fetch/$s_!knkf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3234eb1b-ca33-4b13-bc85-4e599170e1d4_1600x902.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 role="img" 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><title></title><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>Now is your chance to enter into your most productive era!<br><strong><br></strong>That&#8217;s why we recommend joining <strong><a href="https://link.outskill.com/NEOKIMMAR4">Outskill</a></strong>- the world&#8217;s first AI learning platform where over 10+ Million Learners have learnt from top industry leaders like Microsoft, NVIDIA, and Google.</p><p style="text-align: justify;">They are hosting a 2-day LIVE AI Mastermind where you&#8217;ll build automations, create personalized agents, and learn to turn AI into your ultimate competitive edge.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://link.outskill.com/NEOKIMMAR4&quot;,&quot;text&quot;:&quot;START LEARNING NOW&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://link.outskill.com/NEOKIMMAR4"><span>START LEARNING NOW</span></a></p><p style="text-align: justify;">You will also unlock exclusive bonuses for free when you show up: A Prompt Bible, AI monetization roadmap, and a personalized toolkit builder - for which you would have to pay $1000+ outside. <br><br><strong>&#129504; Happening LIVE- Saturday and Sunday<br>&#128348; 10 AM EST to 7PM EST</strong></p><p><strong><a href="https://link.outskill.com/NEOKIMMAR4">Register here</a> </strong>before they run out of seats. (free for the next 72 hours only!)</p><div><hr></div><p>I want to introduce <strong><a href="https://www.linkedin.com/in/codingwithroby/">Eric Roby</a></strong> as a guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="http://cwroby.com/M9xR2bK7tQs" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1zG8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3bb9b58-3c53-4e9d-bf40-fb19cadb4850_1600x811.png 424w, https://substackcdn.com/image/fetch/$s_!1zG8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3bb9b58-3c53-4e9d-bf40-fb19cadb4850_1600x811.png 848w, https://substackcdn.com/image/fetch/$s_!1zG8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3bb9b58-3c53-4e9d-bf40-fb19cadb4850_1600x811.png 1272w, https://substackcdn.com/image/fetch/$s_!1zG8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3bb9b58-3c53-4e9d-bf40-fb19cadb4850_1600x811.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1zG8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3bb9b58-3c53-4e9d-bf40-fb19cadb4850_1600x811.png" width="1456" height="738" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c3bb9b58-3c53-4e9d-bf40-fb19cadb4850_1600x811.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:738,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;http://cwroby.com/M9xR2bK7tQs&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!1zG8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3bb9b58-3c53-4e9d-bf40-fb19cadb4850_1600x811.png 424w, https://substackcdn.com/image/fetch/$s_!1zG8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3bb9b58-3c53-4e9d-bf40-fb19cadb4850_1600x811.png 848w, https://substackcdn.com/image/fetch/$s_!1zG8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3bb9b58-3c53-4e9d-bf40-fb19cadb4850_1600x811.png 1272w, https://substackcdn.com/image/fetch/$s_!1zG8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3bb9b58-3c53-4e9d-bf40-fb19cadb4850_1600x811.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 role="img" 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><title></title><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>He&#8217;s a senior backend and AI engineer focused on building real-world systems and teaching developers how to do the same. He runs the YouTube channel <a href="https://www.youtube.com/@codingwithroby">@codingwithroby</a>, where he focuses on backend engineering, and created the platform <a href="http://cwroby.com/M9xR2bK7tQs">The Backend OS</a>.</p><p>Through his content and courses, he helps engineers go beyond tutorials, think in systems, and develop the skills that actually matter for real backend roles.</p><p>Check out <strong><a href="http://cwroby.com/M9xR2bK7tQs">The Backend OS</a></strong>, built to close the knowledge gaps you don&#8217;t even know you have.</p><div><hr></div><h2><strong>The Knowledge Problem</strong></h2><p>We need to understand why LLMs struggle with real-world knowledge before we fix them. The problem has <em>three</em> layers, and none of the obvious solutions work&#8230;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Knyq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee59d528-eb06-4bac-b934-4eabe279e7e6_1280x720.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Knyq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee59d528-eb06-4bac-b934-4eabe279e7e6_1280x720.png 424w, https://substackcdn.com/image/fetch/$s_!Knyq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee59d528-eb06-4bac-b934-4eabe279e7e6_1280x720.png 848w, https://substackcdn.com/image/fetch/$s_!Knyq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee59d528-eb06-4bac-b934-4eabe279e7e6_1280x720.png 1272w, https://substackcdn.com/image/fetch/$s_!Knyq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee59d528-eb06-4bac-b934-4eabe279e7e6_1280x720.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Knyq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee59d528-eb06-4bac-b934-4eabe279e7e6_1280x720.png" width="1280" height="720" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ee59d528-eb06-4bac-b934-4eabe279e7e6_1280x720.png&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;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!Knyq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee59d528-eb06-4bac-b934-4eabe279e7e6_1280x720.png 424w, https://substackcdn.com/image/fetch/$s_!Knyq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee59d528-eb06-4bac-b934-4eabe279e7e6_1280x720.png 848w, https://substackcdn.com/image/fetch/$s_!Knyq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee59d528-eb06-4bac-b934-4eabe279e7e6_1280x720.png 1272w, https://substackcdn.com/image/fetch/$s_!Knyq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee59d528-eb06-4bac-b934-4eabe279e7e6_1280x720.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 role="img" 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><title></title><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>LLM knowledge is frozen at training time</strong></h3><p>Every LLM has a cutoff date for its knowledge.</p><p>Everything the model knows was scraped, processed, and compressed into parameters during training. After that date, the model is blind. It isn&#8217;t aware of your new product launch, yesterday&#8217;s security issue, or this morning&#8217;s HR policy change.</p><p>This isn&#8217;t a minor inconvenience.</p><p>In business, accuracy is crucial. This includes areas like customer support, legal analysis, internal search, and compliance. A model that can&#8217;t access current information is a liability. It doesn&#8217;t help the business at all.</p><h3><strong>Context Windows Aren&#8217;t the Answer</strong></h3><p>The brute-force approach is tempting: <em>dump everything into the prompt.</em></p><p>Context windows<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-5" href="#footnote-5" target="_self">5</a> have increased a lot. Some models can now handle over a million tokens<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-6" href="#footnote-6" target="_self">6</a>. But this approach has three fatal problems.</p><p><strong>First, it&#8217;s expensive</strong>.</p><p>You pay for each token. Sending your entire knowledge base with every query will wipe out your budget.</p><p><strong>Second, there are hard limits.</strong></p><p>A million-token window can&#8217;t fit all of a large enterprise&#8217;s documents or its databases.</p><p><strong>Third, and this is the one most people miss, models get </strong><em><strong>worse</strong></em><strong> with more context.</strong></p><p>Research from Stanford and UC Berkeley shows LLM performance follows a U-shaped curve. Models do best when key information is at the start or end, but accuracy drops sharply when important facts are buried in the middle. In Liu et al.&#8217;s multi-document QA experiments, accuracy for some models dropped to roughly 25% when key information was placed in the middle of a 20-document context.</p><p>It&#8217;s clear: adding more context to the prompt doesn&#8217;t guarantee the model will use it.</p><div><hr></div><h2><strong>Fine-tuning isn&#8217;t the answer either</strong></h2><p>Fine-tuning<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-7" href="#footnote-7" target="_self">7</a> is when you take a pre-trained model and continue training it on your own specific data, so it learns new knowledge or behavior.</p><p>Fine-tuning changes the model&#8217;s weights to incorporate new knowledge. Think of it like sending someone back to school for a specialized course. In theory, this lets you teach the model about your domain.</p><p>In practice, it creates more problems than it solves&#8230;</p><p>It requires GPU compute, machine learning expertise, and carefully prepared training data. It takes days or weeks to complete. The result is a snapshot. Once your underlying data changes, your fine-tuned model becomes stale.</p><h3><strong>What&#8217;s Actually Needed</strong></h3><p>The key is to provide the AI with the right information at the right time for each query. And it should be done without changing the model itself.</p><p>That&#8217;s RAG.</p><p>Now let&#8217;s investigate RAG deeper:</p><div><hr></div><h2><strong>What RAG actually is</strong></h2><p>Retrieval-Augmented Generation is an architectural pattern, not a product. The concept is straightforward, and the best analogy is an open-book exam.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WV5q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ac6e9d-d48d-403a-aafa-40092392d779_1280x720.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WV5q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ac6e9d-d48d-403a-aafa-40092392d779_1280x720.png 424w, https://substackcdn.com/image/fetch/$s_!WV5q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ac6e9d-d48d-403a-aafa-40092392d779_1280x720.png 848w, https://substackcdn.com/image/fetch/$s_!WV5q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ac6e9d-d48d-403a-aafa-40092392d779_1280x720.png 1272w, https://substackcdn.com/image/fetch/$s_!WV5q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ac6e9d-d48d-403a-aafa-40092392d779_1280x720.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WV5q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ac6e9d-d48d-403a-aafa-40092392d779_1280x720.png" width="1280" height="720" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/50ac6e9d-d48d-403a-aafa-40092392d779_1280x720.png&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;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!WV5q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ac6e9d-d48d-403a-aafa-40092392d779_1280x720.png 424w, https://substackcdn.com/image/fetch/$s_!WV5q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ac6e9d-d48d-403a-aafa-40092392d779_1280x720.png 848w, https://substackcdn.com/image/fetch/$s_!WV5q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ac6e9d-d48d-403a-aafa-40092392d779_1280x720.png 1272w, https://substackcdn.com/image/fetch/$s_!WV5q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ac6e9d-d48d-403a-aafa-40092392d779_1280x720.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 role="img" 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><title></title><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 student taking a closed-book exam relies on what they have memorized.</p><p>That&#8217;s a standard LLM. It&#8217;s smart and can reason, but it&#8217;s limited to what&#8217;s in its parameters. A student with an open-book exam has the same reasoning skills. They can check relevant pages before answering.</p><p>That&#8217;s RAG.</p><p>The formal definition comes from a 2020 paper by Patrick Lewis and his team at Facebook AI Research and University College London. RAG models combine parametric memory<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-8" href="#footnote-8" target="_self">8</a> with a pre-trained language model and non-parametric memory<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-9" href="#footnote-9" target="_self">9</a>. This non-parametric memory uses an external knowledge index. It&#8217;s accessed by a neural retriever<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-10" href="#footnote-10" target="_self">10</a>.</p><p>You can still update the model&#8217;s knowledge by swapping the retrieval index. No one needs to retrain.</p><p>In practice, RAG follows a three-step loop:</p><ol><li><p>Query comes in: a user asks a question.</p></li><li><p>Retrieve: System looks in an external knowledge base for the best information chunks.</p></li><li><p>Question and context go to the LLM. It then creates an answer based on the retrieved documents.</p></li></ol><p>You&#8217;re not changing the model. You&#8217;re changing what it sees. That distinction makes RAG so powerful and so practical.</p><p>The open-book analogy makes sense at a high level. But understanding why it works so well means diving deeper into the topic&#8230;</p><div><hr></div><h2><strong>How RAG Works Under the Hood</strong></h2><p>The three-step loop sounds simple. The engineering that makes it work is where things get interesting.</p><p>A RAG system has two main parts:</p><ul><li><p>An <strong>offline ingestion pipeline</strong> that gets your data ready.</p></li><li><p>An <strong>online retrieval pipeline</strong> that answers queries.</p></li></ul><p>Let&#8217;s walk through each one&#8230;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!y9LI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F821e9ca3-44bb-4aae-87c9-26d932f2f67a_1280x720.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!y9LI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F821e9ca3-44bb-4aae-87c9-26d932f2f67a_1280x720.png 424w, https://substackcdn.com/image/fetch/$s_!y9LI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F821e9ca3-44bb-4aae-87c9-26d932f2f67a_1280x720.png 848w, https://substackcdn.com/image/fetch/$s_!y9LI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F821e9ca3-44bb-4aae-87c9-26d932f2f67a_1280x720.png 1272w, https://substackcdn.com/image/fetch/$s_!y9LI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F821e9ca3-44bb-4aae-87c9-26d932f2f67a_1280x720.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!y9LI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F821e9ca3-44bb-4aae-87c9-26d932f2f67a_1280x720.png" width="1280" height="720" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/821e9ca3-44bb-4aae-87c9-26d932f2f67a_1280x720.png&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;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!y9LI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F821e9ca3-44bb-4aae-87c9-26d932f2f67a_1280x720.png 424w, https://substackcdn.com/image/fetch/$s_!y9LI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F821e9ca3-44bb-4aae-87c9-26d932f2f67a_1280x720.png 848w, https://substackcdn.com/image/fetch/$s_!y9LI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F821e9ca3-44bb-4aae-87c9-26d932f2f67a_1280x720.png 1272w, https://substackcdn.com/image/fetch/$s_!y9LI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F821e9ca3-44bb-4aae-87c9-26d932f2f67a_1280x720.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 role="img" 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><title></title><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>Embeddings: Core Mechanism</strong></h3><p>Before anything else, you need to understand embeddings<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-11" href="#footnote-11" target="_self">11</a>. This is the concept that enables semantic search<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-12" href="#footnote-12" target="_self">12</a>.</p><p>Text embeddings turn text into dense numerical vectors<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-13" href="#footnote-13" target="_self">13</a>. These are arrays of floating-point numbers, usually with 1,536 or 3,072 dimensions. They capture the text meaning. The magic is in what &#8220;capture meaning&#8221; means. Words and sentences with similar intent are close together in vector space. This happens even with different words.</p><p>Consider this: <em>&#8220;How do I reset my password?&#8221;</em> and <em>&#8220;I can&#8217;t log into my account&#8221;</em> use completely different words.</p><p>But when converted to embeddings, they produce nearly identical vectors. The distance between them is tiny because their meanings are similar. This is measured using cosine similarity<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-14" href="#footnote-14" target="_self">14</a>, dot product, or Euclidean distance.</p><p>The key insight for RAG is clear.</p><p>System finds relevant content. It does this even if the user&#8217;s question doesn&#8217;t use the exact words from the source document. It searches by meaning, not by keywords.</p><h3><strong>Data Ingestion Pipeline (Offline Phase)</strong></h3><p>First, process your knowledge base. Then, index it. Only then can your RAG system answer questions.</p><p>This happens in five steps:</p><p><strong>What triggers the offline phase?</strong></p><p>In traditional workflows, this pipeline runs when new data is available. This can happen when documents are added or updated. It can also occur when a database changes or on a regular schedule, like nightly or weekly. Some teams trigger re-ingestion if retrieval quality drops.</p><p>They also do this when a new data source connects:</p><ol><li><p><strong>Load documents from anywhere</strong>: PDFs, databases, APIs, wikis, Slack channels, and Confluence pages. Frameworks like LangChain<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-15" href="#footnote-15" target="_self">15</a> and LlamaIndex<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-16" href="#footnote-16" target="_self">16</a> offer ready-made connectors for many common sources.</p></li><li><p><strong>Chunking</strong><a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-17" href="#footnote-17" target="_self">17</a><strong>: </strong>Split documents into semantically meaningful pieces. This is the single highest-leverage step to get right, and we will cover it in depth later.</p></li><li><p><strong>Embedding:</strong> Convert each chunk into a vector using an embedding model.</p></li><li><p><strong>Storage:</strong> Store the vectors in a vector database<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-18" href="#footnote-18" target="_self">18</a> optimized for similarity search.</p></li><li><p><strong>Metadata tagging:</strong> Tag each chunk with source, timestamp, category, and access control information. This metadata becomes critical for filtering, attribution, and security later.</p></li></ol><h3><strong>Retrieval Pipeline (Online Phase)</strong></h3><p>When a user asks a question, the retrieval pipeline kicks in:</p><ol><li><p><strong>Query embedding</strong>: User&#8217;s question turns into a vector. This uses the same embedding model from ingestion. This is critical: the query and the documents must live in the same vector space.</p></li><li><p><strong>Similarity search</strong>: The system finds the top-K<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-19" href="#footnote-19" target="_self">19</a> similar chunks. It compares the query vector to each vector in the database.</p></li><li><p><strong>Retrieval strategy</strong>: This is where the real engineering decisions happen. Three primary approaches exist:</p><ol><li><p>Sparse retrieval<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-20" href="#footnote-20" target="_self">20</a> uses a statistical method that matches exact keywords. It weighs these matches using term frequency and inverse document frequency.</p></li><li><p>Dense retrieval (embeddings):<strong> </strong>Semantic search via vectors. Finds conceptually relevant content even when the wording differs.</p></li><li><p>Hybrid search (combining both): Use both sparse and dense retrieval. Then, merge the results with Reciprocal Rank Fusion<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-21" href="#footnote-21" target="_self">21</a> (RRF). This boosts documents that rank high in both systems.</p></li></ol></li><li><p><strong>Re-ranking</strong>: After retrieving results, a cross-encoder model rescans them. It processes the query and each document as one input. This captures fine-grained relevance that bi-encoders miss.</p></li></ol><h3><strong>Generation Phase</strong></h3><p>With the most relevant chunks in hand, the system assembles the final prompt:</p><ol><li><p><strong>Prompt Construction:</strong></p><ol><li><p><strong>System Prompt:</strong> Combine the system prompt (the instructions that tell the LLM how to behave, like <em>&#8220;You are a helpful customer support agent&#8221;</em>) with the user&#8217;s request.</p></li><li><p><strong>Retrieved Context Chunks:</strong> Integrate the relevant pieces of text pulled from your knowledge base. For instance, if someone asks, <em>&#8220;What&#8217;s your refund policy?&#8221;</em> You might pull two paragraphs from your company&#8217;s policy document.</p></li><li><p><strong>User&#8217;s Original Query:</strong> Include the user&#8217;s actual question or task &#8212; exactly as they typed it.</p></li></ol></li><li><p><strong>LLM Call:</strong> The model generates an answer grounded in the retrieved documents. The key facts are in the prompt. The model uses these facts to reason instead of relying on its trained memory. Think of it like giving someone an open-book exam instead of asking them to answer from memory.</p></li><li><p><strong>Citation and Attribution:</strong> The system shows which source documents were used and provides verifiable citations. For example, the response might say, <em>&#8220;Based on Section 3.2 of the Employee Handbook...&#8221;</em> so the user knows exactly where the answer came from. This is one of RAG&#8217;s biggest advantages over fine-tuning: transparency.</p></li></ol><p>Now that you know how RAG works mechanically, the real question is whether it&#8217;s the right tool. That depends on what you&#8217;re comparing it to&#8230;</p><div><hr></div><h2><strong>Why RAG over alternatives?</strong></h2><p>RAG isn&#8217;t the only approach to giving AI access to knowledge.</p><p>You need to know when to use it and when not to. This means comparing it to other options.</p><h3><strong>RAG vs. Fine-Tuning</strong></h3><p>This is the comparison most teams face first. Here&#8217;s how they stack up:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1-2N!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80bd91be-a383-4f21-a05e-1a2acadabb96_1164x814.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1-2N!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80bd91be-a383-4f21-a05e-1a2acadabb96_1164x814.png 424w, https://substackcdn.com/image/fetch/$s_!1-2N!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80bd91be-a383-4f21-a05e-1a2acadabb96_1164x814.png 848w, https://substackcdn.com/image/fetch/$s_!1-2N!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80bd91be-a383-4f21-a05e-1a2acadabb96_1164x814.png 1272w, https://substackcdn.com/image/fetch/$s_!1-2N!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80bd91be-a383-4f21-a05e-1a2acadabb96_1164x814.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1-2N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80bd91be-a383-4f21-a05e-1a2acadabb96_1164x814.png" width="1164" height="814" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80bd91be-a383-4f21-a05e-1a2acadabb96_1164x814.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:814,&quot;width&quot;:1164,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!1-2N!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80bd91be-a383-4f21-a05e-1a2acadabb96_1164x814.png 424w, https://substackcdn.com/image/fetch/$s_!1-2N!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80bd91be-a383-4f21-a05e-1a2acadabb96_1164x814.png 848w, https://substackcdn.com/image/fetch/$s_!1-2N!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80bd91be-a383-4f21-a05e-1a2acadabb96_1164x814.png 1272w, https://substackcdn.com/image/fetch/$s_!1-2N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80bd91be-a383-4f21-a05e-1a2acadabb96_1164x814.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 role="img" 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><title></title><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 key nuance: fine-tuning and RAG are complementary, not competing.</p><p>Fine-tuning is the best option when you want to adjust the model&#8217;s behavior, style, or output format, not just its knowledge. The best production systems do two things: they fine-tune style and behavior, and then they use RAG for knowledge. You can adjust a model to produce structured JSON in a certain format.</p><p>Then, use RAG to fill it with up-to-date data.</p><h3><strong>RAG vs. Long Context Windows</strong></h3><p>Context windows keep growing. Why not dump everything in the prompt?</p><p>Cost and precision. RAG retrieves only the 5-20 most relevant chunks. Long context stuffs everything in and hopes the model finds the needle. RAG is cheaper per query. It&#8217;s also more precise in what it finds. Plus, it can search millions of documents, unlike others that have a token limit.</p><p>They work well together: first, use RAG to get the right 20 chunks.</p><p>Then, use long context to process them all at once. The &#8220;lost in the middle&#8221; research shows that retrieving small, relevant chunks works better than using large context windows.</p><div><hr></div><p><em><strong>Reminder: this is a teaser of the subscriber-only newsletter series, exclusive to my golden members.</strong></em></p><p>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>High-level architecture of real-world systems.</strong></p></li><li><p>Deep dive into how popular real-world systems actually work.</p></li><li><p><strong>How real-world systems handle scale, reliability, and performance.</strong></p></li></ul><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><h2><strong>Traditional RAG vs. Agentic RAG</strong></h2><p>Traditional RAG follows the straightforward three-step loop described above: retrieve, then generate. It works well for simple question-answering but has limitations. What happens when the first retrieval doesn&#8217;t return good results? Traditional RAG just pushes forward with whatever it finds.</p><p>Agentic RAG adds a reasoning layer on top.</p><p>An AI agent decides how to handle each query. It can change the search, link several retrievals, pick a knowledge base, or skip retrieval completely. Think of Traditional RAG as a student who looks up one page and writes their answer. Agentic RAG is like a student. They check several sources. They re-read sections that seem off and cross-reference information before writing.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WJ3i!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15a5d41-dd18-4a64-bd28-79621c669aec_1404x570.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WJ3i!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15a5d41-dd18-4a64-bd28-79621c669aec_1404x570.png 424w, https://substackcdn.com/image/fetch/$s_!WJ3i!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15a5d41-dd18-4a64-bd28-79621c669aec_1404x570.png 848w, https://substackcdn.com/image/fetch/$s_!WJ3i!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15a5d41-dd18-4a64-bd28-79621c669aec_1404x570.png 1272w, https://substackcdn.com/image/fetch/$s_!WJ3i!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15a5d41-dd18-4a64-bd28-79621c669aec_1404x570.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WJ3i!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15a5d41-dd18-4a64-bd28-79621c669aec_1404x570.png" width="1404" height="570" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b15a5d41-dd18-4a64-bd28-79621c669aec_1404x570.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:570,&quot;width&quot;:1404,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!WJ3i!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15a5d41-dd18-4a64-bd28-79621c669aec_1404x570.png 424w, https://substackcdn.com/image/fetch/$s_!WJ3i!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15a5d41-dd18-4a64-bd28-79621c669aec_1404x570.png 848w, https://substackcdn.com/image/fetch/$s_!WJ3i!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15a5d41-dd18-4a64-bd28-79621c669aec_1404x570.png 1272w, https://substackcdn.com/image/fetch/$s_!WJ3i!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15a5d41-dd18-4a64-bd28-79621c669aec_1404x570.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 role="img" 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><title></title><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><h2><strong>Multi-Step RAG Pipeline</strong></h2><p>Production RAG systems often go beyond the simple retrieve-and-generate loop. A multi-step pipeline adds intelligence before and after retrieval:</p><ol><li><p>Query Intent Parsing: Before searching, the system analyzes what the user actually wants. Is it a factual question? A comparison? A request for a summary? Understanding intent helps the system choose the right retrieval strategy and knowledge base.</p></li><li><p>Query Reformulation: The system may rewrite the user&#8217;s question to improve retrieval quality. For example, <em>&#8220;Why is my app slow?&#8221;</em> might become <em>&#8220;application performance bottleneck causes and solutions.&#8221;</em></p></li><li><p>Retrieval: System searches for relevant chunks (as described above).</p></li><li><p>Live Web Search: If internal documents aren&#8217;t enough, some RAG systems can do live web searches. This helps them get current information from the internet.</p></li><li><p>Reranking<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-22" href="#footnote-22" target="_self">22</a> and Filtering: Results are scored, filtered, and reranked for relevance.</p></li><li><p>Generation: LLM produces an answer grounded in all the gathered context.</p></li></ol><p>This multi-step approach is what separates demo-quality RAG from production-quality RAG.</p><div><hr></div><h2><strong>RAG Limitations</strong></h2><p>RAG is powerful, but it&#8217;s not a silver bullet&#8230;</p><p>Understanding its limitations helps you decide when to use it and when to look elsewhere:</p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/how-rag-works">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[I struggled with AI agents until I built an incident response agent ]]></title><description><![CDATA[#131: Step-by-step guide to building your first AI agent]]></description><link>https://newsletter.systemdesign.one/p/how-do-ai-agents-work</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/how-do-ai-agents-work</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Wed, 18 Mar 2026 14:17:46 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/f7e5768b-0414-42da-a26b-8d52dce3dbad_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/how-do-ai-agents-work/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>Everyone is talking about AI agents, but only very few people are actually building them.</p><p>Plugging a chatbot into your website is just a UI update. The biggest opportunity is in agentic AI, and most people are missing it&#8230;</p><p>Onward.</p><div><hr></div><h2><strong><a href="https://orchidsapp.link/neokim">The best way to build any app (Partner)</a></strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://orchidsapp.link/neokim" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Yv56!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 424w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 848w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 1272w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Yv56!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e7ea1369-7f5d-400e-8b47-3c49bf1e055e_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;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://orchidsapp.link/neokim&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Yv56!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 424w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 848w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 1272w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 1456w" sizes="100vw" loading="lazy" 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 role="img" 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><title></title><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 tax on vibe builders right now isn&#8217;t effort, it&#8217;s cost.</p><p>Every tool wants you to pay for its model usage and hosting forever. <strong><a href="https://orchidsapp.link/neokim">Orchids.app</a></strong> lets you bring your own and use tools/SDKs that already exist elsewhere.</p><p>Plug in your ChatGPT, Claude Code, Gemini, Copilot, GLM, or any API key you already pay for.</p><p>You keep control of the bill. And the best part is: you don&#8217;t get price locked because you shipped with Orchids. Deploy your code straight to Vercel with one click.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://orchidsapp.link/neokim&quot;,&quot;text&quot;:&quot;Get Started Today&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://orchidsapp.link/neokim"><span>Get Started Today</span></a></p><p><em>(Use this discount code to get a onetime 15% off during checkout: MARCH15)</em></p><div><hr></div><p>I want to introduce <strong><a href="https://strategizeyourcareer.com/5eca9a08">Fran Soto</a></strong> as a guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://strategizeyourcareer.com/5eca9a08" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!niZ1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a17bef-6a7e-4b53-ad17-52124c0a8fe8_755x467.png 424w, https://substackcdn.com/image/fetch/$s_!niZ1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a17bef-6a7e-4b53-ad17-52124c0a8fe8_755x467.png 848w, https://substackcdn.com/image/fetch/$s_!niZ1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a17bef-6a7e-4b53-ad17-52124c0a8fe8_755x467.png 1272w, https://substackcdn.com/image/fetch/$s_!niZ1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a17bef-6a7e-4b53-ad17-52124c0a8fe8_755x467.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!niZ1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a17bef-6a7e-4b53-ad17-52124c0a8fe8_755x467.png" width="755" height="467" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c1a17bef-6a7e-4b53-ad17-52124c0a8fe8_755x467.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:467,&quot;width&quot;:755,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://strategizeyourcareer.com/5eca9a08&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!niZ1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a17bef-6a7e-4b53-ad17-52124c0a8fe8_755x467.png 424w, https://substackcdn.com/image/fetch/$s_!niZ1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a17bef-6a7e-4b53-ad17-52124c0a8fe8_755x467.png 848w, https://substackcdn.com/image/fetch/$s_!niZ1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a17bef-6a7e-4b53-ad17-52124c0a8fe8_755x467.png 1272w, https://substackcdn.com/image/fetch/$s_!niZ1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a17bef-6a7e-4b53-ad17-52124c0a8fe8_755x467.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 role="img" 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><title></title><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>Fran is a software engineer at Amazon. He&#8217;s responsible for most of the &#8220;Add to Cart&#8221; and other buttons you see in the search results of the Amazon marketplace, and now works at Ring.</p><p>Fran helps software engineers grow their careers. He teaches them productivity and the AI automation skills they need to grow to the next level.</p><p>To celebrate this collaboration, Fran is giving away his premium <strong><a href="https://strategizeyourcareer.com/5eca9a08">System Design Template</a></strong> completely free to all new subscribers. This template is the perfect tool to structure your architectural decisions before you write any code. You can practice filling it with the case studies and deep dives from this newsletter!</p><p>For the next few days, you can also claim a <a href="https://strategizeyourcareer.com/5eca9a08">25% discount on the StrategizeYourCareer</a> annual subscription from the links in this newsletter. Whether you grab the annual discount or just want the free template, join today to become a productive engineer.</p><p>Check out his newsletter: <strong><a href="https://strategizeyourcareer.com/5eca9a08">StrategizeYourCareer</a></strong>.</p><div><hr></div><p>Imagine you have just bought some furniture and now you have to assemble it&#8230;</p><p>The fixed set of instructions that comes in the box is a <em>workflow</em>. It is a linear path that works perfectly as long as everything goes right. It&#8217;s the equivalent of scripts and programming languages. But if you make a mistake and break a wooden part, the instructions cannot help you.</p><p>There is no recovery from that.</p><p>An <em>LLM</em> would be like having a customer support line available for you to call.</p><p>You can describe the broken piece, and they will give you a brilliant, empathetic answer. They might even explain why the wood snapped. But at the end of the call, you are still sitting on the floor with a broken piece. No matter how nice the other person is, they don&#8217;t have hands to help you with your broken piece.</p><p>You are the <em>agent</em> in this scenario.</p><p>You are the one with the tools, like a hammer, nails, glue, and a drill. You are the one with the brain to make decisions on how to best use those tools and how to recover from errors that were never in the initial instructions.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wQlo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77387cc1-ff47-45fd-a0d7-a925acd69fd0_1456x769.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wQlo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77387cc1-ff47-45fd-a0d7-a925acd69fd0_1456x769.jpeg 424w, https://substackcdn.com/image/fetch/$s_!wQlo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77387cc1-ff47-45fd-a0d7-a925acd69fd0_1456x769.jpeg 848w, https://substackcdn.com/image/fetch/$s_!wQlo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77387cc1-ff47-45fd-a0d7-a925acd69fd0_1456x769.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!wQlo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77387cc1-ff47-45fd-a0d7-a925acd69fd0_1456x769.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wQlo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77387cc1-ff47-45fd-a0d7-a925acd69fd0_1456x769.jpeg" width="1456" height="769" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/77387cc1-ff47-45fd-a0d7-a925acd69fd0_1456x769.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:769,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!wQlo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77387cc1-ff47-45fd-a0d7-a925acd69fd0_1456x769.jpeg 424w, https://substackcdn.com/image/fetch/$s_!wQlo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77387cc1-ff47-45fd-a0d7-a925acd69fd0_1456x769.jpeg 848w, https://substackcdn.com/image/fetch/$s_!wQlo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77387cc1-ff47-45fd-a0d7-a925acd69fd0_1456x769.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!wQlo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77387cc1-ff47-45fd-a0d7-a925acd69fd0_1456x769.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 role="img" 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><title></title><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 this newsletter, I want to show you how to build AI agents, providing the tools and knowledge they need to do work on your behalf.</p><p>I will use an <strong>incident response agent</strong> as an example, but the principles of giving an AI both a brain and a set of hands apply to almost any process.</p><h4><strong>In this newsletter, you&#8217;ll learn:</strong></h4><ul><li><p>The differences between LLMs, workflows, and agents.</p></li><li><p>Why the non-deterministic nature of AI is a good feature.</p></li><li><p>A 10-step framework to evolve from manual work to autonomous agents.</p></li><li><p>How and when to keep the human in the loop.</p></li></ul><p>Let&#8217;s get started:</p><div><hr></div><h2><strong>Why the lack of determinism in AI is good for reliability and self-healing</strong></h2><p>I see a lot of skepticism about AI because it is NOT as reliable as traditional code.</p><p>We are used to code that does exactly the same thing every time. However, I believe this lack of determinism is actually a good thing for certain tasks.</p><p>Humans are not as reliable as a machine, yet we are the ones who fix machines when they break. We prefer humans using machines because it brings the best of both worlds. Machines give us the speed and precision of determinism, while humans make things not go as expected.</p><p>An agent mimics this human ability to adapt to new situations. When a system fails in a way you did not anticipate, an agent can review the logs and adjust its approach.</p><p>It&#8217;s self-healing.</p><p>However, to get the most out of agents, instead of using the out-of-the-box generic tool, you need to create your own agents tailored to your use case.</p><div><hr></div><h2><strong>How to build your first AI agent</strong></h2><p>AI companies provide us with generic agents that have planning capabilities and built-in tools. While these are useful, I do not think we want a generic assistant for specialized tasks.</p><p>They also offer integration points to our own memories and tools.</p><p>This is where the opportunity is. The same way a company would hire a software engineer rather than a &#8220;generic human&#8221;, we want that same level of expertise in our agents.</p><p>Building an agent is not a one-step process where you just flip a switch and everything works perfectly. It is an iterative process in which you gradually offload parts of your cognitive load to the machine while keeping a close eye on its performance.</p><p>I&#8217;ve followed this <strong>10-step framework</strong> that starts with pure manual work and ends with a fleet of autonomous agents working together&#8230;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9eSj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F224202ec-78af-409e-b926-aeef281cff43_1600x883.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9eSj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F224202ec-78af-409e-b926-aeef281cff43_1600x883.png 424w, https://substackcdn.com/image/fetch/$s_!9eSj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F224202ec-78af-409e-b926-aeef281cff43_1600x883.png 848w, https://substackcdn.com/image/fetch/$s_!9eSj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F224202ec-78af-409e-b926-aeef281cff43_1600x883.png 1272w, https://substackcdn.com/image/fetch/$s_!9eSj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F224202ec-78af-409e-b926-aeef281cff43_1600x883.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9eSj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F224202ec-78af-409e-b926-aeef281cff43_1600x883.png" width="1456" height="804" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/224202ec-78af-409e-b926-aeef281cff43_1600x883.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:804,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!9eSj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F224202ec-78af-409e-b926-aeef281cff43_1600x883.png 424w, https://substackcdn.com/image/fetch/$s_!9eSj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F224202ec-78af-409e-b926-aeef281cff43_1600x883.png 848w, https://substackcdn.com/image/fetch/$s_!9eSj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F224202ec-78af-409e-b926-aeef281cff43_1600x883.png 1272w, https://substackcdn.com/image/fetch/$s_!9eSj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F224202ec-78af-409e-b926-aeef281cff43_1600x883.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 role="img" 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><title></title><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><em>(This process starts with the way we have always worked: Solving it manually.)</em></p><div><hr></div><h3><strong>Step 1. Do the work manually</strong></h3><p>The first step is always to do the work yourself&#8230;</p><p>I recommend outlining the steps as if you were documenting the runbook for someone else to follow:</p><ol><li><p><em>You open the monitoring dashboard and check any metric outside the usual pattern.</em></p></li><li><p><em>You check the runbooks for troubleshooting info for that specific metric.</em></p></li><li><p><em>You query the error logs for the last 15 minutes, looking for requests that resulted in an HTTP 500 error.</em></p></li></ol><p><strong>Current state:</strong> At this stage, you are the bottleneck in the entire process. Every step requires your manual intervention and your attention. This is the baseline that we want to improve.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SGGl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9105ef28-954b-49e9-8e5a-166a8d25c75e_569x471.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SGGl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9105ef28-954b-49e9-8e5a-166a8d25c75e_569x471.png 424w, https://substackcdn.com/image/fetch/$s_!SGGl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9105ef28-954b-49e9-8e5a-166a8d25c75e_569x471.png 848w, https://substackcdn.com/image/fetch/$s_!SGGl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9105ef28-954b-49e9-8e5a-166a8d25c75e_569x471.png 1272w, https://substackcdn.com/image/fetch/$s_!SGGl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9105ef28-954b-49e9-8e5a-166a8d25c75e_569x471.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SGGl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9105ef28-954b-49e9-8e5a-166a8d25c75e_569x471.png" width="569" height="471" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9105ef28-954b-49e9-8e5a-166a8d25c75e_569x471.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:471,&quot;width&quot;:569,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!SGGl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9105ef28-954b-49e9-8e5a-166a8d25c75e_569x471.png 424w, https://substackcdn.com/image/fetch/$s_!SGGl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9105ef28-954b-49e9-8e5a-166a8d25c75e_569x471.png 848w, https://substackcdn.com/image/fetch/$s_!SGGl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9105ef28-954b-49e9-8e5a-166a8d25c75e_569x471.png 1272w, https://substackcdn.com/image/fetch/$s_!SGGl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9105ef28-954b-49e9-8e5a-166a8d25c75e_569x471.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 role="img" 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><title></title><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><h3><strong>Step 2. Start using an LLM</strong></h3><p>Now that you have a solid manual process, you can use it as a guide for an LLM.</p><p>This moves us from manual labor to having an assistant who can analyze the data for you. You can prompt the AI by copy-pasting the logs from your terminal or the metrics from your dashboard.</p><p>I suggest paying close attention to the prompts you usually use.</p><ul><li><p><em>&#8220;Review these logs to find what error is happening:</em> <em>&lt;copy-paste of logs&gt;&#8221;</em></p></li></ul><p>At this point, it&#8217;s important to notice the areas where the AI does not do what you want, and how you steer it back to the right path when it goes off track.</p><p><strong>Current state:</strong> The AI can start analyzing patterns, but you still have to orchestrate everything and move data around manually.</p><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xQae!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dba869-5e2d-4ee5-8635-c7914ebe28bf_570x666.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xQae!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dba869-5e2d-4ee5-8635-c7914ebe28bf_570x666.png 424w, https://substackcdn.com/image/fetch/$s_!xQae!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dba869-5e2d-4ee5-8635-c7914ebe28bf_570x666.png 848w, https://substackcdn.com/image/fetch/$s_!xQae!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dba869-5e2d-4ee5-8635-c7914ebe28bf_570x666.png 1272w, https://substackcdn.com/image/fetch/$s_!xQae!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dba869-5e2d-4ee5-8635-c7914ebe28bf_570x666.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xQae!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dba869-5e2d-4ee5-8635-c7914ebe28bf_570x666.png" width="616" height="719.7473684210527" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/13dba869-5e2d-4ee5-8635-c7914ebe28bf_570x666.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:666,&quot;width&quot;:570,&quot;resizeWidth&quot;:616,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!xQae!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dba869-5e2d-4ee5-8635-c7914ebe28bf_570x666.png 424w, https://substackcdn.com/image/fetch/$s_!xQae!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dba869-5e2d-4ee5-8635-c7914ebe28bf_570x666.png 848w, https://substackcdn.com/image/fetch/$s_!xQae!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dba869-5e2d-4ee5-8635-c7914ebe28bf_570x666.png 1272w, https://substackcdn.com/image/fetch/$s_!xQae!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dba869-5e2d-4ee5-8635-c7914ebe28bf_570x666.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 role="img" 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><title></title><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><h3><strong>Step 3. Add MCP Tools</strong></h3><p>At this stage, you have an AI partner helping with the analysis, but you are still stuck in the middle, acting as a bridge.</p><p>The next step is to stop copy-pasting data. You can use the Model Context Protocol (<strong>MCP<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a></strong>) to allow the AI to take actions for you. MCP is like HTTP for AI agents. It&#8217;s an API that enables the model to execute operations in other systems.</p><p>Once you connect to the right MCP servers and enable the MCP tools, your prompts will look like this:</p><ul><li><p><em>&#8220;Obtain the alarms that fired in the last 15 minutes. You must give me only the alarm name.&#8221;</em></p></li><li><p><em>&#8220;Check the logs for requests ending with an HTTP 500 error. You must give me the message of the log, the error message, and the stack trace...&#8221;</em></p></li></ul><p>The AI can get the incident details on its own!</p><p><strong>Current state:</strong> The human can drive the entire process through the AI interface without switching between tabs and tools.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cWMn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffd37a94-e18c-499e-8097-16dec45a32ce_928x601.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cWMn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffd37a94-e18c-499e-8097-16dec45a32ce_928x601.png 424w, https://substackcdn.com/image/fetch/$s_!cWMn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffd37a94-e18c-499e-8097-16dec45a32ce_928x601.png 848w, https://substackcdn.com/image/fetch/$s_!cWMn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffd37a94-e18c-499e-8097-16dec45a32ce_928x601.png 1272w, https://substackcdn.com/image/fetch/$s_!cWMn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffd37a94-e18c-499e-8097-16dec45a32ce_928x601.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cWMn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffd37a94-e18c-499e-8097-16dec45a32ce_928x601.png" width="928" height="601" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ffd37a94-e18c-499e-8097-16dec45a32ce_928x601.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:601,&quot;width&quot;:928,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!cWMn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffd37a94-e18c-499e-8097-16dec45a32ce_928x601.png 424w, https://substackcdn.com/image/fetch/$s_!cWMn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffd37a94-e18c-499e-8097-16dec45a32ce_928x601.png 848w, https://substackcdn.com/image/fetch/$s_!cWMn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffd37a94-e18c-499e-8097-16dec45a32ce_928x601.png 1272w, https://substackcdn.com/image/fetch/$s_!cWMn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffd37a94-e18c-499e-8097-16dec45a32ce_928x601.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 role="img" 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><title></title><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><h3><strong>Step 4. Add Agent Skills</strong></h3><p>Up to this point, you still have to be an expert in incident response&#8230;</p><p>AI is useful for doing everything from one place. Now we&#8217;ll start looking at the notes we have been taking on how to improve the process and where AI usually goes wrong.</p><p>We have to onboard the AI to incident response the same way we&#8217;d onboard a junior engineer recently hired:</p><ul><li><p>Teach exactly how to use each tool.</p></li><li><p>Teach how you want the work done.</p></li></ul><p>We can combine guides and Standard Operating Procedures.</p><p>These provide step-by-step instructions for routine tasks. We&#8217;d write them in human language, using small scripts, to address a problem with determinism.</p><p>For example, if the MCP tools require a query as input, we can create the <em>Skill</em> of building a query. We&#8217;ll combine a markdown guide containing the fields from the logs with a few scripts to build queries from a template. This is much better than having the AI write complex queries every time. Plus, it reduces the hallucinations of fields that don&#8217;t exist in your logs.</p><p>We call these reusable pieces of logic <strong>Agent Skills</strong>.</p><p>Agent Skills are great because they&#8217;re loaded into the model ONLY when needed. The agent may have skills for metrics and logs. If we only ask about fired alarms, the agent ignores the log data. It just doesn&#8217;t need it.</p><p>This saves memory.</p><p>With agent skills, our interaction would be like this (Slash is the syntax used in IDEs like Cursor<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a> to force the agent to load a particular skill):</p><ul><li><p><em>/Metrics-and-alarm-management Find the alarms fired</em></p></li><li><p><em>&lt;LLM response with metrics information&gt;</em></p></li><li><p><em>/My-service-logs-management Find the logs with errors in these endpoints</em></p></li><li><p><em>&lt;LLM response with the logs information&gt;</em></p></li><li><p><em>/Code-expert Where in code is this log emitted?</em></p></li><li><p><em>&lt;LLM response with the code information&gt;</em></p></li></ul><p><strong>Current state:</strong> We have now taught AI how we want certain tasks done, such as metrics and log information. The human is orchestrating the process to do things in order.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CYT9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F261798a3-0b8b-4805-ac8b-00817488b602_905x560.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CYT9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F261798a3-0b8b-4805-ac8b-00817488b602_905x560.png 424w, https://substackcdn.com/image/fetch/$s_!CYT9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F261798a3-0b8b-4805-ac8b-00817488b602_905x560.png 848w, https://substackcdn.com/image/fetch/$s_!CYT9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F261798a3-0b8b-4805-ac8b-00817488b602_905x560.png 1272w, https://substackcdn.com/image/fetch/$s_!CYT9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F261798a3-0b8b-4805-ac8b-00817488b602_905x560.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CYT9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F261798a3-0b8b-4805-ac8b-00817488b602_905x560.png" width="905" height="560" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/261798a3-0b8b-4805-ac8b-00817488b602_905x560.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:560,&quot;width&quot;:905,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!CYT9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F261798a3-0b8b-4805-ac8b-00817488b602_905x560.png 424w, https://substackcdn.com/image/fetch/$s_!CYT9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F261798a3-0b8b-4805-ac8b-00817488b602_905x560.png 848w, https://substackcdn.com/image/fetch/$s_!CYT9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F261798a3-0b8b-4805-ac8b-00817488b602_905x560.png 1272w, https://substackcdn.com/image/fetch/$s_!CYT9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F261798a3-0b8b-4805-ac8b-00817488b602_905x560.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 role="img" 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><title></title><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><h3><strong>Step 5. Add memory</strong></h3><p>We have given our agent tools and domain expertise, but every time you start a new chat, it&#8217;s like the agent has amnesia. It knows how to solve an incident, but it doesn&#8217;t remember the one you fixed yesterday.</p><p>An agent needs context to be effective&#8230;</p><p>You can add simple <em>short-term memory</em> <em>and</em> <em>long-term memory</em> files to your system.</p><p>The short-term memory is built by design into the agent. This is essentially the AI&#8217;s ability to remember the previous messages in your current conversation. It helps it stay on track without you having to repeat yourself. When making an API call to get the model&#8217;s response, it sends the previous messages along with the new ones.</p><p>For an incident response agent, we also want some long-term memory.</p><p>We have added some memory thanks to the skills, but we can add more context by creating files that the AI can access.</p><p>Some time ago, each company had its own format, but now they have agreed on a standard called <code>Agents.md</code><a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a>. This means the information inside <code>Agents.md</code> file will be read by the AI regardless of which AI it is.</p><p>Also, each implementation allows you to point to which folders/files to use for the agent&#8217;s context.</p><p><strong>Current state:</strong> We still prompt AI the same way. It uses data from skills and logs. It also reads files to understand the system it is debugging. This helps the AI find past errors and the solutions that worked.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!a1RB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0475afed-6dde-470a-ba4b-1936f09917b2_952x535.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!a1RB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0475afed-6dde-470a-ba4b-1936f09917b2_952x535.png 424w, https://substackcdn.com/image/fetch/$s_!a1RB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0475afed-6dde-470a-ba4b-1936f09917b2_952x535.png 848w, https://substackcdn.com/image/fetch/$s_!a1RB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0475afed-6dde-470a-ba4b-1936f09917b2_952x535.png 1272w, https://substackcdn.com/image/fetch/$s_!a1RB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0475afed-6dde-470a-ba4b-1936f09917b2_952x535.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!a1RB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0475afed-6dde-470a-ba4b-1936f09917b2_952x535.png" width="952" height="535" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0475afed-6dde-470a-ba4b-1936f09917b2_952x535.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:535,&quot;width&quot;:952,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!a1RB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0475afed-6dde-470a-ba4b-1936f09917b2_952x535.png 424w, https://substackcdn.com/image/fetch/$s_!a1RB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0475afed-6dde-470a-ba4b-1936f09917b2_952x535.png 848w, https://substackcdn.com/image/fetch/$s_!a1RB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0475afed-6dde-470a-ba4b-1936f09917b2_952x535.png 1272w, https://substackcdn.com/image/fetch/$s_!a1RB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0475afed-6dde-470a-ba4b-1936f09917b2_952x535.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 role="img" 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><title></title><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><h3><strong>Step 6. Orchestrate with Agent SOPs</strong></h3><p>Up to this point, we have given our agent a brain, a set of hands through MCP tools, and a memory.</p><p>But you are still the one directing every move. While the agent is now more capable, it still requires you to decide manually what to use and when. This is the bottleneck that we solve with Agent SOPs.</p><p>Instead of prompting the AI to use a series of skills one by one, you can create a step-by-step process for the AI to follow. This is what&#8217;s called a Standard Operating Procedure (<strong>SOP</strong>) for your agent.</p><p>An Agent SOP is a file written in accordance with RFC 2119<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a>. This RFC defines key capitalized words (MUST, SHOULD, MAY, etc.) to specify requirement levels. Besides, it contains the steps in order.</p><p>I learned about this concept at work, as Amazon uses it in its Kiro<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-5" href="#footnote-5" target="_self">5</a> and Strands<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-6" href="#footnote-6" target="_self">6</a> agents. However, I&#8217;m also using Agent SOPs with Cursor and Claude Code<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-7" href="#footnote-7" target="_self">7</a> easily. You just have to write the markdown file as an Agent Skill.</p><p>Now, instead of prompting step by step, we just execute our agent with that SOP. For example, if we wrap our SOP in a skill:</p><ul><li><p><em>/Incident-response-agent-sop Investigate the incident reported at JIRA-1234</em></p></li></ul><p><strong>Current state:</strong> This makes the agent much more autonomous. The human just invokes the right SOP, and the agent handles the rest. It&#8217;s like a high-level manager finding the right engineer to loop into a call.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VdRL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44d8abaf-2c06-4df1-b9ee-58cdab0fe20c_952x557.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VdRL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44d8abaf-2c06-4df1-b9ee-58cdab0fe20c_952x557.png 424w, https://substackcdn.com/image/fetch/$s_!VdRL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44d8abaf-2c06-4df1-b9ee-58cdab0fe20c_952x557.png 848w, https://substackcdn.com/image/fetch/$s_!VdRL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44d8abaf-2c06-4df1-b9ee-58cdab0fe20c_952x557.png 1272w, https://substackcdn.com/image/fetch/$s_!VdRL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44d8abaf-2c06-4df1-b9ee-58cdab0fe20c_952x557.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VdRL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44d8abaf-2c06-4df1-b9ee-58cdab0fe20c_952x557.png" width="952" height="557" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/44d8abaf-2c06-4df1-b9ee-58cdab0fe20c_952x557.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:557,&quot;width&quot;:952,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!VdRL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44d8abaf-2c06-4df1-b9ee-58cdab0fe20c_952x557.png 424w, https://substackcdn.com/image/fetch/$s_!VdRL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44d8abaf-2c06-4df1-b9ee-58cdab0fe20c_952x557.png 848w, https://substackcdn.com/image/fetch/$s_!VdRL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44d8abaf-2c06-4df1-b9ee-58cdab0fe20c_952x557.png 1272w, https://substackcdn.com/image/fetch/$s_!VdRL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44d8abaf-2c06-4df1-b9ee-58cdab0fe20c_952x557.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 role="img" 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><title></title><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><h3><strong>Step 7. Define an agent</strong></h3><p>At this point, we have many MCP tools, skills agent SOPs that need to be configured and made available for our agent to work.</p><p>This is easy if this is your first agent, but when you have dozens of them, each using their own set of artifacts, things get hard&#8230;</p><p>We solved this problem in traditional software with dependencies. We declare which packages our software depends on, so it can run in different environments.</p><p>Now it&#8217;s time to declare those dependencies with a new artifact called an <em>agent</em>. This way, we&#8217;d have our incident response agent, and we can define other agents for other purposes.</p><p>This guarantees the AI has all the tools it needs, so you do not need to provide them manually. Currently, there isn&#8217;t a proper package manager to install all of these, but it&#8217;s just a matter of time&#8230;</p><p><strong>Current state:</strong> We now have our agent, and we can delegate the entire incident response investigation to it. We just invoke it and wait for the results.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UyN-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3d77f20-c556-4b76-b7fa-b4d875ab7f74_958x563.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UyN-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3d77f20-c556-4b76-b7fa-b4d875ab7f74_958x563.png 424w, https://substackcdn.com/image/fetch/$s_!UyN-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3d77f20-c556-4b76-b7fa-b4d875ab7f74_958x563.png 848w, https://substackcdn.com/image/fetch/$s_!UyN-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3d77f20-c556-4b76-b7fa-b4d875ab7f74_958x563.png 1272w, https://substackcdn.com/image/fetch/$s_!UyN-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3d77f20-c556-4b76-b7fa-b4d875ab7f74_958x563.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UyN-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3d77f20-c556-4b76-b7fa-b4d875ab7f74_958x563.png" width="958" height="563" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f3d77f20-c556-4b76-b7fa-b4d875ab7f74_958x563.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:563,&quot;width&quot;:958,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!UyN-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3d77f20-c556-4b76-b7fa-b4d875ab7f74_958x563.png 424w, https://substackcdn.com/image/fetch/$s_!UyN-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3d77f20-c556-4b76-b7fa-b4d875ab7f74_958x563.png 848w, https://substackcdn.com/image/fetch/$s_!UyN-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3d77f20-c556-4b76-b7fa-b4d875ab7f74_958x563.png 1272w, https://substackcdn.com/image/fetch/$s_!UyN-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3d77f20-c556-4b76-b7fa-b4d875ab7f74_958x563.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 role="img" 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><title></title><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><h3><strong>Step 8. Execute your agent periodically</strong></h3><p>Up to this point, we have a fully defined agent that knows exactly what to do, but it only moves when you tell it to.</p><p>You have built a great tool, but you are still the one holding the power button&#8230;</p><p>Now that we can delegate most work to AI, you may ask: <em>Why am I still getting paged at 3 am just to invoke the agent and wait?</em></p><p>It&#8217;s time to set the AI agent to run autonomously&#8230;</p><p>I recommend using CLI tools to run your AI agent independently. We can start with a simple script that checks for work and runs the AI agent when found; otherwise, sleep for N minutes.</p><p><strong>Current state:</strong> Now the human isn&#8217;t involved in triggering the agent, but it will find the alarm and the agent&#8217;s output together.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lsQO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd7e6e4d-7e57-4425-a72f-31a8f6dbda20_1038x636.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lsQO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd7e6e4d-7e57-4425-a72f-31a8f6dbda20_1038x636.png 424w, https://substackcdn.com/image/fetch/$s_!lsQO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd7e6e4d-7e57-4425-a72f-31a8f6dbda20_1038x636.png 848w, https://substackcdn.com/image/fetch/$s_!lsQO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd7e6e4d-7e57-4425-a72f-31a8f6dbda20_1038x636.png 1272w, https://substackcdn.com/image/fetch/$s_!lsQO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd7e6e4d-7e57-4425-a72f-31a8f6dbda20_1038x636.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lsQO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd7e6e4d-7e57-4425-a72f-31a8f6dbda20_1038x636.png" width="1038" height="636" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bd7e6e4d-7e57-4425-a72f-31a8f6dbda20_1038x636.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:636,&quot;width&quot;:1038,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!lsQO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd7e6e4d-7e57-4425-a72f-31a8f6dbda20_1038x636.png 424w, https://substackcdn.com/image/fetch/$s_!lsQO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd7e6e4d-7e57-4425-a72f-31a8f6dbda20_1038x636.png 848w, https://substackcdn.com/image/fetch/$s_!lsQO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd7e6e4d-7e57-4425-a72f-31a8f6dbda20_1038x636.png 1272w, https://substackcdn.com/image/fetch/$s_!lsQO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd7e6e4d-7e57-4425-a72f-31a8f6dbda20_1038x636.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 role="img" 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><title></title><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><h3><strong>Step 9. Improve state management</strong></h3><p>The agent is now running on its own, but it&#8217;s still isolated on your local machine using basic loops. To make it a true part of your team, it needs to be integrated into your production environment&#8230;</p><p>The goal is to define an end-to-end workflow that triggers AI agents at the right time without human involvement. For example, a webhook from PagerDuty could automatically trigger the AI agent in Lambda.</p><p>For periodic reports, you may want to set up a cron<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-8" href="#footnote-8" target="_self">8</a> job that triggers the AI agent at regular intervals.</p><p>The AI agent performs the investigation and then posts a summary of the root cause or a periodic report to a Slack channel. This means your agent is working while you sleep, even if it only does one specific thing well.</p><p><strong>Current state:</strong> Now our agent is like a real engineer involved when an incident happens, or an engineer who has scheduled work in their calendar.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-kv2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7388cd2-038b-4bb9-af67-2dd27746cea3_1046x605.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-kv2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7388cd2-038b-4bb9-af67-2dd27746cea3_1046x605.png 424w, https://substackcdn.com/image/fetch/$s_!-kv2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7388cd2-038b-4bb9-af67-2dd27746cea3_1046x605.png 848w, https://substackcdn.com/image/fetch/$s_!-kv2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7388cd2-038b-4bb9-af67-2dd27746cea3_1046x605.png 1272w, https://substackcdn.com/image/fetch/$s_!-kv2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7388cd2-038b-4bb9-af67-2dd27746cea3_1046x605.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-kv2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7388cd2-038b-4bb9-af67-2dd27746cea3_1046x605.png" width="1046" height="605" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c7388cd2-038b-4bb9-af67-2dd27746cea3_1046x605.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:605,&quot;width&quot;:1046,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!-kv2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7388cd2-038b-4bb9-af67-2dd27746cea3_1046x605.png 424w, https://substackcdn.com/image/fetch/$s_!-kv2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7388cd2-038b-4bb9-af67-2dd27746cea3_1046x605.png 848w, https://substackcdn.com/image/fetch/$s_!-kv2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7388cd2-038b-4bb9-af67-2dd27746cea3_1046x605.png 1272w, https://substackcdn.com/image/fetch/$s_!-kv2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7388cd2-038b-4bb9-af67-2dd27746cea3_1046x605.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 role="img" 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><title></title><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><h3><strong>Step 10. Scale to multiple agents</strong></h3><p>At this stage, you have a specialized agent working 24/7.</p><p>But as your system grows, one agent can become overloaded with too many responsibilities. Just as you wouldn&#8217;t ask one engineer to handle every single microservice, we shouldn&#8217;t ask one agent to do it all.</p><p>The final step is to have multiple agents collaborating on the same incident. Each agent can have a different function based on its expertise:</p><ul><li><p>One agent gathers the raw logs while another checks for known infrastructure issues.</p></li><li><p>Another agent could review the recent code deployments for errors.</p></li></ul><p>There are different orchestration paradigms you can use, like sequential, routing, or swarms.</p><p>Even for the same function, there&#8217;s no limit to how much you specialize. If an incident response agent has too many details, you can create agents to check different parts of the system.</p><p>You need a bit of abstraction to manage your AI workforce, just as a manager coordinates a team of specialists. You just do the same: multiple specialist agents, and a manager that invokes each subagent.</p><p>You can use different triggers, such as schedules or events, to make agents collaborate via the file system. No need to start with complex agent-communication protocols; instead:</p><ol><li><p>Start with an orchestrator agent triggered by events, schedule, or polling.</p></li><li><p>The orchestrator invokes other subagents that you have also defined. Most AI companies already implement subagents.</p></li><li><p>All agents write to the filesystem, so they see each other&#8217;s work.</p></li></ol><p>I suggest running agents on your own computer and letting them work together by sharing files.</p><p><strong>Current state:</strong> At this point, the AI performs complex work with multiple steps without your involvement. Humans are no longer the bottleneck.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bGMs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fb3aca7-ad8f-474c-802b-2263e9b97578_1019x594.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bGMs!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fb3aca7-ad8f-474c-802b-2263e9b97578_1019x594.png 424w, https://substackcdn.com/image/fetch/$s_!bGMs!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fb3aca7-ad8f-474c-802b-2263e9b97578_1019x594.png 848w, https://substackcdn.com/image/fetch/$s_!bGMs!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fb3aca7-ad8f-474c-802b-2263e9b97578_1019x594.png 1272w, https://substackcdn.com/image/fetch/$s_!bGMs!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fb3aca7-ad8f-474c-802b-2263e9b97578_1019x594.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bGMs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fb3aca7-ad8f-474c-802b-2263e9b97578_1019x594.png" width="1019" height="594" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7fb3aca7-ad8f-474c-802b-2263e9b97578_1019x594.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:594,&quot;width&quot;:1019,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!bGMs!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fb3aca7-ad8f-474c-802b-2263e9b97578_1019x594.png 424w, https://substackcdn.com/image/fetch/$s_!bGMs!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fb3aca7-ad8f-474c-802b-2263e9b97578_1019x594.png 848w, https://substackcdn.com/image/fetch/$s_!bGMs!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fb3aca7-ad8f-474c-802b-2263e9b97578_1019x594.png 1272w, https://substackcdn.com/image/fetch/$s_!bGMs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fb3aca7-ad8f-474c-802b-2263e9b97578_1019x594.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 role="img" 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><title></title><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>We did it!</p><p>Now we have our autonomous AI agent for incident response.</p><p>I know it looks easier in diagrams than in practice, and the AI doesn&#8217;t work as expected. Let me also share some lessons from building AI agents.</p><div><hr></div><h2><strong>Lessons from the trenches</strong></h2><p>I&#8217;ve spent a lot of time building these agents, and I want to share some practical advice that will save you hours of frustration:</p><ul><li><p><strong>Make sure you have enough examples to build a robust agent.</strong> You wouldn&#8217;t want to automate a task that isn't frequent, so you're likely to have multiple instances to iterate on. I asked my team to handle all intakes of a service for a month. I&#8217;m sure your manager will be happy you're taking on more work.</p></li><li><p><strong>Iterate multiple times per step.</strong> Don&#8217;t move to the next step of the automation until you have solved several tickets or tasks to find the real patterns and failure modes.</p></li><li><p><strong>Don&#8217;t switch tabs while AI works.</strong> Watch the agent work live to catch its mistakes instead of letting it run in the background.</p></li><li><p><strong>Use tmux</strong><a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-9" href="#footnote-9" target="_self">9</a><strong> for persistent loops.</strong> Run your agents from your computer in a tmux session so they keep working even if you lose your terminal connection.</p></li><li><p><strong>Log everything for observability.</strong> Pipe all the agent&#8217;s output into a dedicated log file to give you the same level of visibility when you move to executing it 24/7.</p></li><li><p><strong>Refine prompts based on observations.</strong> Even after you consider the 10 steps done, new edge cases will arise. Make AI keep learning, either by updating it yourself or by letting the AI update its memory files between iterations.</p></li></ul><div><hr></div><h2><strong>Defining the role of the human in the loop</strong></h2><p>I want to be clear that this is not about all-human or all-AI systems&#8230;</p><p>I&#8217;ve focused the incident response agent examples on read-only tasks, such as checking alarms, metrics, and logs.</p><p>Each of us has to define where and when to involve humans for the highest leverage. You can have the agent triage the incident and suggest a fix, then wait for your approval and execution.</p><p>Maybe someone else wants to plug the AI into the codebase to create a PR with the fix and wait for a human to approve it and deploy the hotfix.</p><p>I still think we don&#8217;t want AI making changes in production without human oversight. I have read postmortems where AI ran unauthorized production operations in an AWS account without any human review.</p><p>If we think about the incident response process and a code change, there are many steps before we change something in the system&#8230;</p><p>My current stance on agents is to push the human to the right as much as possible. This is all about making the human do less work, but still overseeing. This is important because no one will ask the AI for ownership or accountability.</p><p>They&#8217;ll ask the humans for it!</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pTtY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea0fb247-5a41-4c75-b22a-c7570de02078_681x225.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pTtY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea0fb247-5a41-4c75-b22a-c7570de02078_681x225.png 424w, https://substackcdn.com/image/fetch/$s_!pTtY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea0fb247-5a41-4c75-b22a-c7570de02078_681x225.png 848w, https://substackcdn.com/image/fetch/$s_!pTtY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea0fb247-5a41-4c75-b22a-c7570de02078_681x225.png 1272w, https://substackcdn.com/image/fetch/$s_!pTtY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea0fb247-5a41-4c75-b22a-c7570de02078_681x225.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pTtY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea0fb247-5a41-4c75-b22a-c7570de02078_681x225.png" width="681" height="225" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ea0fb247-5a41-4c75-b22a-c7570de02078_681x225.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:225,&quot;width&quot;:681,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!pTtY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea0fb247-5a41-4c75-b22a-c7570de02078_681x225.png 424w, https://substackcdn.com/image/fetch/$s_!pTtY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea0fb247-5a41-4c75-b22a-c7570de02078_681x225.png 848w, https://substackcdn.com/image/fetch/$s_!pTtY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea0fb247-5a41-4c75-b22a-c7570de02078_681x225.png 1272w, https://substackcdn.com/image/fetch/$s_!pTtY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea0fb247-5a41-4c75-b22a-c7570de02078_681x225.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div><hr></div><h2><strong>TLDR: The Building Blocks of AI Agents</strong></h2><ul><li><p><strong>Brain (LLM):</strong> The Large Language Model processes information, makes decisions, and determines which steps to take.</p></li><li><p><strong>Hands (Tools &amp; MCP):</strong> They are the interfaces that allow the AI to interact with the real world. Using the MCP, an agent can execute code, query databases, or fetch logs instead of just &#8220;talking&#8221; back to you.</p></li><li><p><strong>Skills (Agent Skills &amp; SOPs):</strong> They teach the model how to perform tasks. This is like a junior engineer following a runbook. It reduces errors and hallucinations.</p></li><li><p><strong>Memory (Context &amp; Agents.md):</strong> This allows the agent to remember past actions. Short-term memory handles the current conversation. Long-term memory provides historical context through shared files. This prevents the agent from repeating mistakes.</p></li><li><p><strong>Manager (Orchestrator):</strong> Use an orchestrator to manage multiple specialized agents as you scale. One agent might find the error, while another suggests a fix, all working together toward a final result.</p></li><li><p><strong>Alarm clock (Cron job):</strong> It lets the agent run on a schedule without you having to manually start it.</p></li><li><p><strong>Workspace (Local filesystem):</strong> A common area where agents read and write. This allows them to collaborate on complex problems.</p></li></ul><div><hr></div><h2><strong>Closing Thoughts: The future of agentic work</strong></h2><p>It is often said that AI will not take your job, but someone using AI will.</p><p>I truly believe this.</p><p>But &#8220;using AI&#8221; does not just mean installing a new extension in your IDE. I have seen many people get frustrated when the AI does not do exactly what they want on the first try, thinking the AI is just dumb.</p><p>The people who succeed are the ones who build an army of AI agents to do the heavy lifting for them. All those AI companies are giving us default tools, but we are the ones who must adapt them to our specific needs.</p><p>I hope this guide was helpful and that you start building your own agents today.</p><div><hr></div><p>&#128075; I&#8217;d like to thank <a href="https://strategizeyourcareer.com/5eca9a08">Fran</a> for writing this newsletter!</p><ul><li><p>Also subscribe to his newsletter, <strong><a href="https://strategizeyourcareer.com/5eca9a08">StrategizeYourCareer</a>.</strong></p></li></ul><p>It will help you master productivity and the AI automation skills needed to thrive in your career, just like we learned in this post.</p><p><em>Remember to claim your free System Design Template by signing up today at <a href="https://strategizeyourcareer.com/5eca9a08">StrategizeYourCareer</a>. You can also take advantage of his special discount before it expires!</em></p><div><hr></div><p>If you find this newsletter valuable, share it with a friend, and subscribe if you haven&#8217;t already. There are <a href="http://newsletter.systemdesign.one/subscribe?group=true">group discounts</a>, <a href="http://newsletter.systemdesign.one/subscribe?gift=true">gift options</a>, and <a href="https://newsletter.systemdesign.one/leaderboard">referral rewards</a> available.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://www.linkedin.com/in/nk-systemdesign-one/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png" width="152" height="152" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:320,&quot;width&quot;:320,&quot;resizeWidth&quot;:152,&quot;bytes&quot;:74009,&quot;alt&quot;:&quot;Author Neo Kim; System design case studies&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://www.linkedin.com/in/nk-systemdesign-one/&quot;,&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="Author Neo Kim; System design case studies" title="Author Neo Kim; System design case studies" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption"><strong>&#128075; Find me on <a href="https://www.linkedin.com/in/nk-systemdesign-one/">LinkedIn</a> | <a href="https://x.com/intent/follow?screen_name=systemdesignone">Twitter</a> | <a href="https://www.threads.net/@systemdesignone">Threads</a> | <a href="https://www.instagram.com/systemdesignone/">Instagram</a></strong></figcaption></figure></div><div><hr></div><p>Thank you for supporting this newsletter.</p><p>You are now 210,001+ readers strong, very close to 210k. Let&#8217;s try to get 211k readers by 21 March. Consider sharing this post with your friends and get rewards.</p><p>Y&#8217;all are the best.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6oWl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" width="590" height="368.75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:800,&quot;resizeWidth&quot;:590,&quot;bytes&quot;:87878,&quot;alt&quot;:&quot;system design newsletter&quot;,&quot;title&quot;:&quot;system design newsletter&quot;,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/163380418?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="system design newsletter" title="system design newsletter" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.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 role="img" 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><title></title><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 class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/how-do-ai-agents-work?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/how-do-ai-agents-work?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p>An open standard that enables AI models to interact with local and remote data and tools. https://modelcontextprotocol.io/docs/getting-started/intro</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p>An AI-powered code editor designed for pair programming and agentic workflows. It also has a CLI available. https://cursor.com/</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-3" href="#footnote-anchor-3" class="footnote-number" contenteditable="false" target="_self">3</a><div class="footnote-content"><p>A standard format for providing context and instructions to AI agents within a repository. https://agents.md/</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-4" href="#footnote-anchor-4" class="footnote-number" contenteditable="false" target="_self">4</a><div class="footnote-content"><p>A document defining requirement levels like &#8220;MUST&#8221; and &#8220;SHOULD&#8221; used in engineering documentation. https://datatracker.ietf.org/doc/html/rfc2119</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-5" href="#footnote-anchor-5" class="footnote-number" contenteditable="false" target="_self">5</a><div class="footnote-content"><p>An AI agent framework designed to automate engineering tasks and workflows. It has an IDE and CLI as products https://kiro.dev/</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-6" href="#footnote-anchor-6" class="footnote-number" contenteditable="false" target="_self">6</a><div class="footnote-content"><p>An open-source framework for building and orchestrating autonomous AI agents. https://strandsagents.com/latest/</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-7" href="#footnote-anchor-7" class="footnote-number" contenteditable="false" target="_self">7</a><div class="footnote-content"><p>Anthropic's agentic CLI tool that can reason about and edit your codebase directly. https://claude.com/product/claude-code</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-8" href="#footnote-anchor-8" class="footnote-number" contenteditable="false" target="_self">8</a><div class="footnote-content"><p>A tool to execute commands on a schedule https://en.wikipedia.org/wiki/Cron</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-9" href="#footnote-anchor-9" class="footnote-number" contenteditable="false" target="_self">9</a><div class="footnote-content"><p>A terminal multiplexer that allows you to keep terminal sessions running in the background. https://github.com/tmux/tmux/wiki</p><p></p></div></div>]]></content:encoded></item><item><title><![CDATA[21 Reinforcement Learning (RL) Concepts Explained Simply]]></title><description><![CDATA[#130: Finally understand RL without getting confused by its fancy math equations]]></description><link>https://newsletter.systemdesign.one/p/what-is-reinforcement-learning</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/what-is-reinforcement-learning</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Sat, 14 Mar 2026 12:20:34 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/782723cc-fb12-4234-9759-4149a3cd7a78_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/what-is-reinforcement-learning/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>Reinforcement learning (<strong>RL</strong>) is making a comeback and becoming mainstream.</p><p>From humanoid robots and game-playing AIs that beat world champions to the LLMs you chat with every day, all are trained using RL, which lets them learn from experience and get better through feedback.</p><p>Contrary to many tutorials that can make it look so hard, RL is actually pretty intuitive, and you really don&#8217;t need a PhD to understand how it works.</p><p>In this newsletter, we will go through 21 key RL concepts to build a solid foundation from the ground up. These terms are all explained in plain language without using any fancy math equations.</p><p>Let&#8217;s start from the very beginning&#8230;</p><div><hr></div><h2><a href="https://coderabbit.link/neo-mar">Want to reduce AI coding bugs before they hit production? (Partner)</a></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://coderabbit.link/neo-mar" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!l5WB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71527969-46aa-4ba3-b906-9cf60b671161_1271x699.png 424w, https://substackcdn.com/image/fetch/$s_!l5WB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71527969-46aa-4ba3-b906-9cf60b671161_1271x699.png 848w, https://substackcdn.com/image/fetch/$s_!l5WB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71527969-46aa-4ba3-b906-9cf60b671161_1271x699.png 1272w, https://substackcdn.com/image/fetch/$s_!l5WB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71527969-46aa-4ba3-b906-9cf60b671161_1271x699.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!l5WB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71527969-46aa-4ba3-b906-9cf60b671161_1271x699.png" width="1271" height="699" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/71527969-46aa-4ba3-b906-9cf60b671161_1271x699.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:699,&quot;width&quot;:1271,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://coderabbit.link/neo-mar&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!l5WB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71527969-46aa-4ba3-b906-9cf60b671161_1271x699.png 424w, https://substackcdn.com/image/fetch/$s_!l5WB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71527969-46aa-4ba3-b906-9cf60b671161_1271x699.png 848w, https://substackcdn.com/image/fetch/$s_!l5WB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71527969-46aa-4ba3-b906-9cf60b671161_1271x699.png 1272w, https://substackcdn.com/image/fetch/$s_!l5WB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71527969-46aa-4ba3-b906-9cf60b671161_1271x699.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 role="img" 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><title></title><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>AI is writing more production code than ever, but it also introduces more risk.</p><p>CodeRabbit&#8217;s research found that AI-generated code contains 1.7x more issues, including 75% more logic errors.</p><p>That&#8217;s exactly why you should grab a copy of the <strong><a href="https://coderabbit.link/neo-mar">Ultimate Prompting Cheat Sheet</a></strong>.</p><p>Here&#8217;s what you get:</p><ul><li><p><strong>Proven prompting techniques to reduce AI coding errors.</strong></p></li><li><p>Actionable workflows for AI-assisted development.</p></li><li><p><strong>Clear frameworks for safer AI-generated code.</strong></p></li><li><p>Practical examples you can apply immediately.</p></li></ul><p>And many more!</p><p>These techniques reduce defects without slowing velocity, regardless of which AI coding tool you use.</p><p>Sign up and get access to the ultimate prompting cheat sheet right now:</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://coderabbit.link/neo-mar&quot;,&quot;text&quot;:&quot;GET INSTANT ACCESS&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://coderabbit.link/neo-mar"><span>GET INSTANT ACCESS</span></a></p><p>(Thanks to CodeRabbit for partnering on this post &amp; sharing the <a href="https://coderabbit.link/neo-mar">ultimate prompting cheat sheet</a>.)</p><div><hr></div><p>I want to reintroduce <strong><a href="https://www.linkedin.com/in/ashishbamania/">Ashish Bamania</a></strong> as a guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://www.linkedin.com/in/ashishbamania/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Shux!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470743b8-73e1-411b-85a6-80c14b0d8d54_1558x906.png 424w, https://substackcdn.com/image/fetch/$s_!Shux!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470743b8-73e1-411b-85a6-80c14b0d8d54_1558x906.png 848w, https://substackcdn.com/image/fetch/$s_!Shux!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470743b8-73e1-411b-85a6-80c14b0d8d54_1558x906.png 1272w, https://substackcdn.com/image/fetch/$s_!Shux!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470743b8-73e1-411b-85a6-80c14b0d8d54_1558x906.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Shux!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470743b8-73e1-411b-85a6-80c14b0d8d54_1558x906.png" width="1456" height="847" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/470743b8-73e1-411b-85a6-80c14b0d8d54_1558x906.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:847,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:null,&quot;href&quot;:&quot;https://www.linkedin.com/in/ashishbamania/&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Shux!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470743b8-73e1-411b-85a6-80c14b0d8d54_1558x906.png 424w, https://substackcdn.com/image/fetch/$s_!Shux!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470743b8-73e1-411b-85a6-80c14b0d8d54_1558x906.png 848w, https://substackcdn.com/image/fetch/$s_!Shux!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470743b8-73e1-411b-85a6-80c14b0d8d54_1558x906.png 1272w, https://substackcdn.com/image/fetch/$s_!Shux!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470743b8-73e1-411b-85a6-80c14b0d8d54_1558x906.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 role="img" 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><title></title><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>He&#8217;s a self-taught software engineer and an emergency physician. He is also the editor and primary author of the newsletters <a href="https://intoai.pub/">Into AI</a> and <a href="https://intoquantum.pub/">Into Quantum</a>.</p><p>The images used in this newsletter come from his books:</p><ul><li><p><strong><a href="https://bamaniaashish.gumroad.com/l/llmbook/NEO20">LLMs In 100 Images</a></strong></p></li></ul><ul><li><p><strong>Reinforcement Learning in 100 Images </strong>(upcoming)</p></li></ul><p>Grab the book at <strong>20% discount today</strong> with the discount code <strong><a href="https://bamaniaashish.gumroad.com/l/llmbook/NEO20">NEO20</a></strong>, pre-applied to the link above!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://bamaniaashish.gumroad.com/l/llmbook/NEO20" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OdW0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28809feb-c484-45a6-a7ef-ca9c42d63270_6912x3456.png 424w, https://substackcdn.com/image/fetch/$s_!OdW0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28809feb-c484-45a6-a7ef-ca9c42d63270_6912x3456.png 848w, https://substackcdn.com/image/fetch/$s_!OdW0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28809feb-c484-45a6-a7ef-ca9c42d63270_6912x3456.png 1272w, https://substackcdn.com/image/fetch/$s_!OdW0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28809feb-c484-45a6-a7ef-ca9c42d63270_6912x3456.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OdW0!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28809feb-c484-45a6-a7ef-ca9c42d63270_6912x3456.png" width="730" height="365" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/28809feb-c484-45a6-a7ef-ca9c42d63270_6912x3456.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:728,&quot;width&quot;:1456,&quot;resizeWidth&quot;:730,&quot;bytes&quot;:834004,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://bamaniaashish.gumroad.com/l/llmbook/NEO20&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.intoai.pub/i/189764942?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28809feb-c484-45a6-a7ef-ca9c42d63270_6912x3456.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-large" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!OdW0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28809feb-c484-45a6-a7ef-ca9c42d63270_6912x3456.png 424w, https://substackcdn.com/image/fetch/$s_!OdW0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28809feb-c484-45a6-a7ef-ca9c42d63270_6912x3456.png 848w, https://substackcdn.com/image/fetch/$s_!OdW0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28809feb-c484-45a6-a7ef-ca9c42d63270_6912x3456.png 1272w, https://substackcdn.com/image/fetch/$s_!OdW0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28809feb-c484-45a6-a7ef-ca9c42d63270_6912x3456.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 role="img" 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><title></title><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><h3><strong>1. What is Reinforcement learning?</strong></h3><p>Let&#8217;s start with the definition of Reinforcement Learning (<strong>RL</strong>).</p><p>RL is a type of machine learning (besides Supervised and Unsupervised learning) that deals with an entity called an &#8216;Agent&#8217;, trying to learn to perform a task better in its &#8216;Environment&#8217; through trial and error.</p><p>For example, a deer (Agent) foraging in a forest (Environment) to survive, avoiding being eaten by its predators.</p><p>We will soon move to more AI-related examples, I promise, but first, let&#8217;s better understand what the terms &#8216;Agent&#8217; and &#8216;Environment&#8217; mean.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KWWU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KWWU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!KWWU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!KWWU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!KWWU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KWWU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.png" width="1080" height="1080" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1080,&quot;width&quot;:1080,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:58194,&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://www.intoai.pub/i/189764942?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!KWWU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!KWWU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!KWWU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!KWWU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f659f9a-ad05-41bf-ad19-3aa5fb54ea19_1080x1080.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 role="img" 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><title></title><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><h3><strong>2. Agent</strong></h3><p>An agent is the central entity in RL.</p><p>It is one that studies and interacts with its environment, makes decisions, takes actions, and learns from its outcomes.</p><p>In our previous case, we used a deer as an agent example, but from now on, we will discuss concepts assuming an LLM as the agent as well.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!G36e!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!G36e!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!G36e!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!G36e!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!G36e!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!G36e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.png" width="1080" height="1080" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1080,&quot;width&quot;:1080,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:37902,&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://www.intoai.pub/i/189764942?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!G36e!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!G36e!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!G36e!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!G36e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39eff2da-de63-42f3-99cf-a5c0a70e864d_1080x1080.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 role="img" 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><title></title><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><h3><strong>3. Environment</strong></h3><p>The environment is everything outside the agent with which it interacts.</p><p>The function of an environment is to:</p><ul><li><p>Get affected by an agent&#8217;s actions</p></li><li><p>Change its state (or maybe hold its state constant) depending on the agent&#8217;s actions</p></li><li><p>Give the agent a reward or punishment based on its actions, so that the agent can modify its intent the next time it takes an action</p></li></ul><p>In the first case, the deer was functioning in a forest as its environment. Based on the deer&#8217;s actions (moving around in different directions), either the forest (environment) lets it progress towards food (reward) or it exposes it to a cheetah (punishment).</p><p>In the case of an LLM as an agent, everything outside it, such as the following, is part of its environment:</p><ul><li><p>User inputs</p></li><li><p>System prompt</p></li><li><p>Tools / APIs it can call</p></li><li><p>System responses (tool results, API outputs, error messages)</p></li><li><p>Context (documents, conversation history, files)</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!46u0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa56e779c-0fa0-4bba-b950-203d27617524_1080x1080.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!46u0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa56e779c-0fa0-4bba-b950-203d27617524_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!46u0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa56e779c-0fa0-4bba-b950-203d27617524_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!46u0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa56e779c-0fa0-4bba-b950-203d27617524_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!46u0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa56e779c-0fa0-4bba-b950-203d27617524_1080x1080.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!46u0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa56e779c-0fa0-4bba-b950-203d27617524_1080x1080.png" width="1080" height="1080" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a56e779c-0fa0-4bba-b950-203d27617524_1080x1080.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1080,&quot;width&quot;:1080,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:34579,&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://www.intoai.pub/i/189764942?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa56e779c-0fa0-4bba-b950-203d27617524_1080x1080.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!46u0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa56e779c-0fa0-4bba-b950-203d27617524_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!46u0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa56e779c-0fa0-4bba-b950-203d27617524_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!46u0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa56e779c-0fa0-4bba-b950-203d27617524_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!46u0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa56e779c-0fa0-4bba-b950-203d27617524_1080x1080.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 role="img" 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><title></title><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><h3><strong>4. State</strong></h3><p>A State is a snapshot of an environment at a time. It is everything an agent sees at a given moment that it can use to make its next decision.</p><p>For a deer agent, it could be its current location in the forest, nearby predators, and the time of day.</p><p>For an LLM agent, it is all the context it has access to at a moment, which it can use to decide its next action.</p><p><em>But what&#8217;s action?</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9jG5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9jG5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!9jG5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!9jG5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!9jG5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9jG5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.png" width="1080" height="1080" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1080,&quot;width&quot;:1080,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:113427,&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://www.intoai.pub/i/189764942?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!9jG5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!9jG5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!9jG5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!9jG5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b4c95a-3713-4961-aecd-583635e1917c_1080x1080.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 role="img" 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><title></title><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><h3><strong>5. Action</strong></h3>
      <p>
          <a href="https://newsletter.systemdesign.one/p/what-is-reinforcement-learning">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[I struggled with system design until I learned these 114 concepts]]></title><description><![CDATA[#129: Part 3 - Webhooks, WebRTC, CQRS, and 35 others.]]></description><link>https://newsletter.systemdesign.one/p/system-design-fundamentals</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/system-design-fundamentals</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Tue, 10 Mar 2026 16:27:36 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/7b3dab87-3707-4525-852e-201fb95d33fb_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/system-design-fundamentals/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li><li><p><em>Block diagrams created using <a href="https://app.eraser.io/auth/sign-up?ref=neo">Eraser</a>.</em></p></li></ul><div><hr></div><p>No time for small talk today:</p><p>Following is the third of a premium 3-part newsletter series... if you want to be successful with system design in 2026, then this newsletter is for YOU.</p><p>On with part 3 of the newsletter:</p><p>===</p><p>Some of these are foundational, and some are quite advanced. ALL of them are super useful to engineers building production-ready systems.</p><p>Curious to know how many were new to you:</p><ol start="77"><li><p>Webhooks,</p></li><li><p>WebRTC,</p></li><li><p>CQRS,</p></li><li><p>Event Sourcing,</p></li><li><p>Service Discovery,</p></li><li><p>Circuit Breaker Pattern,</p></li><li><p>Bulkhead Pattern,</p></li><li><p>Strangler Fig Pattern,</p></li><li><p>Backend for Frontend.</p></li><li><p>Sidecar Pattern,</p></li><li><p>Service Mesh,</p></li><li><p>Observability,</p></li><li><p>Logging,</p></li><li><p>Metrics,</p></li><li><p>Distributed Tracing,</p></li><li><p>Correlation IDs,</p></li><li><p>Full-Text Search Engine,</p></li><li><p>Time Series Database,</p></li><li><p>Vector Database,</p></li><li><p>Materialized Views,</p></li><li><p>Query Optimization,</p></li><li><p>Connection Pooling,</p></li><li><p>Cache Stampede,</p></li><li><p>Cache Warming,</p></li><li><p>PACELC Theorem,</p></li><li><p>Security Secrets Management,</p></li><li><p>Role-Based Access Control,</p></li><li><p>Single Sign-On,</p></li><li><p>Checksums,</p></li><li><p>Bloom Filter,</p></li><li><p>B-trees and B+ trees,</p></li><li><p>LSM Tree,</p></li><li><p>Merkle Tree,</p></li><li><p>HyperLogLog,</p></li><li><p>Batch vs Stream Processing,</p></li><li><p>ETL Pipelines,</p></li><li><p>MapReduce,</p></li><li><p>Erasure Coding.</p></li></ol><p>For each, I&#8217;ll share:</p><ul><li><p>What it is &amp; how it works--in simple words</p></li><li><p>A real-world analogy</p></li><li><p>Tradeoffs</p></li><li><p>Why it matters</p></li></ul><p>Let&#8217;s go.</p><div><hr></div><h2><a href="https://orchidsapp.link/neokim">The best way to build any app (Partner)</a></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://orchidsapp.link/neokim" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Yv56!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 424w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 848w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 1272w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Yv56!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e7ea1369-7f5d-400e-8b47-3c49bf1e055e_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;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://orchidsapp.link/neokim&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!Yv56!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 424w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 848w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_1600x900.png 1272w, https://substackcdn.com/image/fetch/$s_!Yv56!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7ea1369-7f5d-400e-8b47-3c49bf1e055e_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 role="img" 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><title></title><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 &#8220;AI app builders&#8221; aren&#8217;t actually app builders. They are infrastructure middlemen. You live inside their box, choose from their secret stack, and force you to start over the moment you want to use a different database, payment processor, or tool.</p><p>With <a href="https://orchidsapp.link/neokim">Orchids</a>:</p><ul><li><p>You&#8217;re not locked-in to Supabase or Stripe.</p></li><li><p>Not forced to spend credits, bring your own AI subscriptions with you.</p></li><li><p>One-click deployment straight to Vercel</p></li></ul><p>Build  anything. From web, mobile, internal tools, browser extensions, scripts, and bots. <a href="https://orchidsapp.link/neokim">Orchids.app</a> is capable of building anything that you can put your mind to.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://orchidsapp.link/neokim&quot;,&quot;text&quot;:&quot;Get Started Today&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://orchidsapp.link/neokim"><span>Get Started Today</span></a></p><p><strong>Use this discount code to get a onetime 15% off during checkout: MARCH15</strong></p><div><hr></div><h2><strong>77. Webhooks</strong></h2><blockquote><p>Webhooks are HTTP callbacks that allow one system to notify another system when an event occurs by sending a POST request to a configured URL.</p></blockquote><p>Instead of constantly polling for updates, the source system pushes data to your endpoint when something happens.</p><p>You register a URL with the provider, and they call it when events trigger. Webhooks enable real-time, event-driven integrations between systems.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YE7V!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfa596d6-05ab-4ee3-830c-9dd42c440094_1554x956.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YE7V!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfa596d6-05ab-4ee3-830c-9dd42c440094_1554x956.png 424w, https://substackcdn.com/image/fetch/$s_!YE7V!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfa596d6-05ab-4ee3-830c-9dd42c440094_1554x956.png 848w, https://substackcdn.com/image/fetch/$s_!YE7V!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfa596d6-05ab-4ee3-830c-9dd42c440094_1554x956.png 1272w, https://substackcdn.com/image/fetch/$s_!YE7V!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfa596d6-05ab-4ee3-830c-9dd42c440094_1554x956.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YE7V!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfa596d6-05ab-4ee3-830c-9dd42c440094_1554x956.png" width="1456" height="896" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dfa596d6-05ab-4ee3-830c-9dd42c440094_1554x956.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:896,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!YE7V!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfa596d6-05ab-4ee3-830c-9dd42c440094_1554x956.png 424w, https://substackcdn.com/image/fetch/$s_!YE7V!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfa596d6-05ab-4ee3-830c-9dd42c440094_1554x956.png 848w, https://substackcdn.com/image/fetch/$s_!YE7V!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfa596d6-05ab-4ee3-830c-9dd42c440094_1554x956.png 1272w, https://substackcdn.com/image/fetch/$s_!YE7V!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfa596d6-05ab-4ee3-830c-9dd42c440094_1554x956.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 role="img" 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><title></title><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>Analogy</h3><p>A doorbell that alerts you when someone arrives instead of you checking the door every few minutes&#8230;</p><p>When a package arrives, the delivery person rings the bell, and you respond immediately. You don&#8217;t waste time repeatedly checking if anyone&#8217;s there.</p><h3>Tradeoff</h3><p>Webhooks eliminate polling overhead and provide near-instant notifications.</p><p>Yet they require exposing a public endpoint, handling retries when your server is down, securing the endpoint against unauthorized requests, and handling duplicate or out-of-order events.</p><p>The sender controls retry logic, and you can&#8217;t always guarantee delivery.</p><h3>Why it matters</h3><p>Integrating with payment providers like Stripe, receiving GitHub repository events, getting Slack notifications, building event-driven workflows, or any system needing real-time notifications from external services.</p><p>Essential for modern API integrations. Combine with message queues for reliable processing and idempotency for handling duplicates.</p><h2><strong>78. WebRTC</strong></h2><blockquote><p>WebRTC (Web Real-Time Communication) is a technology that enables peer-to-peer<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a> audio, video, and data sharing directly between browsers without requiring servers to relay media.</p></blockquote><p>After initial signaling through a server to establish the connection, media flows directly between peers.</p><p>WebRTC automatically handles:</p><ul><li><p>Getting through NAT and firewalls</p></li><li><p>Encrypting the connection</p></li><li><p>Adjusting video quality based on network speed (adaptive bitrate streaming)</p></li></ul><p>It&#8217;s built into modern browsers, so users don&#8217;t need to install plugins.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9fWh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ffd443a-7b01-44af-bcdf-a75adc56d0ab_1600x547.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9fWh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ffd443a-7b01-44af-bcdf-a75adc56d0ab_1600x547.png 424w, https://substackcdn.com/image/fetch/$s_!9fWh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ffd443a-7b01-44af-bcdf-a75adc56d0ab_1600x547.png 848w, https://substackcdn.com/image/fetch/$s_!9fWh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ffd443a-7b01-44af-bcdf-a75adc56d0ab_1600x547.png 1272w, https://substackcdn.com/image/fetch/$s_!9fWh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ffd443a-7b01-44af-bcdf-a75adc56d0ab_1600x547.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9fWh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ffd443a-7b01-44af-bcdf-a75adc56d0ab_1600x547.png" width="1456" height="498" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6ffd443a-7b01-44af-bcdf-a75adc56d0ab_1600x547.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:498,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!9fWh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ffd443a-7b01-44af-bcdf-a75adc56d0ab_1600x547.png 424w, https://substackcdn.com/image/fetch/$s_!9fWh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ffd443a-7b01-44af-bcdf-a75adc56d0ab_1600x547.png 848w, https://substackcdn.com/image/fetch/$s_!9fWh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ffd443a-7b01-44af-bcdf-a75adc56d0ab_1600x547.png 1272w, https://substackcdn.com/image/fetch/$s_!9fWh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ffd443a-7b01-44af-bcdf-a75adc56d0ab_1600x547.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 role="img" 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><title></title><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>Analogy</h3><p>It is like two people being introduced by a mutual friend:</p><p>The friend shares their phone number, but once they start talking, the friend is no longer on the call.</p><h3>Tradeoff</h3><p>WebRTC offers very low latency, thus making it ideal for live conversations. It can also reduce server costs because media often bypasses backend servers.</p><p>But:</p><ul><li><p>It&#8217;s difficult to implement correctly</p></li><li><p>You usually need a TURN server as a backup when a direct connection cannot be made</p></li><li><p>Debugging network problems can be hard</p></li><li><p>Some corporate networks block peer-to-peer connections</p></li></ul><h3>Why it matters</h3><p>WebRTC powers:</p><ul><li><p>Video calls</p></li><li><p>Screen sharing</p></li><li><p>Voice chat in games</p></li><li><p>Live collaboration tools</p></li></ul><p>It&#8217;s used in Zoom, Google Meet, and Discord.</p><p>If you&#8217;re building a real-time app, you can use WebRTC directly. But consider managed services like Twilio or Agora so you do not have to run your own signaling and TURN servers.</p><h2><strong>79. CQRS</strong></h2><blockquote><p>CQRS (Command Query Responsibility Segregation) means separating how your system writes data from how it reads data.</p></blockquote><ul><li><p>Commands are used to change data. They use a write model optimized to handle updates.</p></li><li><p>Queries are used to read data. They go to a separate read model designed for fast retrieval.</p></li></ul><p>The read model is often eventually consistent, updated asynchronously from the write model using events.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!G-b3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37241a29-75d8-448a-b7ae-7b76dac7db8f_1600x978.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!G-b3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37241a29-75d8-448a-b7ae-7b76dac7db8f_1600x978.png 424w, https://substackcdn.com/image/fetch/$s_!G-b3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37241a29-75d8-448a-b7ae-7b76dac7db8f_1600x978.png 848w, https://substackcdn.com/image/fetch/$s_!G-b3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37241a29-75d8-448a-b7ae-7b76dac7db8f_1600x978.png 1272w, https://substackcdn.com/image/fetch/$s_!G-b3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37241a29-75d8-448a-b7ae-7b76dac7db8f_1600x978.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!G-b3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37241a29-75d8-448a-b7ae-7b76dac7db8f_1600x978.png" width="1456" height="890" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/37241a29-75d8-448a-b7ae-7b76dac7db8f_1600x978.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:890,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!G-b3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37241a29-75d8-448a-b7ae-7b76dac7db8f_1600x978.png 424w, https://substackcdn.com/image/fetch/$s_!G-b3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37241a29-75d8-448a-b7ae-7b76dac7db8f_1600x978.png 848w, https://substackcdn.com/image/fetch/$s_!G-b3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37241a29-75d8-448a-b7ae-7b76dac7db8f_1600x978.png 1272w, https://substackcdn.com/image/fetch/$s_!G-b3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37241a29-75d8-448a-b7ae-7b76dac7db8f_1600x978.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 role="img" 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><title></title><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>Analogy</h3><p>Imagine a restaurant with two separate counters:</p><p>One counter takes orders... it focuses on taking them correctly. The other counter only handles pickups. It focuses on quickly delivering food to customers.</p><p>Both handle the same orders, but each serves a different purpose.</p><h3>Tradeoff</h3><p>Benefits:</p><ul><li><p>Scale reads &amp; writes separately</p></li><li><p>Design different data models for reading and writing</p></li><li><p>Create specialized read models from the same write model</p></li></ul><p>Drawbacks:</p><ul><li><p>Adds architectural complexity</p></li><li><p>Read side may not reflect changes immediately</p></li><li><p>Requires event handling or synchronization between models</p></li><li><p>Makes the system harder to understand and maintain</p></li></ul><p>It is usually too complex for simple CRUD applications.</p><h3>Why it matters</h3><p>CQRS is useful when:</p><ul><li><p>Your system has very different read &amp; write workloads</p></li><li><p>Reads significantly outnumber writes</p></li><li><p>You need many views of the same data</p></li><li><p>Domain &amp; business logic is complex</p></li></ul><p>It&#8217;s often used together with Event Sourcing.</p><p>But a single model for both reads and writes is usually enough for simple systems.</p><h2><strong>80. Event Sourcing</strong></h2><blockquote><p>Event Sourcing is a way of storing data in which you record every change that happens in the system, rather than only saving the latest state.</p></blockquote><p>Each change gets captured as an immutable event.</p><p>You can rebuild the current state by replaying events from the beginning or from a snapshot. You can also rebuild the state at any point in time and audit the complete history of changes.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9Q8m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bd0fa7-24fd-4e0b-8c01-48a52f771577_1600x969.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9Q8m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bd0fa7-24fd-4e0b-8c01-48a52f771577_1600x969.png 424w, https://substackcdn.com/image/fetch/$s_!9Q8m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bd0fa7-24fd-4e0b-8c01-48a52f771577_1600x969.png 848w, https://substackcdn.com/image/fetch/$s_!9Q8m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bd0fa7-24fd-4e0b-8c01-48a52f771577_1600x969.png 1272w, https://substackcdn.com/image/fetch/$s_!9Q8m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bd0fa7-24fd-4e0b-8c01-48a52f771577_1600x969.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9Q8m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bd0fa7-24fd-4e0b-8c01-48a52f771577_1600x969.png" width="1456" height="882" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/37bd0fa7-24fd-4e0b-8c01-48a52f771577_1600x969.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:882,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!9Q8m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bd0fa7-24fd-4e0b-8c01-48a52f771577_1600x969.png 424w, https://substackcdn.com/image/fetch/$s_!9Q8m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bd0fa7-24fd-4e0b-8c01-48a52f771577_1600x969.png 848w, https://substackcdn.com/image/fetch/$s_!9Q8m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bd0fa7-24fd-4e0b-8c01-48a52f771577_1600x969.png 1272w, https://substackcdn.com/image/fetch/$s_!9Q8m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bd0fa7-24fd-4e0b-8c01-48a52f771577_1600x969.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 role="img" 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><title></title><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>Analogy</h3><p>Think of a bank that records every transaction in a ledger:</p><p>Instead of only storing your current balance, bank keeps a list of all deposits and withdrawals. Your balance can always be calculated by adding up all those transactions.</p><h3>Tradeoff</h3><p>Benefits:</p><ul><li><p>You get a history of all changes</p></li><li><p>Easy to audit what happened and when</p></li><li><p>You can rebuild the system state at any time</p></li><li><p>You can create new views or reports from past events</p></li></ul><p>Drawbacks:</p><ul><li><p>Harder to design &amp; implement</p></li><li><p>Events are immutable, so fixing mistakes requires new corrective events</p></li><li><p>Getting the current state often requires projections or snapshots</p></li><li><p>Event formats may change over time, which makes schema evolution difficult</p></li><li><p>Event storage grows unbounded without snapshots</p></li></ul><h3>Why it matters</h3><ul><li><p>Audit-heavy domains such as financial systems</p></li><li><p>Systems that need historical queries</p></li><li><p>Systems that need many views built from the same data</p></li></ul><p>It&#8217;s often used together with CQRS.</p><h2><strong>81. Service Discovery</strong></h2><blockquote><p>Service discovery allows services within a system to automatically find and communicate with each other, eliminating the need for fixed IP addresses.</p></blockquote><p>When a service starts, it registers itself in a service registry. The registry tracks where each service instance is running. When another service wants to call it, it asks the registry for the instances and connects to one of them.</p><p>Common tools: Consul, etcd, and Eureka.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LWg3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F087b7f71-5e95-4550-9b26-c8c8fd74894b_1600x823.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LWg3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F087b7f71-5e95-4550-9b26-c8c8fd74894b_1600x823.png 424w, https://substackcdn.com/image/fetch/$s_!LWg3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F087b7f71-5e95-4550-9b26-c8c8fd74894b_1600x823.png 848w, https://substackcdn.com/image/fetch/$s_!LWg3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F087b7f71-5e95-4550-9b26-c8c8fd74894b_1600x823.png 1272w, https://substackcdn.com/image/fetch/$s_!LWg3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F087b7f71-5e95-4550-9b26-c8c8fd74894b_1600x823.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LWg3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F087b7f71-5e95-4550-9b26-c8c8fd74894b_1600x823.png" width="1456" height="749" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/087b7f71-5e95-4550-9b26-c8c8fd74894b_1600x823.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:749,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!LWg3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F087b7f71-5e95-4550-9b26-c8c8fd74894b_1600x823.png 424w, https://substackcdn.com/image/fetch/$s_!LWg3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F087b7f71-5e95-4550-9b26-c8c8fd74894b_1600x823.png 848w, https://substackcdn.com/image/fetch/$s_!LWg3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F087b7f71-5e95-4550-9b26-c8c8fd74894b_1600x823.png 1272w, https://substackcdn.com/image/fetch/$s_!LWg3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F087b7f71-5e95-4550-9b26-c8c8fd74894b_1600x823.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 role="img" 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><title></title><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>Analogy</h3><p>Think of it like a phone directory:</p><p>Instead of remembering everyone&#8217;s phone number, you look them up in the directory. If someone changes their number, the directory gets updated so people can still reach them.</p><h3>Tradeoff</h3><ul><li><p>Requires health checks</p></li><li><p>Adds infrastructure complexity</p></li><li><p>It can become a critical dependency</p></li><li><p>Service lookups can add a small amount of latency</p></li><li><p>Cached results might sometimes point to instances that are no longer healthy</p></li></ul><h3>Why it matters</h3><p>Service discovery is important in environments where services move or scale frequently:</p><ul><li><p>Microservices architecture</p></li><li><p>Container platforms like Kubernetes</p></li><li><p>Cloud systems with auto-scaling</p></li></ul><p>It allows services to locate and communicate with each other even when their IP addresses or instances change dynamically.</p><h2><strong>82. Circuit Breaker Pattern</strong></h2><blockquote><p>Circuit breaker pattern protects a system from repeatedly calling a failing service.</p></blockquote><p>A circuit breaker sits between a service and the dependency it calls (for example, another service, API, or database). It monitors failures such as errors or timeouts.</p><p>If failures pass a threshold, the circuit breaker &#8220;opens&#8221; and stops sending requests to the failing service. Instead, it immediately returns an error or a fallback response.</p><p>After a set time, the circuit breaker moves to a &#8220;half-open&#8221; state. It allows a small number of test requests.</p><ul><li><p>If those succeed, the circuit &#8220;closes&#8221; and normal traffic resumes.</p></li><li><p>If they fail, the circuit &#8220;opens&#8221; again.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cxjV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b03643-4967-49be-ade0-bdf90d213c71_1600x616.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cxjV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b03643-4967-49be-ade0-bdf90d213c71_1600x616.png 424w, https://substackcdn.com/image/fetch/$s_!cxjV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b03643-4967-49be-ade0-bdf90d213c71_1600x616.png 848w, https://substackcdn.com/image/fetch/$s_!cxjV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b03643-4967-49be-ade0-bdf90d213c71_1600x616.png 1272w, https://substackcdn.com/image/fetch/$s_!cxjV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b03643-4967-49be-ade0-bdf90d213c71_1600x616.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cxjV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b03643-4967-49be-ade0-bdf90d213c71_1600x616.png" width="1456" height="561" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72b03643-4967-49be-ade0-bdf90d213c71_1600x616.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:561,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!cxjV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b03643-4967-49be-ade0-bdf90d213c71_1600x616.png 424w, https://substackcdn.com/image/fetch/$s_!cxjV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b03643-4967-49be-ade0-bdf90d213c71_1600x616.png 848w, https://substackcdn.com/image/fetch/$s_!cxjV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b03643-4967-49be-ade0-bdf90d213c71_1600x616.png 1272w, https://substackcdn.com/image/fetch/$s_!cxjV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72b03643-4967-49be-ade0-bdf90d213c71_1600x616.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 role="img" 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><title></title><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>Analogy</h3><p>It works like an electrical circuit breaker in a house:</p><p>If too much current flows, the breaker cuts power to prevent damage. After the problem gets fixed, you reset the breaker and power flows again.</p><h3>Tradeoff</h3><p>Benefits:</p><ul><li><p>Prevents cascading failures in distributed systems</p></li><li><p>Reduces load on failing services so they can recover</p></li><li><p>Fails fast instead of waiting for long timeouts</p></li><li><p>Protects system resources</p></li></ul><p>Drawbacks:</p><ul><li><p>Adds complexity to service calls</p></li><li><p>Requires tuning thresholds &amp; timeout values</p></li><li><p>Can open unnecessarily if thresholds are set incorrectly</p></li><li><p>Needs monitoring to detect when circuits are open</p></li></ul><h3>Why it matters</h3><p>It&#8217;s useful when systems make network calls that can fail, such as:</p><ul><li><p>Microservices calling other services</p></li><li><p>Services calling external APIs</p></li><li><p>Systems that depend on remote databases or infrastructure</p></li></ul><p>It helps prevent one failing dependency from causing failures across the entire system.</p><p>Common libraries: Resilience4j &amp; Polly.</p><div><hr></div><p><em><strong>Reminder: this is a teaser of the subscriber-only post, exclusive to my golden members.</strong></em></p><p>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>Full access to system design case studies</strong></p></li><li><p>FREE access to (coming) Design, Build, Scale newsletter series</p></li><li><p><strong>FREE access to (coming) popular interview question breakdowns</strong></p></li></ul><p>And more!</p><p>Get 10x the results you currently get with 1/10th the time, energy &amp; effort.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe&quot;,&quot;text&quot;:&quot;Get Instant Access&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe"><span>Get Instant Access</span></a></p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/system-design-fundamentals">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[I Struggled With System Design Interview Until I Learned This Framework]]></title><description><![CDATA[#128: From Someone Who Failed and Then Passed]]></description><link>https://newsletter.systemdesign.one/p/how-to-prepare-for-system-design-interview</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/how-to-prepare-for-system-design-interview</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Sat, 07 Mar 2026 12:50:35 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/ed5c1145-c042-4545-b6e9-d41f7579fd92_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p> </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/how-to-prepare-for-system-design-interview/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>In 2021, I applied to Amazon and <em>failed</em> the system design interview.</p><p>I knew something was off during the interview, but I couldn&#8217;t figure out what. At that time, I was a Software Engineer at Trainline on the Search/Checkout Web Services team, building software for over 100 million customers across Europe. I could code, I understood distributed systems, and I had shipped real features.</p><p>On paper, everything looked fine.</p><p>Looking back, I can see exactly what I missed&#8230;</p><p>I jumped straight into designing without clarifying requirements, never validated my assumptions, and never asked what actually mattered. I just started drawing boxes and arrows. I felt great in the moment and got smiles from the interviewer, but ultimately I failed.</p><p>Fast forward today&#8230;</p><p>I&#8217;m an L5 Software Engineer at AWS, who has contributed to CloudWatch, EC2, and Regional Services. I conduct system design interviews for candidates. That journey from failure to interviewer taught me something important: most engineers who fail these interviews aren&#8217;t bad engineers. They just don&#8217;t have a framework for turning vague problems into conversations.</p><p>This newsletter is everything I wish I knew before my 2021 interview.</p><p>I&#8217;m going to share what you actually need to pass: the framework, the pacing, the collaboration checkpoints, and the mindset that separates candidates who pass from those who don&#8217;t.</p><p>Before we get into frameworks and strategies, let&#8217;s explore why these interviews feel so different from everything else you do as an engineer.</p><p>Onward.</p><div><hr></div><h3><strong><a href="https://serpapi.com/?utm_source=thesystemdesignnewsletter">Need public web data, without scraper headaches? (Partner)</a></strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://serpapi.com/?utm_source=thesystemdesignnewsletter" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Hdlc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Hdlc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg" width="1200" height="1171" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1171,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:182785,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:&quot;https://serpapi.com/?utm_source=thesystemdesignnewsletter&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/180977546?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Hdlc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.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 role="img" 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><title></title><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><a href="https://serpapi.com/?utm_source=thesystemdesignnewsletter">SerpApi</a></strong> turns search results into predictable JSON with built-in scale, location options, and protection from blocks.</p><p>That&#8217;s why engineers use it to ship:</p><ul><li><p>AI applications</p></li><li><p>Product research</p></li><li><p>Price tracking</p></li><li><p>SEO insights</p></li></ul><p>All without maintaining scrapers or infrastructure.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://serpapi.com/?utm_source=thesystemdesignnewsletter&quot;,&quot;text&quot;:&quot;Try For Free&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://serpapi.com/?utm_source=thesystemdesignnewsletter"><span>Try For Free</span></a></p><p>(I&#8217;d like to thank <a href="https://serpapi.com/?utm_source=thesystemdesignnewsletter">SerpApi</a> for partnering on this post.)</p><div><hr></div><p>I want to introduce <strong><a href="http://linkedin.com/in/abdirahman-sj">Abdirahman Jama</a></strong> as the guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="http://linkedin.com/in/abdirahman-sj" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!C231!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 424w, https://substackcdn.com/image/fetch/$s_!C231!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 848w, https://substackcdn.com/image/fetch/$s_!C231!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 1272w, https://substackcdn.com/image/fetch/$s_!C231!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!C231!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png" width="1456" height="807" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:807,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;http://linkedin.com/in/abdirahman-sj&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!C231!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 424w, https://substackcdn.com/image/fetch/$s_!C231!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 848w, https://substackcdn.com/image/fetch/$s_!C231!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 1272w, https://substackcdn.com/image/fetch/$s_!C231!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.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 role="img" 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><title></title><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>He&#8217;s a Software Engineer at AWS, where he&#8217;s contributed to production services like CloudWatch and EC2. He also conducts system design interviews for engineering candidates.</p><p>Before AWS, he worked at Trainline and BT, building software for over 100 million customers across Europe. He was an AWS Community Builder and served as a coding instructor at Code First Girls in collaboration with Skyscanner.</p><p>He regularly shares free software engineering tips, system design breakdowns, and career advice for engineers breaking into big tech.</p><p>You can connect with Abdirahman here:</p><ul><li><p><strong><a href="http://linkedin.com/in/abdirahman-sj">LinkedIn</a></strong></p></li><li><p><a href="http://instagram.com/abdirahmancodes">Instagram</a></p></li><li><p><strong><a href="https://softwaredevweekly.substack.com/">Newsletter</a></strong></p></li></ul><div><hr></div><h1><strong>Why System Design Interviews Feel Hard</strong></h1><p>In coding interviews, the problem is clear: <em>&#8220;Write a function that does X.&#8221;</em></p><p>You can write the function, add some tests, and confirm whether it works. The feedback loop is immediate and obvious.</p><p>When you&#8217;re building systems at work, you have context.</p><p>You know your users, your constraints, and the internal components you can integrate. Also, you have teammates to bounce ideas off and challenge assumptions. Plus, you have time to assess different options, weigh pros/cons, and make informed decisions. And most importantly, you can use Google.</p><p>System design interviews strip all of that away:</p><p>You&#8217;re given a vague problem like <em>&#8220;Design ChatGPT&#8221;</em> and roughly 30-40 minutes to propose a solution. You can&#8217;t search for anything. Yet somehow you&#8217;re expected to show enough depth and breadth to cover important concepts.</p><p>Now that you understand the challenge, let&#8217;s look at what&#8217;s actually being evaluated. Knowing the scoring criteria changes how you prepare.</p><div><hr></div><h1><strong>What Interviewers Look For (&amp; Mental Model You Need)</strong></h1><p>Here&#8217;s what I learned as an interviewer: we&#8217;re not looking for the &#8220;<em>right answer.</em>&#8221;</p><p>There isn&#8217;t one! We&#8217;re evaluating whether you can think &#8220;systematically&#8221; about ambiguous problems&#8230;</p><p>Here are five dimensions most companies will assess you on:</p><h3><strong>1. Communication and Collaboration</strong></h3><ul><li><p>Do you ask clarifying questions?</p></li><li><p>Do you validate assumptions throughout the interview?</p></li><li><p>Do you treat the interviewer as a partner, or do you just talk at them for 40 minutes straight?</p></li></ul><p>This is crucial as it shows if you&#8217;d be a good teammate.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XN0u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec496a26-9fe9-4692-9ea5-4027a70bc8de_1600x1149.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XN0u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec496a26-9fe9-4692-9ea5-4027a70bc8de_1600x1149.png 424w, https://substackcdn.com/image/fetch/$s_!XN0u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec496a26-9fe9-4692-9ea5-4027a70bc8de_1600x1149.png 848w, https://substackcdn.com/image/fetch/$s_!XN0u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec496a26-9fe9-4692-9ea5-4027a70bc8de_1600x1149.png 1272w, https://substackcdn.com/image/fetch/$s_!XN0u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec496a26-9fe9-4692-9ea5-4027a70bc8de_1600x1149.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XN0u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec496a26-9fe9-4692-9ea5-4027a70bc8de_1600x1149.png" width="1456" height="1046" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ec496a26-9fe9-4692-9ea5-4027a70bc8de_1600x1149.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1046,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!XN0u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec496a26-9fe9-4692-9ea5-4027a70bc8de_1600x1149.png 424w, https://substackcdn.com/image/fetch/$s_!XN0u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec496a26-9fe9-4692-9ea5-4027a70bc8de_1600x1149.png 848w, https://substackcdn.com/image/fetch/$s_!XN0u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec496a26-9fe9-4692-9ea5-4027a70bc8de_1600x1149.png 1272w, https://substackcdn.com/image/fetch/$s_!XN0u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec496a26-9fe9-4692-9ea5-4027a70bc8de_1600x1149.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 role="img" 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><title></title><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>2. Structured Thinking</strong></h3><ul><li><p>Can you break down a vague problem systematically?</p></li><li><p>Do you tackle things logically or jump around between different database choices, caching strategies, and API design?</p></li></ul><p>Strong candidates show how they can organise their thoughts even when the problem is ambiguous.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rOy0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3528d07-b1e6-4960-9ed5-e96854fc9c82_1600x894.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rOy0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3528d07-b1e6-4960-9ed5-e96854fc9c82_1600x894.png 424w, https://substackcdn.com/image/fetch/$s_!rOy0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3528d07-b1e6-4960-9ed5-e96854fc9c82_1600x894.png 848w, https://substackcdn.com/image/fetch/$s_!rOy0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3528d07-b1e6-4960-9ed5-e96854fc9c82_1600x894.png 1272w, https://substackcdn.com/image/fetch/$s_!rOy0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3528d07-b1e6-4960-9ed5-e96854fc9c82_1600x894.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rOy0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3528d07-b1e6-4960-9ed5-e96854fc9c82_1600x894.png" width="1456" height="814" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d3528d07-b1e6-4960-9ed5-e96854fc9c82_1600x894.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:814,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!rOy0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3528d07-b1e6-4960-9ed5-e96854fc9c82_1600x894.png 424w, https://substackcdn.com/image/fetch/$s_!rOy0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3528d07-b1e6-4960-9ed5-e96854fc9c82_1600x894.png 848w, https://substackcdn.com/image/fetch/$s_!rOy0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3528d07-b1e6-4960-9ed5-e96854fc9c82_1600x894.png 1272w, https://substackcdn.com/image/fetch/$s_!rOy0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3528d07-b1e6-4960-9ed5-e96854fc9c82_1600x894.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 role="img" 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><title></title><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>3. Technical Judgment</strong></h3><ul><li><p>When you pick a technology, a database, a cache, or a message queue, can you explain why?</p></li><li><p>Can you walk through the trade-offs? For example, why DynamoDB over PostgreSQL for this specific use case?</p></li></ul><p>This shows you choose tools based on requirements, not habit.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8BbU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facf458dd-c3a0-4a7b-9815-7480574d3a2e_1600x948.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8BbU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facf458dd-c3a0-4a7b-9815-7480574d3a2e_1600x948.png 424w, https://substackcdn.com/image/fetch/$s_!8BbU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facf458dd-c3a0-4a7b-9815-7480574d3a2e_1600x948.png 848w, https://substackcdn.com/image/fetch/$s_!8BbU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facf458dd-c3a0-4a7b-9815-7480574d3a2e_1600x948.png 1272w, https://substackcdn.com/image/fetch/$s_!8BbU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facf458dd-c3a0-4a7b-9815-7480574d3a2e_1600x948.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8BbU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facf458dd-c3a0-4a7b-9815-7480574d3a2e_1600x948.png" width="1456" height="863" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/acf458dd-c3a0-4a7b-9815-7480574d3a2e_1600x948.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:863,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!8BbU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facf458dd-c3a0-4a7b-9815-7480574d3a2e_1600x948.png 424w, https://substackcdn.com/image/fetch/$s_!8BbU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facf458dd-c3a0-4a7b-9815-7480574d3a2e_1600x948.png 848w, https://substackcdn.com/image/fetch/$s_!8BbU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facf458dd-c3a0-4a7b-9815-7480574d3a2e_1600x948.png 1272w, https://substackcdn.com/image/fetch/$s_!8BbU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facf458dd-c3a0-4a7b-9815-7480574d3a2e_1600x948.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 role="img" 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><title></title><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>4. Practical Depth</strong></h3><ul><li><p>Do you think about failure modes, scale, and operations?</p></li><li><p>Or do you only design the happy path?</p></li></ul><p>This is where we spot engineers who&#8217;ve shipped production systems and those who haven&#8217;t. Real systems fail. Databases go down. Networks partition. Strong candidates anticipate and design for this.</p><h3><strong>5. Time Management</strong></h3><ul><li><p>Can you pace yourself to cover breadth and depth in 40 minutes?</p></li><li><p>Do you spend a long period covering a specific area?</p></li></ul><p>It&#8217;s always worth working with your interviewer to understand if there&#8217;s an area of interest for them, or you should propose what you&#8217;ll focus on. Get alignment.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dCqO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2dedc724-326b-4e7d-b25b-7a20d941854f_1600x1093.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dCqO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2dedc724-326b-4e7d-b25b-7a20d941854f_1600x1093.png 424w, https://substackcdn.com/image/fetch/$s_!dCqO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2dedc724-326b-4e7d-b25b-7a20d941854f_1600x1093.png 848w, https://substackcdn.com/image/fetch/$s_!dCqO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2dedc724-326b-4e7d-b25b-7a20d941854f_1600x1093.png 1272w, https://substackcdn.com/image/fetch/$s_!dCqO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2dedc724-326b-4e7d-b25b-7a20d941854f_1600x1093.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dCqO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2dedc724-326b-4e7d-b25b-7a20d941854f_1600x1093.png" width="1456" height="995" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2dedc724-326b-4e7d-b25b-7a20d941854f_1600x1093.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:995,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!dCqO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2dedc724-326b-4e7d-b25b-7a20d941854f_1600x1093.png 424w, https://substackcdn.com/image/fetch/$s_!dCqO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2dedc724-326b-4e7d-b25b-7a20d941854f_1600x1093.png 848w, https://substackcdn.com/image/fetch/$s_!dCqO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2dedc724-326b-4e7d-b25b-7a20d941854f_1600x1093.png 1272w, https://substackcdn.com/image/fetch/$s_!dCqO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2dedc724-326b-4e7d-b25b-7a20d941854f_1600x1093.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 role="img" 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><title></title><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>Between my failed 2021 interview and the ones I passed, the biggest shift was adopting a mental model, a framework that works for any system design problem. This framework keeps people organised and shows how to solve ambiguous problems.</p><p>Let&#8217;s walk through each step&#8230;</p><div><hr></div><h1><strong>Framework: 5 Simple Steps to System Design Interviews</strong></h1><h3><strong>Step 1: Clarify the problem</strong></h3><ul><li><p>Goal: Understand the problem before you design anything.</p></li><li><p>Estimated time: 5 minutes</p></li></ul><p>Start by understanding what&#8217;s in scope and what isn&#8217;t:</p><ul><li><p>Are you focusing on Feature A or Feature B, or both?</p></li><li><p>Are you targeting a specific platform?</p></li><li><p>How many users are you building for?</p></li><li><p>Where are they located?</p></li></ul><p>These aren&#8217;t just theoretical questions&#8230;</p><p>The answers can fundamentally change your design.</p><h4><strong>Functional Requirements (What Are We Building?)</strong></h4><p>Be specific about what your system needs to do:</p><ul><li><p>What are the main use cases?</p></li><li><p>Who are the users?</p></li><li><p>What core features are you building?</p></li><li><p>What are you explicitly leaving out of scope?</p></li></ul><h4><strong>Non-Functional Requirements (What Are the Constraints?)</strong></h4><p>This is where numbers matter:</p><ul><li><p>How many daily and monthly users do you have?</p></li><li><p>How many requests per second?</p></li><li><p>What&#8217;s the read-to-write ratio?</p></li><li><p>What are the latency requirements? Is 200ms acceptable, or do we need sub-100ms?</p></li><li><p>What&#8217;s an acceptable downtime?</p></li></ul><p>These constraints will drive every technical decision you make&#8230;</p><p>A system for 1000 users looks completely different from one serving 200 million daily active users.</p><p>TIP: Check with your interviewer and ask if the scope and requirements make sense.</p><h3><strong>Step 2: Define Core Data &amp; APIs</strong></h3><ul><li><p>Goal: Model what you&#8217;re storing and how clients interact with it.</p></li><li><p>Estimated time: 10 minutes</p></li></ul><h4><strong>Data Model</strong></h4><p>Identify the core entities and their attributes:</p><ul><li><p>What are the main &#8220;things&#8221; in your system? Think about how they relate to each other.</p></li><li><p>Define your primary keys, foreign keys, and the indexes you&#8217;ll need for common queries.</p></li></ul><h4><strong>Data Characteristics</strong></h4><p>Understand the shape of your data:</p><ul><li><p>How big is each record?</p></li><li><p>Is the data append-only or mutable?</p></li><li><p>What&#8217;s the growth rate?</p></li><li><p>How will the data be queried?</p><ul><li><p>Are you doing point lookups by ID or complex joins?</p></li><li><p>Which data needs strong consistency, and what can be eventually consistent?</p></li><li><p>What absolutely cannot be lost?</p></li></ul></li></ul><h4><strong>API Contracts</strong></h4><p>Define your main endpoints with clear request and response formats. Think about pagination strategies, error handling, rate limiting, and versioning.</p><h4><strong>Database Choice</strong></h4><p>Pick a technology and explain why.</p><p>Don&#8217;t just say: &#8220;<em>Use PostgreSQL.</em>&#8221; Justify your choice based on the requirements, discuss alternatives, and explain why you chose one over another.</p><p>TIP: Check again with your interviewer: <em>&#8220;Does this data model and API structure make sense for the requirements?&#8221;</em></p><h3><strong>Step 3: High-Level Architecture</strong></h3><ul><li><p>Goal: Design system components and show how data flows through them.</p></li><li><p>Estimated time: 15 minutes</p></li></ul><p>You should spend most of your interview time here.</p><p>Start by identifying your core components: load balancers, API servers, a cache layer, and queues. Keep this list focused and include only what your design needs.</p><h4><strong>Draw Data Flow</strong></h4><p>Walk through how a request moves through your system.</p><p>From the client, through the load balancer, to the API server, into the cache or database, and back. Do this for both reads and writes.</p><h4><strong>Discuss Asynchronous Workflows Where Appropriate</strong></h4><p>When appropriate, explain why you&#8217;d decouple work into background processing. Also discuss trade-offs: faster responses, but eventual consistency.</p><h4><strong>Caching Strategy</strong></h4><p>Be specific about what you&#8217;re caching, for how long, and how you handle invalidation. Plus, explain the trade-offs between freshness and performance.</p><h4><strong>CAP Theorem Considerations</strong></h4><p>For different parts of your system, choose between consistency, availability, and partition tolerance. Explain why each part of the system may need a different approach.</p><h3><strong>Step 4: Bottlenecks, Scale, and Reliability</strong></h3><ul><li><p>Goal: Show you understand what breaks at scale and how to handle failures.</p></li><li><p>Estimated time: 5 minutes</p></li></ul><p>Don&#8217;t just design the happy path; show you think about failure and scale.</p><h4><strong>Identify Bottlenecks</strong></h4><p>Where will your system struggle under load?</p><p>Name the component, quantify the limit, and propose a mitigation.</p><h4><strong>Single Points of Failure</strong></h4><p>What happens if a component goes down? Identify the risks and explain the mitigation.</p><h4><strong>Failure Modes and Graceful Degradation</strong></h4><ul><li><p>Cache failure: fallback to a slower but functional path</p></li><li><p>Message queue backed up: serve stale data instead of failing requests</p></li><li><p>Network partition: degrade gracefully rather than returning errors</p></li></ul><h4><strong>Redundancy</strong></h4><ul><li><p>Database: multi-AZ replicas for high availability</p></li><li><p>Application servers: auto-scaling across availability zones</p></li><li><p>Cache: distributed cache with replication</p></li></ul><h4><strong>Monitoring, Logging, and Alerting</strong></h4><p>This is my favourite part of the interview. It shows you&#8217;re thinking about operations and observability--one of the clearest signals separating junior from senior engineers.</p><p>You should cover:</p><ul><li><p>API latency at p50, p95, and p99</p></li><li><p>Error rates and thresholds</p></li><li><p>Queue depth and backlog alerts</p></li><li><p>Structured logs with request IDs for distributed tracing</p></li></ul><p>TIP: Ask your interviewer: <em>&#8220;Are there specific failure scenarios you&#8217;d like me to explore further?&#8221;</em></p><h3><strong>Step 5: Tradeoffs and Extensions</strong></h3><ul><li><p>Goal: Summarise key decisions and discuss what you&#8217;d build next.</p></li><li><p>Estimated time: 5 minutes</p></li></ul><p>Wrap up by summarising the key trade-offs you made. What did you prioritise, and what did you sacrifice? Be explicit about the why.</p><p>Then discuss extensions. What would you add if you had more time? This shows you&#8217;re thinking beyond the immediate problem. That&#8217;s the framework.</p><p>Next let&#8217;s see it in action with a real example:</p><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="http://linkedin.com/in/abdirahman-sj" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!C231!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 424w, https://substackcdn.com/image/fetch/$s_!C231!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 848w, https://substackcdn.com/image/fetch/$s_!C231!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 1272w, https://substackcdn.com/image/fetch/$s_!C231!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!C231!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png" width="1456" height="807" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:807,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;http://linkedin.com/in/abdirahman-sj&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!C231!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 424w, https://substackcdn.com/image/fetch/$s_!C231!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 848w, https://substackcdn.com/image/fetch/$s_!C231!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.png 1272w, https://substackcdn.com/image/fetch/$s_!C231!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4724c28-286f-461d-8cb0-82ea2dc5eb64_1570x870.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 role="img" 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><title></title><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>Connect with Abdirahman here:</p><ul><li><p><strong><a href="http://linkedin.com/in/abdirahman-sj">LinkedIn</a></strong></p></li><li><p><a href="http://instagram.com/abdirahmancodes">Instagram</a></p></li><li><p><strong><a href="https://softwaredevweekly.substack.com/">Newsletter</a></strong></p></li></ul><p>He regularly shares free software engineering tips, system design breakdowns, and career advice for engineers breaking into big tech.</p><div><hr></div><p><em>Reminder: this is a teaser of the subscriber-only post, exclusive to my golden members.</em></p><p>When you upgrade, you&#8217;ll get:</p><ul><li><p>Full access to system design case studies</p></li><li><p>FREE access to (coming) Design, Build, Scale newsletter series</p></li><li><p>FREE access to (coming) popular interview question breakdowns</p></li></ul><p>And more!</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p><h4><em><strong>Access the interview example and quick reference framework &#128071;</strong></em></h4>
      <p>
          <a href="https://newsletter.systemdesign.one/p/how-to-prepare-for-system-design-interview">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Context Engineering vs Prompt Engineering]]></title><description><![CDATA[#127: A Developer&#8217;s Guide to Writing Better Prompts and Building Better Context]]></description><link>https://newsletter.systemdesign.one/p/context-engineering-vs-prompt-engineering</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/context-engineering-vs-prompt-engineering</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Tue, 03 Mar 2026 09:33:24 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/b8c31bd3-0a00-44a6-994d-4e8554533bba_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/context-engineering-vs-prompt-engineering/?action=share">Share this post</a> &amp; I&#8217;ll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>You&#8217;ve spent three days crafting the perfect prompt.</p><p>You&#8217;ve added role-playing instructions, sprinkled in a few-shot<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a> examples, and even included that magic phrase everyone swears by, &#8220;<em>Let&#8217;s think step by step</em>&#8221;.</p><p>Your <em>AI travel assistant</em> is ready for production.</p><p>Then your first real user types: <em>&#8220;Book me a hotel in Paris for the DevOps conference.&#8221;</em></p><p>Your agent cheerfully books the Best Western in Paris, Kentucky.</p><p>This isn&#8217;t a prompting failure. It&#8217;s an architecture failure. And if you&#8217;ve been building AI agents in production, you&#8217;ve probably hit this wall where no amount of clever phrasing can make up for missing information.</p><p>The solution isn&#8217;t to write better prompts. It&#8217;s engineering a better context!</p><p>Onward.</p><div><hr></div><h2><strong><a href="https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine">Unblocked: The context layer your AI tools are missing (Partner)</a></strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-9qf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 424w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 848w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 1272w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-9qf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png" width="1200" height="600" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:307185,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/188825279?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!-9qf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 424w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 848w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 1272w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.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 role="img" 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><title></title><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>Give your agents the understanding they need to generate reliable code, reviews, and answers. <strong><a href="https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine">Unblocked</a></strong> builds context from your team&#8217;s code, PR history, conversations, documentation, planning tools, and runtime signals. It surfaces the insights that matter so AI outputs reflect how your system actually works.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine&quot;,&quot;text&quot;:&quot;See How It Works&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine"><span>See How It Works</span></a></p><p>(Thanks, <a href="https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine">Unblocked</a>, for partnering on this post.)</p><div><hr></div><p>I want to introduce <a href="https://www.linkedin.com/in/pvergadia/">Priyanka Vergadia (&#8220;Cloud Girl&#8221;)</a> as the guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://www.linkedin.com/in/pvergadia/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1xqh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc817e61a-7d37-4551-9b30-42e15e19a6f3_1600x480.png 424w, https://substackcdn.com/image/fetch/$s_!1xqh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc817e61a-7d37-4551-9b30-42e15e19a6f3_1600x480.png 848w, https://substackcdn.com/image/fetch/$s_!1xqh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc817e61a-7d37-4551-9b30-42e15e19a6f3_1600x480.png 1272w, https://substackcdn.com/image/fetch/$s_!1xqh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc817e61a-7d37-4551-9b30-42e15e19a6f3_1600x480.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1xqh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc817e61a-7d37-4551-9b30-42e15e19a6f3_1600x480.png" width="1456" height="437" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c817e61a-7d37-4551-9b30-42e15e19a6f3_1600x480.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:437,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://www.linkedin.com/in/pvergadia/&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!1xqh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc817e61a-7d37-4551-9b30-42e15e19a6f3_1600x480.png 424w, https://substackcdn.com/image/fetch/$s_!1xqh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc817e61a-7d37-4551-9b30-42e15e19a6f3_1600x480.png 848w, https://substackcdn.com/image/fetch/$s_!1xqh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc817e61a-7d37-4551-9b30-42e15e19a6f3_1600x480.png 1272w, https://substackcdn.com/image/fetch/$s_!1xqh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc817e61a-7d37-4551-9b30-42e15e19a6f3_1600x480.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 role="img" 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><title></title><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>She is a cloud and AI expert who has worked at two of the hyperscalers: Google and Microsoft. Check out her newsletter and social media:</p><ul><li><p><a href="https://www.thecloudgirl.dev/subscribe-to-cloud-girl-bytes">Cloud Girl Bytes (newsletter)</a></p></li><li><p><a href="https://www.linkedin.com/in/pvergadia/">LinkedIn</a></p></li><li><p><a href="https://x.com/pvergadia">Twitter</a></p></li><li><p><a href="https://www.youtube.com/@pvergadia">YouTube</a></p></li><li><p><a href="https://www.thecloudgirl.dev/">Website</a></p></li><li><p><a href="https://www.instagram.com/pvergadia/">Instagram</a></p></li></ul><p>It&#8217;ll help you quickly master cloud and AI.</p><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!T4MM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!T4MM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!T4MM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!T4MM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!T4MM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!T4MM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.png" width="1080" height="1080" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1080,&quot;width&quot;:1080,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1439234,&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://newsletter.systemdesign.one/i/188715439?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!T4MM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!T4MM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!T4MM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!T4MM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1d0d5d4-14ab-4044-a3a1-a857fcf665d5_1080x1080.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 role="img" 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><title></title><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 newsletter will walk you through the shift from <strong>Prompt Engineering</strong> (optimizing what you write) to <strong>Context Engineering</strong> (architecting what the model receives).</p><p>By the end, you&#8217;ll understand why this distinction matters and how to implement it in your own systems. But first, let&#8217;s make sure we&#8217;re speaking the same language&#8230;</p><div><hr></div><h2><strong>Key Concepts: A Quick Primer</strong></h2><p>Whether you&#8217;re just getting started with AI development or looking for a refresher, here are the foundational terms we&#8217;ll use throughout this post:</p><p><strong>LLM (Large Language Model)</strong></p><p>Think of this as the &#8220;brain&#8221; of your AI application.</p><p>Models like GPT-4, Claude, or Llama<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a> are trained on massive amounts of text to understand and generate human-like language. They don&#8217;t &#8220;know&#8221; things the way you do&#8212;they &#8220;predict&#8221; what text should come next based on patterns they&#8217;ve learned.</p><p><strong>Prompt</strong></p><p>The instructions or text you send to an LLM.</p><p>If the LLM is an actor, the prompt is the script you hand them. A prompt might be as simple as &#8220;<em>Summarize this email</em>&#8221; or as complex as a multi-paragraph system message with examples and constraints.</p><p><strong>Context</strong></p><p>All the information the LLM has access to when generating a response.</p><p>This includes your prompt, as well as any additional data you provide: conversation history, retrieved documents, user profiles, tool outputs, and more. Context is everything in the model&#8217;s &#8220;working memory&#8221; at the moment of inference.</p><p><strong>Context Window</strong></p><p>The maximum amount of text (measured in &#8220;tokens&#8221;&#8212;roughly 3/4 of a word) that an LLM can process at once.</p><p>Think of it as the model&#8217;s short-term memory capacity. GPT-4 Turbo has a 128K token window; Claude 3 offers up to 200K. Anything beyond this limit simply won&#8217;t be seen by the model.</p><p><strong>Inference</strong></p><p>The moment when the model actually generates a response.</p><p>Everything you send&#8212;prompts, context, conversation history&#8212;gets processed at inference time. It&#8217;s the &#8220;go&#8221; moment.</p><p><strong>RAG (Retrieval-Augmented Generation)</strong></p><p>A technique where you fetch relevant documents or data from an external source (like a database or search engine) and inject them into the context before inference. This gives the LLM access to information it wasn&#8217;t trained on&#8212;like your company&#8217;s travel policy or today&#8217;s flight prices.</p><p><strong>Agent</strong></p><p>An AI system that can take actions, not just generate text.</p><p>Agents typically operate in loops: they reason about a task, call tools<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a> (such as APIs or databases), observe the results, and iterate until the task is complete. Your travel booking assistant is an agent.</p><p><strong>Hallucination</strong></p><p>When an LLM confidently generates information that isn&#8217;t true.</p><p>Without proper context, models fill in gaps with plausible-sounding but incorrect details&#8212;like assuming &#8220;Paris&#8221; means Kentucky when the user clearly meant France.</p><p>With these concepts in hand, let&#8217;s explore why traditional prompt engineering often falls short&#8212;and what to do instead.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!h3gr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83ae996b-af30-4472-8715-5a5298bde70e_893x1600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!h3gr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83ae996b-af30-4472-8715-5a5298bde70e_893x1600.png 424w, https://substackcdn.com/image/fetch/$s_!h3gr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83ae996b-af30-4472-8715-5a5298bde70e_893x1600.png 848w, https://substackcdn.com/image/fetch/$s_!h3gr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83ae996b-af30-4472-8715-5a5298bde70e_893x1600.png 1272w, https://substackcdn.com/image/fetch/$s_!h3gr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83ae996b-af30-4472-8715-5a5298bde70e_893x1600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!h3gr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83ae996b-af30-4472-8715-5a5298bde70e_893x1600.png" width="893" height="1600" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/83ae996b-af30-4472-8715-5a5298bde70e_893x1600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1600,&quot;width&quot;:893,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!h3gr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83ae996b-af30-4472-8715-5a5298bde70e_893x1600.png 424w, https://substackcdn.com/image/fetch/$s_!h3gr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83ae996b-af30-4472-8715-5a5298bde70e_893x1600.png 848w, https://substackcdn.com/image/fetch/$s_!h3gr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83ae996b-af30-4472-8715-5a5298bde70e_893x1600.png 1272w, https://substackcdn.com/image/fetch/$s_!h3gr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83ae996b-af30-4472-8715-5a5298bde70e_893x1600.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 role="img" 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><title></title><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><h2><strong>1. The Micro-Optimization: Prompt Engineering</strong></h2><p><em>The &#8220;Static Script&#8221;.</em></p><p>If you&#8217;ve been working with LLMs, you already know Prompt Engineering. It&#8217;s the craft of writing effective instructions for a model, and for the past two years, it&#8217;s been the primary way developers have tried to improve AI output.</p><p>Think of an LLM as a talented improv actor:</p><p><strong>Prompt Engineering</strong> is the script you hand them before the curtain rises. It defines their character, the scene's tone, and the rules of engagement. A good script can make a significant difference in performance.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_Cxe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44c988f-a748-49b5-892d-326d19d4d774_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_Cxe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44c988f-a748-49b5-892d-326d19d4d774_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!_Cxe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44c988f-a748-49b5-892d-326d19d4d774_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!_Cxe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44c988f-a748-49b5-892d-326d19d4d774_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!_Cxe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44c988f-a748-49b5-892d-326d19d4d774_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_Cxe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44c988f-a748-49b5-892d-326d19d4d774_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b44c988f-a748-49b5-892d-326d19d4d774_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;:89946,&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://newsletter.systemdesign.one/i/188715439?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44c988f-a748-49b5-892d-326d19d4d774_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_Cxe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44c988f-a748-49b5-892d-326d19d4d774_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!_Cxe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44c988f-a748-49b5-892d-326d19d4d774_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!_Cxe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44c988f-a748-49b5-892d-326d19d4d774_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!_Cxe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44c988f-a748-49b5-892d-326d19d4d774_1200x630.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 role="img" 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><title></title><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 standard developer toolkit for prompt engineering includes:</p><ul><li><p><strong>Role Assignment </strong>&#8211; Setting the persona with instructions like <em>&#8220;You are an expert travel agent.&#8221;</em> This primes the model to use vocabulary and behaviors associated with that role.</p></li><li><p><strong>Few-Shot Examples</strong> &#8211; Providing input/output pairs demonstrating the exact format you want. For example, showing the model three examples of properly formatted JSON responses before asking it to generate one.</p></li><li><p><strong>Chain of Thought (CoT)</strong> &#8211; Instructions like <em>&#8220;Let&#8217;s think step by step&#8221;</em> that encourage the model to show its reasoning. This dramatically reduces errors in logic and math problems by forcing the model to &#8220;work through&#8221; the problem rather than jumping to an answer.</p></li><li><p><strong>Constraint Setting </strong>&#8211; Hard limits on output, like <em>&#8220;Limit your response to 50 words,</em>&#8221; or <em>&#8220;Respond only with valid JSON.&#8221;</em></p></li></ul><p>These techniques are valuable and worth mastering.</p><p>But they share a fundamental limitation that becomes apparent when you move from demos to production.</p><h3><strong>The &#8220;Paris, Kentucky&#8221; Failure</strong></h3><p>The limitation of Prompt Engineering is that it is <strong>static</strong>.</p><p>Let&#8217;s return to our travel agent. The user says: <em>&#8220;Book me a hotel in Paris for the DevOps conference.&#8221;</em></p><p>An agent relying only on prompt engineering sees the words &#8220;Paris&#8221; and &#8220;DevOps.&#8221; It has no access to external data, so it does what LLMs do when they lack information: it makes a <em>probabilistic guess</em>. There&#8217;s a Paris in France, sure, but there&#8217;s also a Paris in Kentucky, Texas, Tennessee, and several other states. Without additional context, the model has no way of knowing which one you mean.</p><p>The result?</p><p>Your user gets booked into the Best Western in Paris, Kentucky.</p><p>No amount of clever prompt phrasing can fix this. You could write <em>&#8220;Always book hotels in major international cities&#8221;</em>&#8212;but what about the user who actually wants Paris, Texas? The problem isn&#8217;t the prompt. The problem is that the model lacks three critical pieces of information:</p><ol><li><p>User lives in London (suggesting international travel is more likely)</p></li><li><p>DevOps conference this year is actually in Paris, France</p></li><li><p>The user&#8217;s company policy requires booking Marriott properties under &#8364;200/night</p></li></ol><p>This is where the paradigm shifts.</p><p>We need to move from optimizing static scripts to dynamically assembling the right information at runtime. We need Context Engineering.</p><div><hr></div><h2><strong>2. The Macro-Architecture: Context Engineering</strong></h2><p><em>The &#8220;Dynamic Set Design&#8221;.</em></p><p>If Prompt Engineering is handing a script to your improv actor, Context Engineering is building the entire stage, providing the props, dressing the set, and handing them a dossier about their scene partners&#8212;all before they speak a single line.</p><p>Context Engineering is the <strong>programmatic assembly </strong>of the &#8220;Context Package&#8221;&#8212;the exact bundle of tokens sent to the LLM at inference<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a> time. It&#8217;s not about writing a better sentence; it&#8217;s about building an Orchestrator Loop that fetches the right information from multiple sources before the model ever generates a response.</p><p>This is a systems engineering challenge, involving data pipelines<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-5" href="#footnote-5" target="_self">5</a>, vector databases<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-6" href="#footnote-6" target="_self">6</a>, state machines, and API integrations.</p><p>The traditional flow looks like this:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;e1eaa8af-1041-4d98-b225-4ac256d001eb&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">User Input &#8594; LLM</code></pre></div><p>The context-engineered flow looks like this:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;69ff3dfe-051d-42f8-8cdb-d97defbfa6c8&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">User Input &#8594; [Memory + RAG + State + Tools] &#8594; Assembled Context &#8594; LLM</code></pre></div><p>Let&#8217;s break down each component of this architecture.</p><div><hr></div><h2><strong>The Four Pillars of Context Engineering</strong></h2><h4><strong>1. Memory Management (The Brain)</strong></h4><p>Here&#8217;s a <em>naive</em> approach that doesn&#8217;t scale: dump the entire conversation history into the context window every time.</p><p>With a 128K token context window and $10/million tokens, this gets expensive fast&#8212;and it significantly slows response time (a metric called Time to First Token, or <strong>TTFT</strong>).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yRAZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yRAZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.png 424w, https://substackcdn.com/image/fetch/$s_!yRAZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.png 848w, https://substackcdn.com/image/fetch/$s_!yRAZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.png 1272w, https://substackcdn.com/image/fetch/$s_!yRAZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yRAZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.png" width="1456" height="420" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:420,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:101111,&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://newsletter.systemdesign.one/i/188715439?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!yRAZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.png 424w, https://substackcdn.com/image/fetch/$s_!yRAZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.png 848w, https://substackcdn.com/image/fetch/$s_!yRAZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.png 1272w, https://substackcdn.com/image/fetch/$s_!yRAZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3322f7f8-265f-4f89-82ed-efaf208750b3_1783x514.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 role="img" 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><title></title><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>Smart memory management means being strategic about what you include:</p><p><em><strong>Short-term memory</strong></em></p><p>A rolling window of the last N conversations is used to maintain immediate context. The user said,&nbsp;<em>&#8220;Actually, make it a window seat&#8221;.</em>&nbsp;The model needs to remember they were just discussing flight preferences.</p><p><em><strong>Long-term memory</strong></em></p><p>Persistent facts about the user, retrieved semantically. Instead of storing every conversation verbatim, you extract and index key facts: &#8220;User location: London&#8221;, &#8220;Seating preference: Aisle.&#8221; At inference time, you query this memory store to retrieve only what&#8217;s relevant to the current task.</p><p><em><strong>Travel Agent Example:</strong></em></p><p>When the user asks about booking a hotel, the system retrieves &#8220;User: London-based&#8221; and &#8220;Preference: Aisle seat&#8221; from long-term memory, while keeping the last 3 conversation turns in short-term memory.</p><h4><strong>2. RAG (Retrieval Augmented Generation)</strong></h4><p>RAG is your connection to &#8220;ground truth&#8221;&#8212;information that exists outside the model&#8217;s training data. This might be company policies, product documentation, real-time pricing, or any other external data source.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rKIs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rKIs!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png 424w, https://substackcdn.com/image/fetch/$s_!rKIs!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png 848w, https://substackcdn.com/image/fetch/$s_!rKIs!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png 1272w, https://substackcdn.com/image/fetch/$s_!rKIs!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rKIs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png" width="1456" height="347" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:347,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:112283,&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://newsletter.systemdesign.one/i/188715439?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rKIs!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png 424w, https://substackcdn.com/image/fetch/$s_!rKIs!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png 848w, https://substackcdn.com/image/fetch/$s_!rKIs!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png 1272w, https://substackcdn.com/image/fetch/$s_!rKIs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bb84819-7808-4a51-9f8e-a9eedd2620b6_2149x512.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>A robust RAG implementation typically combines:</p><p><em><strong>Hybrid Search</strong></em></p><p>Combining traditional keyword search (BM25)<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-7" href="#footnote-7" target="_self">7</a> with semantic vector search<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-8" href="#footnote-8" target="_self">8</a>. Keyword search catches exact matches (&#8220;policy ID 998&#8221;); semantic search catches conceptual matches (&#8220;rules about hotel spending&#8221;).</p><p><em><strong>Smart Filtering</strong></em></p><p>You don&#8217;t want to retrieve the entire company handbook&#8212;that would blow your token budget. The context engine must extract only the relevant chunks, ranked by relevance to the current query.</p><p><em><strong>Travel Agent Example:</strong></em></p><p>When the user mentions booking a hotel, the retrieval system queries the corporate travel policy database and pulls the specific snippet: &#8220;Max Hotel Spend: &#8364;200/night, Approved Chains: Marriott, Hilton.&#8221; This grounds the agent&#8217;s booking decisions in the company's actual rules.</p><h4><strong>3. State Management (The Workflow)</strong></h4><p>Unlike simple chatbots, agents are <strong>stateful</strong>&#8212;they operate within multi-step workflows where sequence matters.</p><p>You can&#8217;t book a hotel before you&#8217;ve searched for options. You can&#8217;t confirm a reservation until the user approves the price.</p><p>The LLM needs to know where it is in this business process. State management includes:</p><p><em><strong>Workflow Tracking</strong></em></p><p>What phase are we in? Discovery, Search, Selection, Booking, Confirmation?</p><p><em><strong>Progress Indicators</strong></em></p><p>What constraints have already been satisfied? What&#8217;s still needed?</p><p><em><strong>Travel Agent Example:</strong></em></p><p>The system injects a state object like:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;json&quot;,&quot;nodeId&quot;:&quot;15ff388d-42c7-4200-b627-f1460f02be91&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-json">{
  "Phase": "Booking",
  "Status": "Searching",
  "Constraints_Met": ["dates", "location"],
  "Constraints_Pending": ["user_approval", "payment"]
}</code></pre></div><p>This prevents the agent from accidentally jumping ahead to book before search results are reviewed.</p><h4><strong>4. Tool Access (The Hands)</strong></h4><p>The LLM is a reasoning engine, not a database.</p><p>It can&#8217;t check flight prices, look up conference locations, or execute bookings on its own. We must give it &#8220;hands&#8221;&#8212;well-defined interfaces (APIs) it can call.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MBjJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MBjJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png 424w, https://substackcdn.com/image/fetch/$s_!MBjJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png 848w, https://substackcdn.com/image/fetch/$s_!MBjJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png 1272w, https://substackcdn.com/image/fetch/$s_!MBjJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MBjJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png" width="1456" height="199" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:199,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:51753,&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://newsletter.systemdesign.one/i/188715439?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MBjJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png 424w, https://substackcdn.com/image/fetch/$s_!MBjJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png 848w, https://substackcdn.com/image/fetch/$s_!MBjJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png 1272w, https://substackcdn.com/image/fetch/$s_!MBjJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2539484-d60a-4cf3-a49b-fd5639f3ccd2_1680x230.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Tool integration involves:</p><p><em><strong>Function Schemas</strong></em></p><p>JSON definitions of available tools.</p><p>For example:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;2ce545a3-0c7a-4afa-b29e-233b2fa28dc7&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">search_conference_details(name: string),
search_hotels(location: string, check_in: date, max_price: number),
execute_booking(hotel_id: string)</code></pre></div><p>The model learns what tools exist and what parameters they accept.</p><p><em><strong>Orchestrator Execution</strong></em></p><p>When the model decides to call a tool, it outputs a structured request.</p><p>The Orchestrator intercepts this request, executes the actual code, and returns the result to the context for the next inference step.</p><p><em><strong>Handling Failures</strong></em></p><p>Tools don&#8217;t always work perfectly. A robust context engine must handle failure scenarios gracefully:</p><p><em>Timeouts:</em></p><p>If a tool call takes too long (e.g., an API doesn&#8217;t respond), the system might retry with exponential backoff, try an alternative tool, or inform the user of the delay.</p><p><em>Errors:</em></p><p>If a tool returns an error (e.g., &#8220;No hotels found matching criteria&#8221;), the agent should recognize this and either adjust parameters or ask the user for clarification.</p><p><em>Ambiguous Results:</em></p><p>If a tool returns unclear or partial data, the agent might call additional tools to verify, request human confirmation, or explicitly note the uncertainty to the user before proceeding.</p><p><em><strong>Travel Agent Example:</strong></em></p><p>The agent calls:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;69844d5c-2d67-42c1-9111-3afa50d84781&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">search_conference_details(&#8221;DevOps Conference&#8221;)</code></pre></div><p>&#8230;and receives:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;9a032ee7-5c89-4983-a490-652022c381f4&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">{ &#8220;Location&#8221;: &#8220;Paris, France&#8221;, &#8220;Dates&#8221;: &#8220;Oct 12-15&#8221; }</code></pre></div><p>Now it knows exactly which Paris the user means. If this API times out, the system retries twice, then asks the user: <em>&#8220;I&#8217;m having trouble looking up the conference details. Can you confirm the location?&#8221;</em></p><div><hr></div><h2><strong>When Context Exceeds Capacity: Prioritization</strong></h2><p>Even with large context windows, you&#8217;ll often have more relevant information than you can fit. When the assembled context exceeds your token budget, the system must prioritize.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iSCe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59bb33ad-8158-4b96-a84b-48ac03b49295_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iSCe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59bb33ad-8158-4b96-a84b-48ac03b49295_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!iSCe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59bb33ad-8158-4b96-a84b-48ac03b49295_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!iSCe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59bb33ad-8158-4b96-a84b-48ac03b49295_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!iSCe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59bb33ad-8158-4b96-a84b-48ac03b49295_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iSCe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59bb33ad-8158-4b96-a84b-48ac03b49295_1200x630.png" width="646" height="339.15" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/59bb33ad-8158-4b96-a84b-48ac03b49295_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;:646,&quot;bytes&quot;:44085,&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://newsletter.systemdesign.one/i/188715439?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59bb33ad-8158-4b96-a84b-48ac03b49295_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iSCe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59bb33ad-8158-4b96-a84b-48ac03b49295_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!iSCe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59bb33ad-8158-4b96-a84b-48ac03b49295_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!iSCe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59bb33ad-8158-4b96-a84b-48ac03b49295_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!iSCe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59bb33ad-8158-4b96-a84b-48ac03b49295_1200x630.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 role="img" 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><title></title><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>Here&#8217;s a typical priority hierarchy:</p><p><strong>1. System Instructions </strong>(always included) &#8211; The core behavioral rules and role definition never get cut.</p><p><strong>2. Current State </strong>(highest priority) &#8211; Where are we in the workflow? This prevents the agent from taking nonsensical actions.</p><p><strong>3. Active Tool Outputs </strong>(high priority) &#8211; Results from the most recent tool calls are essential for the current reasoning step.</p><p><strong>4. Retrieved Policies/Documents </strong>(high priority) &#8211; Compliance rules and ground truth data that constrain valid actions.</p><p><strong>5. User Profile/Long-term Memory </strong>(medium priority) &#8211; Persistent facts about the user that improve personalization.</p><p><strong>6. Conversation History </strong>(lower priority) &#8211; Earlier turns can be summarized or dropped when space is tight. Keep the most recent turns intact.</p><p><strong>7. Few-shot Examples </strong>(lowest priority) &#8211; These can often be reduced or removed once the model is performing well on the task.</p><p>Think of it this way: if your agent forgets a few-shot example, the output format might drift slightly. If it forgets a compliance policy, it might book an unauthorized hotel. If it forgets its current state, it might try to book a hotel that doesn&#8217;t exist.</p><p>Prioritize accordingly.</p><div><hr></div><h2><strong>3. The Solution: &#8220;Runtime Prompt&#8221;</strong></h2><p>When you move from Prompt Engineering to Context Engineering, the actual text sent to the model (<strong>Runtime Prompt</strong>) is dynamically generated.</p><p>Here is what the &#8220;Real&#8221; System Architecture sends to the LLM for <em>Travel AI Agent Example</em>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;25306f6e-5db9-426e-aa5e-d88bc82aad60&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">*** SYSTEM INSTRUCTIONS ***

You are an Expert Travel Agent.
Review the memory, policy, and state below before answering.


*** STATE ***

Phase: Booking
Status: Searching


*** MEMORY &amp; USER PROFILE ***

- User Location: London, UK
- Preference: Aisle seats
- History: Prefers Europe for conferences


*** RAG / RETRIEVED POLICY ***

- Corporate Policy ID: 998
- Max Hotel Spend: &#8364;200
- Approved Chains: Marriott, Hilton


*** TOOL OUTPUTS ***

&gt; search_conference_details(&#8221;DevOps Conference&#8221;)
  Result: &#8220;Location: Paris, France. Dates: Oct 12-15&#8221;


*** USER INPUT ***

&#8220;Book me a hotel in Paris for the DevOps conference.&#8221;</code></pre></div><h3><strong>The Result</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iAks!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iAks!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!iAks!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!iAks!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!iAks!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iAks!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif" width="420" height="220.5" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1200,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:236467,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/188715439?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iAks!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!iAks!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!iAks!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!iAks!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5386434a-13e9-4481-b5c6-7b0e7f793aec_1200x630.gif 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Because the context was engineered before inference, the model now has everything it needs to make a correct decision:</p><ul><li><p>Disambiguation: The tool output explicitly clarifies &#8220;Paris, France.&#8221; No ambiguity remains.</p></li><li><p>Compliance: The RAG retrieval enforces the &#8364;200/night limit and approved hotel chains. The agent won&#8217;t even consider the &#8364;400/night boutique hotel.</p></li><li><p>Reasoning: With all constraints visible, the LLM selects the Paris Marriott Champs-&#201;lys&#233;es (&#8364;190/night) instead of making a blind guess.</p></li></ul><p>This is the power of Context Engineering: transforming the LLM from a probabilistic text generator into a reliable reasoning engine constrained by real-world data.</p><div><hr></div><h2>Understanding the Tradeoffs</h2><p>More context isn&#8217;t free. As you implement these systems, be mindful of the costs:</p><p><strong>Token Costs: </strong>Each additional token you send to the model costs money. At $10 per million input tokens, a 10K token context package processed 100,000 times costs $10,000. The prioritization hierarchy discussed earlier becomes essential at scale.</p><p><strong>Latency: </strong>Larger context windows increase Time to First Token (TTFT). Users waiting 3+ seconds for a response may disengage. You&#8217;ll need to balance comprehensiveness with responsiveness.</p><p><strong>System Complexity:</strong> Memory stores, RAG pipelines, state machines, and tool integrations all require maintenance, monitoring, and debugging. Every component is a potential point of failure.</p><p><strong>Retrieval Quality:</strong> Bad retrieval is worse than no retrieval. If your RAG system surfaces irrelevant documents, you&#8217;re paying token costs to confuse the model. Invest in retrieval quality metrics and continuous improvement.</p><p><strong>The right approach is iterative: </strong>start with the minimum viable context, measure what&#8217;s missing when failures occur, and expand strategically.</p><div><hr></div><h2><strong>Closing Thoughts</strong></h2><p>Context Engineering represents a fundamental shift in how we build AI applications.</p><p>It moves us from treating LLMs as chatbots that need cleverer instructions to treating them as reasoning engines that need better inputs.</p><p>The investment is real, but the payoff is production-grade reliability that prompt tweaking alone can never achieve.</p><div><hr></div><p>&#128075; I&#8217;d like to thank <strong><a href="https://www.linkedin.com/in/pvergadia/">Priyanka</a></strong> for writing this newsletter!</p><p>Also subscribe to her newsletter, <a href="https://www.thecloudgirl.dev/subscribe-to-cloud-girl-bytes">Cloud Girl Bytes</a>, and follow her on <a href="https://www.linkedin.com/in/pvergadia/">LinkedIn</a>, <a href="https://x.com/pvergadia">Twitter</a>, <a href="https://www.youtube.com/@pvergadia">YouTube</a>, or the social network of your choice. It&#8217;ll help you quickly master cloud and AI.</p><div><hr></div><p>I launched <strong>Design, Build, Scale</strong> (newsletter series exclusive to PAID subscribers).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://newsletter.systemdesign.one/subscribe?yearly=true" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jG0C!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jG0C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/63fca468-adce-4713-97a0-203c35bc1c60_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;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:null,&quot;href&quot;:&quot;https://newsletter.systemdesign.one/subscribe?yearly=true&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/179076610?img=https%3A%2F%2Fsubstackcdn.com%2Fimage%2Ffetch%2F%24s_%21jG0C%21%2Cf_auto%2Cq_auto%3Agood%2Cfl_progressive%3Asteep%2Fhttps%253A%252F%252Fsubstack-post-media.s3.amazonaws.com%252Fpublic%252Fimages%252F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!jG0C!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.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 role="img" 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><title></title><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>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>High-level architecture of real-world systems.</strong></p></li><li><p>Deep dive into how popular real-world systems actually work.</p></li><li><p><strong>How real-world systems handle scale, reliability, and performance.</strong></p></li><li><p>10x the results you currently get with 1/10th of your time, energy, and effort.</p></li></ul><p><strong>&#128073; <a href="https://newsletter.systemdesign.one/subscribe?yearly=true">CLICK HERE TO ACCESS DESIGN, BUILD, SCALE!</a></strong></p><div><hr></div><p>If you find this newsletter valuable, share it with a friend, and subscribe if you haven&#8217;t already. There are <a href="http://newsletter.systemdesign.one/subscribe?group=true">group discounts</a>, <a href="http://newsletter.systemdesign.one/subscribe?gift=true">gift options</a>, and <a href="https://newsletter.systemdesign.one/leaderboard">referral rewards</a> available.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://www.linkedin.com/in/nk-systemdesign-one/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png" width="152" height="152" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:320,&quot;width&quot;:320,&quot;resizeWidth&quot;:152,&quot;bytes&quot;:74009,&quot;alt&quot;:&quot;Author Neo Kim; System design case studies&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://www.linkedin.com/in/nk-systemdesign-one/&quot;,&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="Author Neo Kim; System design case studies" title="Author Neo Kim; System design case studies" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption"><strong>&#128075; Find me on <a href="https://www.linkedin.com/in/nk-systemdesign-one/">LinkedIn</a> | <a href="https://x.com/intent/follow?screen_name=systemdesignone">Twitter</a> | <a href="https://www.threads.net/@systemdesignone">Threads</a> | <a href="https://www.instagram.com/systemdesignone/">Instagram</a></strong></figcaption></figure></div><div><hr></div><p>Thank you for supporting this newsletter.</p><p>You are now 210,001+ readers strong, very close to 210k. Let&#8217;s try to get 211k readers by 7 March. Consider sharing this post with your friends and get rewards.</p><p>Y&#8217;all are the best.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6oWl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" width="590" height="368.75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:800,&quot;resizeWidth&quot;:590,&quot;bytes&quot;:87878,&quot;alt&quot;:&quot;system design newsletter&quot;,&quot;title&quot;:&quot;system design newsletter&quot;,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/163380418?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="system design newsletter" title="system design newsletter" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.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 role="img" 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><title></title><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 class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/context-engineering-vs-prompt-engineering?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/context-engineering-vs-prompt-engineering?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><ul><li><p><em>Block diagrams created using <a href="https://app.eraser.io/auth/sign-up?ref=neo">Eraser</a>.</em></p></li></ul><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p>Few-shot prompting is a technique where a model is given a small number of input-output examples within the prompt to guide its responses.</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p>Llama is used for more control, customization, or data privacy compared to closed API-only models</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-3" href="#footnote-anchor-3" class="footnote-number" contenteditable="false" target="_self">3</a><div class="footnote-content"><p>A tool is an external function or API that an AI model can call to retrieve real-world data or perform actions beyond generating text.</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-4" href="#footnote-anchor-4" class="footnote-number" contenteditable="false" target="_self">4</a><div class="footnote-content"><p>Inference time is the moment when the model receives your prompt and generates a response.</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-5" href="#footnote-anchor-5" class="footnote-number" contenteditable="false" target="_self">5</a><div class="footnote-content"><p>Data pipelines are automated workflows that ingest, transform, and route data from source systems to destinations for storage or analysis.</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-6" href="#footnote-anchor-6" class="footnote-number" contenteditable="false" target="_self">6</a><div class="footnote-content"><p>Vector databases are specialized storage systems designed to index and query high-dimensional embeddings for fast similarity search.</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-7" href="#footnote-anchor-7" class="footnote-number" contenteditable="false" target="_self">7</a><div class="footnote-content"><p>BM25 (best matching) is a ranking function used by search engines to estimate the relevance of documents to a search query.</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-8" href="#footnote-anchor-8" class="footnote-number" contenteditable="false" target="_self">8</a><div class="footnote-content"><p>Semantic vector search is a method of finding information by comparing the meanings of text using numerical embeddings (vectors) rather than matching exact keywords.</p><p></p></div></div>]]></content:encoded></item><item><title><![CDATA[A Crash Course on High Availability]]></title><description><![CDATA[#126: What Is High Availability]]></description><link>https://newsletter.systemdesign.one/p/what-is-high-availability</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/what-is-high-availability</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Sat, 28 Feb 2026 12:57:09 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/3dcd543a-ebea-4765-a859-d4bae681e495_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/what-is-high-availability/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li><li><p><em>Block diagrams created using <a href="https://app.eraser.io/auth/sign-up?ref=neo">Eraser</a>.</em></p></li></ul><div><hr></div><p>Why should we care about uptime? And what exactly is high availability?</p><p>Downtime is expensive&#8230;</p><p>A payment system that goes down during peak shopping hours bleeds revenue. A hospital record system that crashes mid-shift puts patients at risk. An app going offline for ten minutes triggers trending hashtags from angry users.</p><p>Downtime is never abstract&#8230;</p><p>It translates into lost money, lost trust, and sometimes even legal penalties. Some of it can never be recovered. High availability started long before the cloud. In the 1960s, defense and finance systems had to run nonstop. Those engineers designed machines that could keep working even when parts failed. When the internet arrived, that same discipline moved online. Banks, retailers, and payment networks learned that a brief outage can erase months of profit.</p><p>With the widespread use of technology, the expectation of &#8220;always on&#8221; has never been greater. Now, uptime is not a luxury but a baseline.</p><p>The goal never changed: build systems that keep running when the world shakes.</p><p>So failures will happen. No matter how hard we try, we can&#8217;t avoid them. Hardware burns out, networks drop packets, software engineers create bugs. High availability (<strong>HA</strong>) is about absorbing those failures behind the scenes&#8230;it&#8217;s about the service being available regardless of failures.</p><p>People don&#8217;t think about their car tires until one goes flat.</p><p>High availability is having a spare one in the trunk. After we replace them, we can drive again. We can&#8217;t always control why the tire got flat, but we can carry a spare one. This is the core idea of high availability.</p><p>Now let&#8217;s put some numbers to it.</p><p>Onward.</p><div><hr></div><h2><a href="https://orchidsapp.link/neokim">The best way to build any app (Partner)</a></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://orchidsapp.link/neokim" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!td_i!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F676ee402-cd35-46bd-b6a7-dee96527e3d1_1600x900.png 424w, https://substackcdn.com/image/fetch/$s_!td_i!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F676ee402-cd35-46bd-b6a7-dee96527e3d1_1600x900.png 848w, https://substackcdn.com/image/fetch/$s_!td_i!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F676ee402-cd35-46bd-b6a7-dee96527e3d1_1600x900.png 1272w, https://substackcdn.com/image/fetch/$s_!td_i!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F676ee402-cd35-46bd-b6a7-dee96527e3d1_1600x900.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!td_i!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F676ee402-cd35-46bd-b6a7-dee96527e3d1_1600x900.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/676ee402-cd35-46bd-b6a7-dee96527e3d1_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;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://orchidsapp.link/neokim&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!td_i!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F676ee402-cd35-46bd-b6a7-dee96527e3d1_1600x900.png 424w, https://substackcdn.com/image/fetch/$s_!td_i!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F676ee402-cd35-46bd-b6a7-dee96527e3d1_1600x900.png 848w, https://substackcdn.com/image/fetch/$s_!td_i!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F676ee402-cd35-46bd-b6a7-dee96527e3d1_1600x900.png 1272w, https://substackcdn.com/image/fetch/$s_!td_i!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F676ee402-cd35-46bd-b6a7-dee96527e3d1_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 role="img" 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><title></title><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>Treat your app like an Orchid: A beautiful flower that needs sunlight and a bit of water &#127800;</p><p>Most &#8220;AI builders&#8221; make you grow your app in their pot. Same stack. Same limits. Same rules. And on their databases.</p><p><a href="https://orchidsapp.link/neokim">Orchids</a> is different:</p><ul><li><p>It&#8217;s your build space, set up your way.</p></li><li><p>Build anything, Web app, mobile app, Slack bot, Chrome extension, Python script, whatever.</p></li><li><p>Bring your own AI subscriptions so you&#8217;re not paying twice.</p></li><li><p>Plug in the database you already use and trust.</p></li><li><p>Use any payment infra you want.</p></li></ul><p>Try <strong><a href="https://orchidsapp.link/neokim">Orchids.app</a></strong> and build it the way you were meant to:</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://orchidsapp.link/neokim&quot;,&quot;text&quot;:&quot;Get Started Today&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://orchidsapp.link/neokim"><span>Get Started Today</span></a></p><p>(Thanks, <a href="https://orchidsapp.link/neokim">Orchids</a>, for partnering on this post.)</p><p><strong>Use this discount code to get a one time 15% off during checkout: MARCH15</strong></p><div><hr></div><h1>Fundamentals</h1><p>HA means keeping a system running even when parts of it fail.</p><p>The higher the availability, the less impact each individual failure has. To manage HA, engineers use <strong><a href="https://www.pagerduty.com/resources/digital-operations/learn/what-is-slo-sla-sli/">SLAs, SLOs, and SLIs</a></strong>. These turn vague ideas like &#8220;keep it up and running&#8221; into numbers we can measure:</p><ul><li><p><strong>Service Level Agreement (SLA):</strong> Contract with customers about service performance.</p><ul><li><p>This contract keeps a record of what the service provider promises to deliver</p></li><li><p>There are penalties or costs if the contract is not respected</p></li><li><p>In HA, this is an agreement about how much downtime is acceptable</p></li><li><p>For example, &#8220;our app will be online 99.9% of the time. If not, we&#8217;ll give your money back.&#8221;</p></li></ul></li><li><p><strong>Service Level Objective (SLO):</strong> Specific internal goal for the service performance.</p><ul><li><p>This is the target that internal teams are trying to hit with a desired metric</p></li><li><p>Your SLA is the minimum you promise customers; your SLO is the better performance you target internally</p></li><li><p>For example, if the SLA is 95% uptime, the SLO might be 98% to leave a 3% safety margin</p></li></ul></li><li><p><strong>Service Level Indicator (SLI):</strong> Metric used to measure service performance.</p><ul><li><p>Without measuring service performance, we can&#8217;t know if we&#8217;re hitting the targets</p></li><li><p>These metrics should reflect the SLO and SLA</p></li><li><p>For example, &#8220;Percentage of failed requests.&#8221;</p></li></ul></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dpG_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1d541b4-041a-42f8-86c9-aab5de6e1592_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dpG_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1d541b4-041a-42f8-86c9-aab5de6e1592_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!dpG_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1d541b4-041a-42f8-86c9-aab5de6e1592_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!dpG_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1d541b4-041a-42f8-86c9-aab5de6e1592_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!dpG_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1d541b4-041a-42f8-86c9-aab5de6e1592_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dpG_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1d541b4-041a-42f8-86c9-aab5de6e1592_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a1d541b4-041a-42f8-86c9-aab5de6e1592_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;:65316,&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://newsletter.systemdesign.one/i/189243555?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1d541b4-041a-42f8-86c9-aab5de6e1592_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dpG_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1d541b4-041a-42f8-86c9-aab5de6e1592_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!dpG_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1d541b4-041a-42f8-86c9-aab5de6e1592_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!dpG_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1d541b4-041a-42f8-86c9-aab5de6e1592_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!dpG_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1d541b4-041a-42f8-86c9-aab5de6e1592_1200x630.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 role="img" 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><title></title><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><figcaption class="image-caption">SLA vs SLO vs SLI</figcaption></figure></div><p>Let&#8217;s illustrate it with an example:</p><ul><li><p>A restaurant promises customers that their food will be delivered within 20 minutes of ordering (SLA).</p></li><li><p>The kitchen aims to finish orders in 15 minutes to stay ahead (SLO).</p></li><li><p>They track the average order completion time (SLI).</p></li></ul><p>These targets get expressed in &#8220;nines of availability&#8221;.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Jxj3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65ef7aa6-5075-492b-b76a-bdf9ea60ae86_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Jxj3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65ef7aa6-5075-492b-b76a-bdf9ea60ae86_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!Jxj3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65ef7aa6-5075-492b-b76a-bdf9ea60ae86_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!Jxj3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65ef7aa6-5075-492b-b76a-bdf9ea60ae86_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!Jxj3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65ef7aa6-5075-492b-b76a-bdf9ea60ae86_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Jxj3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65ef7aa6-5075-492b-b76a-bdf9ea60ae86_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/65ef7aa6-5075-492b-b76a-bdf9ea60ae86_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;:92909,&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://newsletter.systemdesign.one/i/189243555?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65ef7aa6-5075-492b-b76a-bdf9ea60ae86_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Jxj3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65ef7aa6-5075-492b-b76a-bdf9ea60ae86_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!Jxj3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65ef7aa6-5075-492b-b76a-bdf9ea60ae86_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!Jxj3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65ef7aa6-5075-492b-b76a-bdf9ea60ae86_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!Jxj3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65ef7aa6-5075-492b-b76a-bdf9ea60ae86_1200x630.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 role="img" 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><title></title><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><figcaption class="image-caption">Nines of availability</figcaption></figure></div><p>One nine means 90% uptime; two nines mean 99%; and so on&#8230;</p><p>Each extra nine sounds small, but cuts downtime by a ton. For example, 99% uptime allows over 3 days of outage a year, while 99.9% (&#8220;three nines&#8221;) allows only about 8 hours. Every nine added costs more. It needs better hardware, more redundancy, and more monitoring.</p><p>The closer you aim for perfect uptime, the more effort and money it takes to maintain it.</p><p>When failures occur,&nbsp;<a href="https://www.atlassian.com/incident-management/kpis/common-metrics">recovery metrics</a>&nbsp;help us measure how quickly and effectively we can recover. Here are the most important ones:</p><ul><li><p><strong>Recovery Time Objective (RTO)</strong></p><ul><li><p>How fast should the system recover from failure? How long can it be down for?</p></li><li><p>Larger RTO means more downtime is acceptable; smaller RTO means less downtime</p></li><li><p>For example, an RTO of 10 minutes means that the system should be able to recover within 10 minutes of failing</p></li></ul></li><li><p><strong>Recovery Point Objective (RPO)</strong></p><ul><li><p>To what point in time does the system recover? How much data loss is acceptable?</p></li><li><p>Larger RPO means more data loss, smaller RPO means less</p></li><li><p>For example, an RPO of 5 minutes means 5 minutes of data gets lost</p></li></ul></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fPWZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6396a491-c1e9-4b7d-8dd6-3d00ac688e24_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fPWZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6396a491-c1e9-4b7d-8dd6-3d00ac688e24_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!fPWZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6396a491-c1e9-4b7d-8dd6-3d00ac688e24_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!fPWZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6396a491-c1e9-4b7d-8dd6-3d00ac688e24_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!fPWZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6396a491-c1e9-4b7d-8dd6-3d00ac688e24_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fPWZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6396a491-c1e9-4b7d-8dd6-3d00ac688e24_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6396a491-c1e9-4b7d-8dd6-3d00ac688e24_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;:81930,&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://newsletter.systemdesign.one/i/189243555?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6396a491-c1e9-4b7d-8dd6-3d00ac688e24_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fPWZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6396a491-c1e9-4b7d-8dd6-3d00ac688e24_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!fPWZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6396a491-c1e9-4b7d-8dd6-3d00ac688e24_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!fPWZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6396a491-c1e9-4b7d-8dd6-3d00ac688e24_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!fPWZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6396a491-c1e9-4b7d-8dd6-3d00ac688e24_1200x630.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 role="img" 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><title></title><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><figcaption class="image-caption">RPO represents gap between last durable recovery point and an incident</figcaption></figure></div><ul><li><p><strong>MTTD (Mean Time to Detect)</strong></p><ul><li><p>This is the mean time needed to notice a failure</p></li><li><p>How long does it usually take for the system or team to detect that something is wrong?</p></li><li><p>Smaller MTTD means faster detection; larger MTTD means slower detection</p></li><li><p>For example, an MTTD of 30 seconds means issues get found half a minute after they occur on average</p></li></ul></li></ul><ul><li><p><strong>MTTR (Mean Time to Repair)</strong></p><ul><li><p>This is the mean time needed to fix a failure. How long does the system usually take to recover?</p></li><li><p>Larger MTTR means more time to recover, smaller MTTR means less</p></li><li><p>For example, an MTTR of 5 minutes means the failure will take 5 minutes to recover on average</p></li></ul></li><li><p><strong>MTBF (Mean Time Between Failures)</strong></p><ul><li><p>This is the mean time between two failures. How often does the system usually fail?</p></li><li><p>Larger MTBF means failures happen less often &amp; vice-versa</p></li><li><p>For example, an MTBF of 1h means failures usually happen every hour</p></li></ul></li><li><p><strong>MTTF (Mean Time to Failure)</strong></p><ul><li><p>This metric is designed for non-recoverable components. How long is the lifespan of this component?</p></li><li><p>This metric differs from MTBF because it lacks a recovery component. The component is alive, and then it crashes without recovery. MTTF is the time between those two points.</p></li><li><p>A larger MTTF means a component has a longer lifespan, and a smaller MTTF means a shorter one</p></li><li><p>For example, an MTTF of 3 years means a component usually lasts for 3 years before becoming unusable</p></li></ul></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DgT0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_1200x630.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DgT0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!DgT0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!DgT0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!DgT0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DgT0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_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;:68479,&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://newsletter.systemdesign.one/i/189243555?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!DgT0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!DgT0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!DgT0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!DgT0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1cf9f0c-66af-4a82-8a8a-d0d5f067ce7c_1200x630.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 role="img" 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><title></title><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><figcaption class="image-caption">NOTE: MTTF is for non-repairable systems. For repairable systems, it&#8217;s uptime.</figcaption></figure></div><p><strong>Availability Formula</strong></p><p>Availability links uptime &amp; downtime in one line:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;2263ec8c-47cd-441d-988c-7e9d581966a6&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">Availability = MTBF / (MTBF + MTTR)</code></pre></div><p>If the system runs for 1000 hours before a 1-hour fix, uptime is 99.9%.</p><p>Every extra nine costs more to achieve. Past &#8220;three nines,&#8221; you buy less outage and pay more in redundancy, automation, and testing.</p><p><em><strong>Takeaway:</strong></em></p><p>HA is measurable. Metrics turn abstract goals into clear engineering targets.</p><p>What gets measured gets managed.</p><p>Ready for the best part?</p><div><hr></div><p><em><strong>Reminder: this is a teaser of the subscriber-only post, exclusive to my golden members.</strong></em></p><p>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>Full access to System Design Case Studies</strong></p></li><li><p>FREE access to (coming) Interview Academy</p></li><li><p><strong>FREE access to (coming) Design, Build, Scale newsletter series</strong></p></li></ul><p>And more!</p><p>Get 10x the results you currently get with 1/10th the time, energy &amp; effort.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe&quot;,&quot;text&quot;:&quot;Unlock Your Next Level&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe"><span>Unlock Your Next Level</span></a></p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/what-is-high-availability">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[System Design Interview: Design ChatGPT]]></title><description><![CDATA[#125: System Design Interview]]></description><link>https://newsletter.systemdesign.one/p/chatgpt-system-design</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/chatgpt-system-design</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Wed, 25 Feb 2026 16:30:56 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/f0475035-1015-4e4d-8d47-0c650b185661_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/chatgpt-system-design/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li><li><p><em>Block diagrams created using <a href="https://app.eraser.io/auth/sign-up?ref=neo">Eraser</a>.</em></p></li></ul><div><hr></div><p>Most engineers think designing an AI chat system is just <em>&#8220;calling OpenAI API and saving messages to a database&#8221;.</em></p><p><em>That approach doesn&#8217;t work when you need to handle ChatGPT&#8217;s scale:</em></p><ul><li><p><em>5.8 billion visits per month</em></p></li><li><p><em>1 billion weekly active users sending 2.5+ billion prompts per day</em></p></li></ul><p>Your database can&#8217;t store 500TB per year. API costs will hit $145 million per month. And you&#8217;ll need 11.4 million concurrent connections that no single server can handle.</p><p>This problem shows up in senior and staff-level interviews at companies building AI products because it tests the exact skills that separate mid-level engineers from seniors:</p><ul><li><p>handling stateful connections at scale,</p></li><li><p>managing expensive external dependencies,</p></li><li><p>keeping costs under control while maintaining good UX,</p></li><li><p>and designing for failures when parts of your system go down.</p></li></ul><p>We&#8217;re going to build this from scratch at ChatGPT&#8217;s real scale, starting with clarifying requirements, then moving through frontend and backend design, database sharding<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a>, the complete user flow, GPU infrastructure, and finally explaining how to scale even further to 1 billion users.</p><p>Before we design anything, we need to understand exactly what we&#8217;re building and at what scale&#8230;</p><div><hr></div><h3><a href="https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine">Unblocked: The context layer your AI tools are missing (Partner)</a></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-9qf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 424w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 848w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 1272w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-9qf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png" width="1200" height="600" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:307185,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/188825279?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!-9qf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 424w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 848w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.png 1272w, https://substackcdn.com/image/fetch/$s_!-9qf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4157723-5d61-4d04-b699-f15d7670aeb4_1200x600.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 role="img" 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><title></title><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>Give your agents the understanding they need to generate reliable code, reviews, and answers. <strong><a href="https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine">Unblocked</a></strong> builds context from your team&#8217;s code, PR history, conversations, documentation, planning tools, and runtime signals. It surfaces the insights that matter so AI outputs reflect how your system actually works.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine&quot;,&quot;text&quot;:&quot;Try Unblocked Now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine"><span>Try Unblocked Now</span></a></p><p>(Thank you, <a href="https://getunblocked.com/?utm_source=systemdesign&amp;utm_medium=email&amp;utm_campaign=contextengine">Unblocked</a>, for partnering on this post.)</p><div><hr></div><p>I want to reintroduce <a href="https://linkedin.com/in/hayksimonyan">Hayk Simonyan</a> as a guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://youtube.com/@hayk.simonyan" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TNRZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 424w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 848w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 1272w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TNRZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png" width="1456" height="600" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:387657,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://youtube.com/@hayk.simonyan&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/188825279?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TNRZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 424w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 848w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.png 1272w, https://substackcdn.com/image/fetch/$s_!TNRZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe42ce2a7-78b8-43b3-b7cf-b293d660240a_1748x720.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 role="img" 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><title></title><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>He&#8217;s a senior software engineer specializing in helping developers break through their career plateaus and secure senior roles.</p><p>If you want to master the essential system design skills and land senior developer roles, I highly recommend checking out Hayk&#8217;s <strong><a href="https://youtube.com/@hayk.simonyan">YouTube channel</a></strong>.</p><p>His approach focuses on what top employers actually care about: system design expertise, advanced project experience, and elite-level interview performance.</p><div><hr></div><h2><strong>Clarifying Requirements</strong></h2><p> In interviews, candidates who skip this step fail immediately.</p><p><strong>Questions to ask:</strong></p><ul><li><p>Are we building the AI model itself or integrating with existing ones?</p></li><li><p>Do we need streaming responses (word by word) or complete responses?</p></li><li><p>What&#8217;s our expected scale? Thousands or millions of users?</p></li><li><p>Do users need accounts and conversation history?</p></li><li><p>Are conversations private or shareable?</p></li><li><p>Do we support multiple languages?</p></li><li><p>How do we handle rate limiting<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>? Free vs paid tiers?</p></li><li><p>Text only, or images and files too?</p></li><li><p>Do we need content moderation?</p></li></ul><p><strong>For this design, let&#8217;s assume:</strong></p><ul><li><p>Integrating with existing LLM (not building the model ourselves)</p></li><li><p>Streaming responses required for good UX</p></li><li><p>As of January 2026, ChatGPT has 800-900 million weekly active users, with an average of 2.5+ billion prompts per day</p></li><li><p>Users need accounts, private conversations with history</p></li><li><p>Text only, English first</p></li><li><p>Rate limiting on both requests and tokens</p></li><li><p>Basic content moderation required</p></li></ul><p>Now that we&#8217;ve defined our requirements, let&#8217;s start with what users actually see and interact with.</p><div><hr></div><h2><strong>Frontend Interface Design</strong></h2><p>Let&#8217;s visualize what we&#8217;re building. This clarifies requirements and influences backend decisions.</p><h4><strong>Main Interface:</strong></h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!v0AH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61231358-4f6b-4ad1-a10e-a62cbd472977_1600x1357.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!v0AH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61231358-4f6b-4ad1-a10e-a62cbd472977_1600x1357.png 424w, https://substackcdn.com/image/fetch/$s_!v0AH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61231358-4f6b-4ad1-a10e-a62cbd472977_1600x1357.png 848w, https://substackcdn.com/image/fetch/$s_!v0AH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61231358-4f6b-4ad1-a10e-a62cbd472977_1600x1357.png 1272w, https://substackcdn.com/image/fetch/$s_!v0AH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61231358-4f6b-4ad1-a10e-a62cbd472977_1600x1357.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!v0AH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61231358-4f6b-4ad1-a10e-a62cbd472977_1600x1357.png" width="1456" height="1235" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/61231358-4f6b-4ad1-a10e-a62cbd472977_1600x1357.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1235,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!v0AH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61231358-4f6b-4ad1-a10e-a62cbd472977_1600x1357.png 424w, https://substackcdn.com/image/fetch/$s_!v0AH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61231358-4f6b-4ad1-a10e-a62cbd472977_1600x1357.png 848w, https://substackcdn.com/image/fetch/$s_!v0AH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61231358-4f6b-4ad1-a10e-a62cbd472977_1600x1357.png 1272w, https://substackcdn.com/image/fetch/$s_!v0AH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61231358-4f6b-4ad1-a10e-a62cbd472977_1600x1357.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 role="img" 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><title></title><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><h4><strong>Critical frontend decision: Streaming</strong></h4><p>You have two options:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!G-uA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f3057f-6f0c-4a34-9220-9186fdd769dc_1600x423.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!G-uA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f3057f-6f0c-4a34-9220-9186fdd769dc_1600x423.png 424w, https://substackcdn.com/image/fetch/$s_!G-uA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f3057f-6f0c-4a34-9220-9186fdd769dc_1600x423.png 848w, https://substackcdn.com/image/fetch/$s_!G-uA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f3057f-6f0c-4a34-9220-9186fdd769dc_1600x423.png 1272w, https://substackcdn.com/image/fetch/$s_!G-uA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f3057f-6f0c-4a34-9220-9186fdd769dc_1600x423.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!G-uA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f3057f-6f0c-4a34-9220-9186fdd769dc_1600x423.png" width="1456" height="385" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b7f3057f-6f0c-4a34-9220-9186fdd769dc_1600x423.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:385,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!G-uA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f3057f-6f0c-4a34-9220-9186fdd769dc_1600x423.png 424w, https://substackcdn.com/image/fetch/$s_!G-uA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f3057f-6f0c-4a34-9220-9186fdd769dc_1600x423.png 848w, https://substackcdn.com/image/fetch/$s_!G-uA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f3057f-6f0c-4a34-9220-9186fdd769dc_1600x423.png 1272w, https://substackcdn.com/image/fetch/$s_!G-uA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f3057f-6f0c-4a34-9220-9186fdd769dc_1600x423.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 role="img" 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><title></title><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>Option 1: Wait for complete response</strong></p><ul><li><p>Simple HTTP POST, and get a full response back</p></li><li><p>User waits 10-30 seconds staring at the loading spinner</p></li><li><p>Poor UX, feels slow</p></li></ul><p><strong>Option 2: Stream word by word</strong></p><ul><li><p>Requires a persistent connection</p></li><li><p>User sees progress immediately</p></li><li><p>Much better UX</p></li></ul><p>ChatGPT, Claude, and Gemini all use streaming.</p><p>Let me verify the exact implementation.</p><h3><strong>How streaming actually works:</strong></h3><p>All major AI chat products use Server-Sent Events<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a> (SSE), not WebSockets.</p><p>Let me explain why:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LbdH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fd901b6-e22c-4826-9f8e-e70e627e4251_1600x1321.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LbdH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fd901b6-e22c-4826-9f8e-e70e627e4251_1600x1321.png 424w, https://substackcdn.com/image/fetch/$s_!LbdH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fd901b6-e22c-4826-9f8e-e70e627e4251_1600x1321.png 848w, https://substackcdn.com/image/fetch/$s_!LbdH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fd901b6-e22c-4826-9f8e-e70e627e4251_1600x1321.png 1272w, https://substackcdn.com/image/fetch/$s_!LbdH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fd901b6-e22c-4826-9f8e-e70e627e4251_1600x1321.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LbdH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fd901b6-e22c-4826-9f8e-e70e627e4251_1600x1321.png" width="1456" height="1202" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8fd901b6-e22c-4826-9f8e-e70e627e4251_1600x1321.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1202,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!LbdH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fd901b6-e22c-4826-9f8e-e70e627e4251_1600x1321.png 424w, https://substackcdn.com/image/fetch/$s_!LbdH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fd901b6-e22c-4826-9f8e-e70e627e4251_1600x1321.png 848w, https://substackcdn.com/image/fetch/$s_!LbdH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fd901b6-e22c-4826-9f8e-e70e627e4251_1600x1321.png 1272w, https://substackcdn.com/image/fetch/$s_!LbdH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fd901b6-e22c-4826-9f8e-e70e627e4251_1600x1321.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 role="img" 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><title></title><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>SSE (what ChatGPT uses):</strong></p><ul><li><p>Works over standard HTTP</p></li><li><p>Browser has a built-in EventSource API</p></li><li><p>Auto-reconnection handled automatically</p></li><li><p>One-way communication (server to client)</p></li><li><p>Simpler to implement and debug</p></li><li><p>Lower overhead than WebSockets</p></li></ul><p><strong>WebSockets (what ChatGPT doesn&#8217;t use):</strong></p><ul><li><p>Requires protocol upgrade from HTTP</p></li><li><p>Bidirectional communication</p></li><li><p>More complex to implement</p></li><li><p>Useful for collaborative features, typing indicators</p></li><li><p>Overkill for just streaming AI responses</p></li></ul><p><strong>Example of SSE streaming:</strong></p><p>User types: <em>&#8220;Explain React hooks&#8221;.</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Lw0g!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f217e2e-f93a-425f-9c8a-d04f9e2f7389_1102x1600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Lw0g!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f217e2e-f93a-425f-9c8a-d04f9e2f7389_1102x1600.png 424w, https://substackcdn.com/image/fetch/$s_!Lw0g!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f217e2e-f93a-425f-9c8a-d04f9e2f7389_1102x1600.png 848w, https://substackcdn.com/image/fetch/$s_!Lw0g!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f217e2e-f93a-425f-9c8a-d04f9e2f7389_1102x1600.png 1272w, https://substackcdn.com/image/fetch/$s_!Lw0g!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f217e2e-f93a-425f-9c8a-d04f9e2f7389_1102x1600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Lw0g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f217e2e-f93a-425f-9c8a-d04f9e2f7389_1102x1600.png" width="724" height="1051.179673321234" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4f217e2e-f93a-425f-9c8a-d04f9e2f7389_1102x1600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1600,&quot;width&quot;:1102,&quot;resizeWidth&quot;:724,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!Lw0g!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f217e2e-f93a-425f-9c8a-d04f9e2f7389_1102x1600.png 424w, https://substackcdn.com/image/fetch/$s_!Lw0g!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f217e2e-f93a-425f-9c8a-d04f9e2f7389_1102x1600.png 848w, https://substackcdn.com/image/fetch/$s_!Lw0g!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f217e2e-f93a-425f-9c8a-d04f9e2f7389_1102x1600.png 1272w, https://substackcdn.com/image/fetch/$s_!Lw0g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f217e2e-f93a-425f-9c8a-d04f9e2f7389_1102x1600.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 role="img" 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><title></title><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>Each word appears in the UI as it arrives, creating the typing effect.</p><h4><strong>Frontend tech stack:</strong></h4><ul><li><p>React for UI components</p></li><li><p>EventSource API for SSE connection</p></li><li><p>State management (Zustand or Redux) for conversations</p></li><li><p>Optimistic updates (show user message immediately)</p></li><li><p>Error handling for network failures, rate limits</p></li></ul><p>The frontend sets user expectations for real-time streaming.</p><p>Now, let&#8217;s formalize what our system must do.</p><div><hr></div><h2><strong>Functional Requirements</strong></h2><ul><li><p>User registration and authentication</p></li><li><p>Create and manage conversations</p></li><li><p>Send messages and receive streaming AI responses via SSE</p></li><li><p>Save all conversations with full history</p></li><li><p>Retrieve past conversations</p></li><li><p>Stream responses token<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a> by token</p></li><li><p>Rate limiting (requests + tokens)</p></li><li><p>Content moderation for harmful requests</p></li></ul><p>We&#8217;ve defined what the system does. But how well must it perform?</p><p>These requirements will drive our architectural decisions.</p><h2><strong>Non-Functional Requirements</strong></h2><p>How well it must perform (we&#8217;ll connect these to design decisions later):</p><ul><li><p>Availability: 99.9%</p><ul><li><p>Max 43 minutes of downtime per month</p></li></ul></li><li><p>Latency: First token &lt; 2 seconds</p><ul><li><p>Users wait no more than 2 seconds</p></li></ul></li><li><p>Scalability: 200M DAU, 20M concurrent conversations</p><ul><li><p>Assuming 10% concurrency</p></li></ul></li><li><p>Consistency: Zero message loss</p><ul><li><p>Every message must be saved</p></li></ul></li><li><p>Cost efficiency</p><ul><li><p>LLM APIs are expensive and need optimization</p></li></ul></li><li><p>Security: End-to-end encryption</p><ul><li><p>Private conversations</p></li></ul></li></ul><p>We&#8217;ll show how our design achieves each of these.</p><p>We&#8217;ve set our performance targets. Now let&#8217;s run the numbers to see what infrastructure we actually need.</p><div><hr></div><h2><strong>Capacity and Storage Estimation</strong></h2><p>Math matters because it drives infrastructure decisions.</p><p>Let&#8217;s use ChatGPT&#8217;s actual scale of growth projections:</p><p><strong>Traffic:</strong></p><ul><li><p>1 billion weekly active users (WAU)</p><ul><li><p>The current sources show 800-900 million weekly active users.</p></li><li><p>To accommodate growth and simplify our calculations, let&#8217;s design for 1 billion weekly active users.</p></li></ul></li><li><p>~200 million daily active users (DAU)</p></li><li><p>2.5 billion prompts/messages per day</p><ul><li><p>ChatGPT&#8217;s actual processing volume</p></li></ul></li><li><p>12.5 messages per user per day average</p></li><li><p>Peak hours (20% of daily traffic in 2 hours)</p><ul><li><p>69,444 messages/second</p></li></ul></li><li><p>Concurrent conversations at peak: ~20 million</p><ul><li><p>Assuming 10% of DAU are chatting simultaneously</p></li></ul></li></ul><p><strong>Storage per conversation:</strong></p><ul><li><p>User message: 100 characters = 100 bytes</p></li><li><p>AI response: 500 characters = 500 bytes</p></li><li><p>Per exchange: 600 bytes</p></li><li><p>12.5 exchanges/day/user: 7.5 KB/user/day</p></li><li><p>200M DAU &#215; 7.5KB = 1.5TB/day</p></li><li><p>Annual: 548 TB/year</p></li></ul><p><strong>Metadata storage:</strong></p><ul><li><p>User profiles (1KB each): 1B &#215; 1KB = 1TB</p></li><li><p>Conversation metadata (500 bytes each, 10 per user average): 10B conversations &#215; 500B = 5TB</p></li></ul><p><strong>Total Year 1: ~554TB</strong> (need distributed database, single PostgreSQL won&#8217;t cut it)</p><p><strong>Connection overhead:</strong></p><ul><li><p>20M concurrent SSE connections at peak</p></li><li><p>Each connection: ~10-30 seconds average</p></li><li><p>Need infrastructure that can handle millions of long-lived connections</p></li></ul><p><strong>Bandwidth:</strong></p><ul><li><p>Average response: 750 bytes streamed over 20 seconds</p></li><li><p>20M concurrent: 20M &#215; 750B / 20s = 750 MB/s = 6 Gbps</p></li><li><p>Peak outbound bandwidth requirement</p></li></ul><p><strong>Key insight:</strong> At ChatGPT&#8217;s scale, single-server solutions don&#8217;t work. We need distributed systems, sharding, and multi-region deployment from day one.</p><p>Now that we know the scale we&#8217;re dealing with, let&#8217;s design the actual system that can handle it.</p><div><hr></div><h2><strong>High-Level System Design</strong></h2><p>Before diving into costs and implementation details, let&#8217;s map out the complete system architecture.</p><p>OpenAI uses a multi-cloud setup to secure enough compute power and avoid relying on a single vendor:</p><ul><li><p><strong>Microsoft Azure:</strong> Still their leading provider. They have a massive, long-term partnership in which Microsoft builds specialized supercomputers for training OpenAI&#8217;s models.</p></li><li><p><strong>AWS:</strong> OpenAI signed a $38 billion deal with Amazon in late 2025. They now run significant workloads on AWS&#8217;s GPU clusters and specialized AI hardware.</p></li><li><p><strong>Google Cloud (GCP):</strong> As of mid-2025, OpenAI uses GCP to power parts of ChatGPT Enterprise and the Team tiers, as well as their API.</p></li><li><p><strong>Oracle:</strong> They have a multi-billion dollar agreement to use Oracle&#8217;s data center capacity, specifically for the massive &#8220;Stargate&#8221; infrastructure project.</p></li><li><p><strong>CoreWeave:</strong> They also use this specialized &#8220;neocloud&#8221; provider for dedicated access to high-performance NVIDIA GPUs.</p></li></ul><h3><strong>Components Overview</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DEzf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a38f62a-6e58-41fc-a140-1c1c04654d25_1600x690.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DEzf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a38f62a-6e58-41fc-a140-1c1c04654d25_1600x690.png 424w, https://substackcdn.com/image/fetch/$s_!DEzf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a38f62a-6e58-41fc-a140-1c1c04654d25_1600x690.png 848w, https://substackcdn.com/image/fetch/$s_!DEzf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a38f62a-6e58-41fc-a140-1c1c04654d25_1600x690.png 1272w, https://substackcdn.com/image/fetch/$s_!DEzf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a38f62a-6e58-41fc-a140-1c1c04654d25_1600x690.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DEzf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a38f62a-6e58-41fc-a140-1c1c04654d25_1600x690.png" width="1456" height="628" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1a38f62a-6e58-41fc-a140-1c1c04654d25_1600x690.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:628,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!DEzf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a38f62a-6e58-41fc-a140-1c1c04654d25_1600x690.png 424w, https://substackcdn.com/image/fetch/$s_!DEzf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a38f62a-6e58-41fc-a140-1c1c04654d25_1600x690.png 848w, https://substackcdn.com/image/fetch/$s_!DEzf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a38f62a-6e58-41fc-a140-1c1c04654d25_1600x690.png 1272w, https://substackcdn.com/image/fetch/$s_!DEzf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a38f62a-6e58-41fc-a140-1c1c04654d25_1600x690.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 role="img" 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><title></title><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>Our system has three main layers:</p><ol><li><p>Client Layer</p><ul><li><p>React web application</p></li><li><p>Mobile apps (iOS/Android)</p></li><li><p>SSE connections for real-time streaming</p></li></ul></li></ol><ol start="2"><li><p>Service Layer (Microservices<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-5" href="#footnote-5" target="_self">5</a>)</p><ul><li><p>API Gateway: Entry point, SSL termination, request routing</p></li><li><p>Auth Service: JWT<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-6" href="#footnote-6" target="_self">6</a> authentication, user session management</p></li><li><p>Message Service: Core orchestrator for message processing and streaming</p></li><li><p>Conversation Service: CRUD operations for conversations and message history</p></li><li><p>Rate Limiter Service: Track and enforce request/token limits per user</p></li><li><p>Moderation Service: Content filtering for harmful requests</p></li><li><p>LLM Gateway Service: Routes requests to GPU clusters, handles streaming responses</p></li></ul></li></ol><ul><li><p><em>Why this order?</em></p><ul><li><p>Load Balancer is &#8220;dumb&#8221; - it just distributes TCP/HTTP connections across servers.</p></li><li><p>API Gateway is &#8220;smart&#8221; - reads the URL path and routes: <code>/auth/*</code> &#8594; Auth Service, <code>/conversations/* </code>&#8594; Conversation Service, etc.</p></li></ul></li></ul><ol start="3"><li><p>Data Layer</p><ul><li><p>PostgreSQL: Single primary + 20 read replicas<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-7" href="#footnote-7" target="_self">7</a> (user data, conversations, messages)</p></li><li><p>Redis<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-8" href="#footnote-8" target="_self">8</a> Cluster: Rate limiting state, conversation history cache, response cache</p></li><li><p>GPU Cluster: 17,500 H100<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-9" href="#footnote-9" target="_self">9</a> GPUs for model inference</p></li><li><p>Azure Blob Storage: Long-term archive for old conversations</p></li></ul></li></ol><h4><strong>How Does the User Receive the Response?</strong></h4><p>The response flows back through the SAME connection path, reversed:</p><ul><li><p>The HTTP connection stays open from:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;f8e55f7f-bc55-485a-9fa6-113aef0c44ab&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext"> Browser &#8594; Load Balancer &#8594; API Gateway &#8594; Message Service</code></pre></div></li><li><p>Message Service writes tokens to the response stream</p></li><li><p>Each token flows backward:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;88ebc8e3-65fe-418a-869a-50a9bbff9379&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">Message Service &#8594; API Gateway &#8594; Load Balancer &#8594; Browser</code></pre></div></li><li><p>Browser&#8217;s EventSource API receives each event in real-time</p></li><li><p>Connection closes when streaming completes</p></li></ul><p>Think of it like a phone call:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;6df3e375-83fe-457d-8e3d-7b009eb68ba1&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">You call (request) &#8594; they answer and KEEP TALKING for 20 seconds (streaming) &#8594; then hang up.</code></pre></div><p>Same connection, just stays open longer.</p><h3><strong>Key Architectural Decisions</strong></h3><p><strong>Single Primary PostgreSQL (not sharded)</strong></p><ul><li><p>Why: ChatGPT&#8217;s workload is 90% reads, 10% writes</p></li><li><p>OpenAI&#8217;s proven architecture: handles 800M users without sharding</p></li><li><p>Writes: All go through a single primary instance</p></li><li><p>Reads: Distributed across 20+ replicas in 6 regions</p></li><li><p>Trade-off: Single writer bottleneck, but application simplicity wins</p></li></ul><p><em><strong>Why reads dominate despite 2.5B prompts/day</strong></em></p><p>Think about what happens per user prompt:</p><ul><li><p>Load user account</p></li><li><p>Load subscription/quota info</p></li><li><p>Load conversation metadata</p></li><li><p>Load recent messages for context</p></li><li><p>Check rate limits</p></li><li><p>Maybe load feature flags, experiments, and so on.</p></li></ul><p>Those are all <em>reads</em>.</p><p>Writes usually happens only when:</p><ul><li><p>A new message is stored</p></li><li><p>Conversation metadata is updated</p></li><li><p>Usage counters are incremented</p></li><li><p>Logs are persisted</p></li></ul><p>So one prompt can trigger many reads, but only a few writes.</p><p><strong>Microservices Architecture</strong></p><ul><li><p>Why: Independent scaling and deployment</p></li><li><p>Each service scales independently based on its load</p></li><li><p>LLM Gateway can scale GPU clusters without touching other services</p></li><li><p>Rate Limiter needs different scaling than Conversation Service</p></li><li><p>Trade-off: Operational complexity vs scaling flexibility</p></li></ul><p><strong>SSE for Streaming (not WebSockets)</strong></p><ul><li><p>Why: Simpler, one-way communication is sufficient</p></li><li><p>Browser has a built-in EventSource API with auto-reconnection</p></li><li><p>Lower overhead than WebSockets</p></li><li><p>Most AI products (ChatGPT, Claude, Gemini) use SSE</p></li><li><p>Trade-off: Can&#8217;t do bidirectional communication (acceptable for chat)</p></li></ul><p><strong>Self-Hosted GPU Infrastructure</strong></p><ul><li><p>Why: At 2.5B messages/day, API costs would be $159M/month</p></li><li><p>Self-hosting: $52.4M/month (67% cheaper)</p></li><li><p>Requires: 17,500 H100 GPUs across multiple cloud providers</p></li><li><p>Trade-off: $525M upfront cost vs ongoing API expenses</p></li></ul><p><strong>Multi-Region Deployment</strong></p><ul><li><p>6 regions: 2 Americas, 2 Europe, 2 Asia-Pacific</p></li><li><p>Why: Global low-latency (users connect to the nearest region)</p></li><li><p>Each region has a full application stack + read replicas</p></li><li><p>GPU clusters are centralized in 3-4 major data centers</p></li><li><p>Trade-off: Operational complexity vs user experience</p></li></ul><p>We've mapped out the architecture.</p><p>The interesting part comes next: how much this actually costs to run, why OpenAI made the controversial choice to not shard their database, and what changes at 500M and 1B users.</p><p>First, let's trace a message from the send button to the AI response&#8230;</p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/chatgpt-system-design">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[System Design Interview: Design Web Crawler and Search Engine]]></title><description><![CDATA[#124: System Design Interview]]></description><link>https://newsletter.systemdesign.one/p/web-crawler-system-design</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/web-crawler-system-design</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Sat, 21 Feb 2026 11:45:16 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/b92c2e4c-68dd-4314-a663-9d2eadd1f51b_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/web-crawler-system-design/?action=share">Share this post</a> &amp; I&#8217;ll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>You type something in the Google Search bar and get instant results.</p><p><em>How does this work?</em></p><p>Today&#8217;s newsletter will teach you the architecture of search systems.</p><p>At a high level, a search system has two components: <strong>a web crawler and a search engine.</strong></p><ul><li><p>A web crawler crawls webpages and stores them in a datastore.</p></li><li><p>A search engine looks through the data in the datastore to answer user search queries.</p></li></ul><p>Let&#8217;s start by understanding the system requirements&#8230;</p><div><hr></div><h3><a href="https://serpapi.com/?utm_source=thesystemdesignnewsletter">Need public web data, without scraper headaches? (Partner)</a></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://serpapi.com/?utm_source=thesystemdesignnewsletter" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Hdlc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Hdlc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg" width="1200" height="1171" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1171,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:182785,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:&quot;https://serpapi.com/?utm_source=thesystemdesignnewsletter&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/180977546?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Hdlc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Hdlc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56bb41d0-a9df-40dd-9253-e67c930cc2ad_1200x1171.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 role="img" 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><title></title><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><a href="https://serpapi.com/?utm_source=thesystemdesignnewsletter">SerpApi</a></strong> turns search results into predictable JSON with built-in scale, location options, and protection from blocks.</p><p>That&#8217;s why engineers use it to ship:</p><ul><li><p>AI applications</p></li><li><p>Product research</p></li><li><p>Price tracking</p></li><li><p>SEO insights</p></li></ul><p>All without maintaining scrapers or infrastructure.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://serpapi.com/?utm_source=thesystemdesignnewsletter&quot;,&quot;text&quot;:&quot;Try For Free&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://serpapi.com/?utm_source=thesystemdesignnewsletter"><span>Try For Free</span></a></p><p>(I&#8217;d like to thank <a href="https://serpapi.com/?utm_source=thesystemdesignnewsletter">SerpApi</a> for partnering on this post.)</p><div><hr></div><p>I want to introduce <a href="https://www.linkedin.com/in/msdeep14/">Mandeep Singh</a> as a guest author.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://www.linkedin.com/in/msdeep14/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zk2R!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a90939-45e0-47ae-ad1d-8d2ad0b3ce61_1584x396.png 424w, https://substackcdn.com/image/fetch/$s_!zk2R!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a90939-45e0-47ae-ad1d-8d2ad0b3ce61_1584x396.png 848w, https://substackcdn.com/image/fetch/$s_!zk2R!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a90939-45e0-47ae-ad1d-8d2ad0b3ce61_1584x396.png 1272w, https://substackcdn.com/image/fetch/$s_!zk2R!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a90939-45e0-47ae-ad1d-8d2ad0b3ce61_1584x396.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zk2R!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a90939-45e0-47ae-ad1d-8d2ad0b3ce61_1584x396.png" width="1456" height="364" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/30a90939-45e0-47ae-ad1d-8d2ad0b3ce61_1584x396.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:364,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1102236,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://www.linkedin.com/in/msdeep14/&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/188371881?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a90939-45e0-47ae-ad1d-8d2ad0b3ce61_1584x396.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zk2R!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a90939-45e0-47ae-ad1d-8d2ad0b3ce61_1584x396.png 424w, https://substackcdn.com/image/fetch/$s_!zk2R!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a90939-45e0-47ae-ad1d-8d2ad0b3ce61_1584x396.png 848w, https://substackcdn.com/image/fetch/$s_!zk2R!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a90939-45e0-47ae-ad1d-8d2ad0b3ce61_1584x396.png 1272w, https://substackcdn.com/image/fetch/$s_!zk2R!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a90939-45e0-47ae-ad1d-8d2ad0b3ce61_1584x396.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>He&#8217;s an author, educator, and software engineer with a strong passion for building simple, scalable systems. He authored the O'Reilly book "System Design on AWS" and supports others' learning and development by sharing lessons on Cloud and System Design on <a href="https://www.youtube.com/@MsDeepSingh">YouTube</a>.</p><p>Checkout his work:</p><ul><li><p><a href="https://oreil.ly/ruQbc">System Design on AWS Book</a> (Also find on <a href="https://amzn.to/3D3BIBJ">Amazon</a>)</p></li><li><p><a href="https://www.linkedin.com/in/msdeep14/">LinkedIn</a></p></li><li><p><a href="https://x.com/msdeep14">X</a></p></li><li><p><a href="https://discord.gg/98zTnzvGz2">Discord Server</a></p></li></ul><div><hr></div><h1>System Requirements</h1><p><em>(There are two kinds of requirements: functional and non-functional.)</em></p><p>Functional requirements are functionalities from the user's perspective.</p><p>It includes:</p><ul><li><p>Fetching top results for a search query.</p></li><li><p>Including the web page URL, title, and subtitle in each result.</p></li><li><p>Avoiding outdated results.</p></li></ul><p>Search systems are large and support many functionalities. So let&#8217;s limit the scope:</p><ul><li><p>Queries can only be done in English.</p></li><li><p>Exclude what, why, and how of machine learning components.</p></li></ul><p>The system must follow certain constraints to maintain quality. These are called non-functional requirements (<strong>NFRs</strong>).</p><p>Key NFRs include:</p><ul><li><p>Availability: System must be up and able to respond to search requests.</p></li><li><p>Reliability: System must return correct and consistent results.</p></li><li><p>Scalability: User traffic grows over time, so does the content on the internet. The system must handle this growth without performance issues.</p></li><li><p>Low Latency: Search results should be returned in milliseconds.</p></li></ul><p>These requirements guide the system design. Another important factor is the expected scale, which directly affects design decisions.</p><p>Let&#8217;s estimate the system scale next&#8230;</p><div><hr></div><h1>Back of the Envelope: Understanding Scale</h1><p>In system design interviews, it&#8217;s recommended to make some assumptions after discussion with the interviewer.</p><p>Here are some estimations:</p><h4>Web crawler</h4><p>The scale of a web crawler depends on how many pages it crawls.</p><p>Assume:</p><ul><li><p>Active websites: 200 million</p></li><li><p>Average pages per website: 50</p></li></ul><p>Now, for each website, there can be both internal and external redirects. The external redirects are part of 200 million.</p><p>Then, for internal redirects:</p><ul><li><p>Total pages = 200 million &#215; 50 = 10 billion pages</p></li></ul><p>Now estimate storage:</p><ul><li><p>Average page size: 2 MB</p></li><li><p>Total storage = 10 billion &#215; 2 MB = 20 PB</p></li></ul><p>NOTE: Web pages can include text, images, and videos. In practice, a crawler may store only the parts needed for search. This estimate assumes we store pages as-is, in the same format in which we download them.</p><p>Let&#8217;s look into the scale of the search engine system next&#8230;</p><h4>Search engine</h4><p>Assume Google scale traffic:</p><ul><li><p>Searches per day: 8.5 billion</p></li><li><p>Searches per second: ~100,000</p></li></ul><p>These rough numbers help shape the design choices.</p><p>Next, we&#8217;ll dive into the high-level system design&#8230;</p><div><hr></div><h1>High-Level System Design</h1><p>We&#8217;ll design a scalable system and discuss the key components of each subsystem separately. Keep in mind that Google has evolved significantly to support this scale, and it is not possible to capture all details in this post.</p><p>We&#8217;ll first design the web crawler, and then move on to the search engine:</p><h2>Web Crawler</h2><p>The crawler needs an initial list of URLs to start with. These are called <strong>seed URLs</strong>.</p><p>There is no single source that contains all websites. So we start with well-known domains and discover new URLs as we crawl.</p><p>Here are several ways to discover new website URLs:</p><ul><li><p>Create a platform for new website owners to submit their site details.</p></li><li><p>Retrieve the list of website links from the website being crawled.</p></li><li><p>New website URL queried by the user.</p></li></ul><p>The crawler does not visit every website at the same rate. Some sites change frequently, while others rarely update.</p><p>The process of deciding how often to visit a website is called <strong>crawl scheduling (politeness)</strong>. The component that decides which URL to crawl next is called the <strong>URL frontier</strong>.</p><h3>1. URL Frontier Design</h3><p>The design shown in Figure 1 is inspired by the <a href="https://www.cs.cornell.edu/courses/cs685/2002fa/mercator.pdf">Mercator</a> crawler. It uses a two-stage queue system to handle both priority and politeness.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QNO0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf2b6846-6131-48bf-b7ef-c70476f96d02_817x362.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QNO0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf2b6846-6131-48bf-b7ef-c70476f96d02_817x362.png 424w, https://substackcdn.com/image/fetch/$s_!QNO0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf2b6846-6131-48bf-b7ef-c70476f96d02_817x362.png 848w, https://substackcdn.com/image/fetch/$s_!QNO0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf2b6846-6131-48bf-b7ef-c70476f96d02_817x362.png 1272w, https://substackcdn.com/image/fetch/$s_!QNO0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf2b6846-6131-48bf-b7ef-c70476f96d02_817x362.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QNO0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf2b6846-6131-48bf-b7ef-c70476f96d02_817x362.png" width="817" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/af2b6846-6131-48bf-b7ef-c70476f96d02_817x362.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:362,&quot;width&quot;:817,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!QNO0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf2b6846-6131-48bf-b7ef-c70476f96d02_817x362.png 424w, https://substackcdn.com/image/fetch/$s_!QNO0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf2b6846-6131-48bf-b7ef-c70476f96d02_817x362.png 848w, https://substackcdn.com/image/fetch/$s_!QNO0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf2b6846-6131-48bf-b7ef-c70476f96d02_817x362.png 1272w, https://substackcdn.com/image/fetch/$s_!QNO0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf2b6846-6131-48bf-b7ef-c70476f96d02_817x362.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 role="img" 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><title></title><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><figcaption class="image-caption">Figure 1. URL Frontier Architecture</figcaption></figure></div><p>Here&#8217;s the architecture overview:</p><ul><li><p>Front queues represent different priority levels. The prioritizer assigns a priority (for example, 1 to n) to each URL. Based on this value, the URL gets placed into a specific front queue. The front queue selector picks URLs using a weighted round-robin approach, so higher-priority URLs get chosen more often.</p></li><li><p>From the front queues, URLs move to the back queues. A domain-to-back-queue database ensures that all URLs from the same host (for example, example.com) go to the same back queue. This helps enforce politeness rules per host.</p></li><li><p>A priority queue (implemented as a min-heap) keeps track of when each host can be contacted again. There is one entry per back queue. The heap stores the next allowed fetch time for that host/domain.</p></li><li><p>The back queue selector removes the host with the earliest allowed time from the heap. It then fetches one URL from that host&#8217;s back queue. After the URL gets crawled, the system updates the heap with the next allowed fetch time according to politeness rules.</p></li></ul><p>While Mercator provides a strong foundation, there can be bottlenecks at internet scale:</p><ul><li><p>FIFO queues keep a fixed number of URLs in memory and store most URLs on disk to support a high crawl rate on commodity hardware. At a large scale, frequent disk reads and writes can become a bottleneck. More advanced disk-based algorithms (such as those discussed in <a href="https://irl.cs.tamu.edu/people/hsin-tsang/papers/www2008.pdf">IRLBot research paper</a>) can help reduce this overhead.</p></li><li><p>Another issue is static priority and politeness logic. If a website becomes slow or starts returning errors, the crawler should adjust its crawl rate dynamically. Instead of fixed rules, the system should use adaptive politeness. HTTP response code could be an important factor in this decision.</p><p>For example:</p><ul><li><p>HTTP 200: Crawl at normal rate.</p></li><li><p>HTTP 429: Reduce crawl rate and retry later.</p></li><li><p>HTTP 500: Retry only after a longer cooldown.</p></li></ul></li><li><p>Many domains could share the same IP address (shared hosting, CDNs, cloud providers). Using a single back queue per host can cause skew or a hotspot. The solution is to enforce limits at both the host and IP levels.</p><p>For example:</p><ul><li><p><code>hello.com</code> can be crawled once every 10 seconds.</p></li><li><p>IP <code>192.168.1.2</code> can be crawled up to 5 times per second across all domains hosted on that IP.</p></li></ul></li></ul><p>URL frontier acts on a continuous feedback loop. URL fetcher (Figure 2) reports metrics such as latency and error rate. URL frontier adjusts crawl rate and priority based on these signals.</p><p>For example:</p><ul><li><p>If a website responds slowly, increase politeness (reduce crawl rate).</p></li><li><p>If there are repeated 500 errors, lower the website&#8217;s priority.</p></li></ul><p>Once URL frontier selects a URL, the crawler visits the page. Before crawling, the system should check whether the page has already been fetched or modified. There is no benefit in fetching the same content repeatedly.</p><p>Next, let&#8217;s discuss URL duplication and content duplication handling...</p><h3>2. Web Page Similarity and URL Duplication</h3><p>A web crawler can run into infinite loops. This can happen if:</p><ul><li><p>A page links to itself.</p></li><li><p>The same URL appears many times in different places.</p></li><li><p>URLs are generated dynamically in large numbers.</p></li></ul><p>To prevent this, the crawler must detect duplicate URLs before crawling them.</p><h4>URL Deduplication</h4><p>How do we check if a URL was crawled?</p><p>One approach is to store all crawled URLs in a global lookup table (HashMap). As many crawler instances run in parallel, this lookup must be shared across machines. A distributed key-value database can be used for this purpose.</p><p>This lookup needs to be fast.</p><p>Disk-based databases increase latency because of disk reads. An in-memory system is faster but must handle very large amounts of data. The data can be partitioned (sharded) across many machines to scale.</p><p>We can use a Bloom filter to reduce memory usage.</p><p>A Bloom filter is a space-efficient data structure that checks whether an element already exists in a set. It&#8217;s probabilistic, that is:</p><ul><li><p>If it says &#8220;<em>no</em>,&#8221; the URL definitely has not been seen.</p></li><li><p>If it says &#8220;<em>yes</em>,&#8221; the URL <em>might</em> have been seen.</p></li></ul><p>This can sometimes cause a new URL to be skipped, but for large-scale crawling, this tradeoff is acceptable.</p><p>The URL set can be distributed across machines using consistent hashing. This ensures even distribution and supports adding or removing servers without major reshuffling.</p><p>Now let&#8217;s focus on content duplication&#8230;</p><h4>Content Deduplication</h4><p>Even if URLs are different, page content might be the same.</p><p>A simple word-by-word comparison is expensive and inefficient. Instead, crawlers compute a fingerprint of the page content. One common technique is <a href="https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/33026.pdf">Simhash algorithm</a>, which generates a compact representation of the page.</p><p>Similar pages will have similar fingerprints, making duplicate detection efficient.</p><h4>Handling Intentional Duplicates</h4><p>Some websites intentionally publish the same content under different URLs.</p><p>Search engines support a <a href="https://en.wikipedia.org/wiki/Canonical_link_element">canonical link element</a> to handle this scenario. Website owners can specify the preferred URL for a piece of content. The crawler stores only the canonical version for indexing.</p><p>The bottom line:</p><ul><li><p>URL deduplication occurs before crawling.</p></li><li><p>Content deduplication occurs after fetching the page.</p></li></ul><h4>Robots and Exclusions</h4><p>Before crawling, the system must check whether the URL is allowed.</p><p>Web servers can define rules in the robots.txt file to control crawler access. The crawler must respect these rules. Also, the crawler may maintain its own blocklist for certain websites or regions.</p><p>After passing these checks and finishing the crawl, the system stores the page content.</p><p>Next, let&#8217;s discuss storage design&#8230;</p><h3>3. Web Crawler Storage</h3><p>The choice of database depends on what we want to store and what format.</p><p>Here are a few options:</p><ol><li><p>Store the entire webpage as-is</p><ul><li><p>This is like saving a webpage using &#8220;Save Page As&#8221; in a browser. The full HTML content is stored without modification.</p></li></ul></li><li><p>Extract and store only the required data</p><ul><li><p>The crawler processes the page and saves only useful parts, such as text and metadata.</p></li></ul></li><li><p>Store the page in a document database</p><ul><li><p>Since a webpage is essentially a document, it can be stored in a document database.</p></li></ul></li></ol><p>In our case, the data has no fixed structure, and we do not need to run complex queries on it. So the simplest approach is to store the entire webpage.</p><p>An object store, such as Amazon S3, is a good fit for this.</p><p>Object stores are scalable and highly durable, so we don&#8217;t have to worry about scalability and reliability. At a very large scale, some companies build and manage their own distributed storage systems, but that is a separate and complex topic.</p><p>NOTE: <a href="https://cloud.google.com/blog/products/storage-data-transfer/a-peek-behind-colossus-googles-file-system">Colossus</a> is Google&#8217;s distributed storage system. It replaced Google File System (<strong>GFS</strong>) and is designed to support Google&#8217;s massive scale.</p><h4>Metadata Storage</h4><p>We also need to store metadata. It includes:</p><ul><li><p>URL</p></li><li><p>Location of stored content</p></li><li><p>Last crawled time</p></li><li><p>Status or crawl result</p></li></ul><p>This requires a key-value style database, where:</p><ul><li><p>Key = URL</p></li><li><p>Value = Metadata</p></li></ul><p>A relational database could also work, but since we do not need complex joins or relationships, a distributed key-value store is more suitable. The data should be partitioned (sharded) for scale.</p><p>Now that we have covered the main crawler components, let&#8217;s discuss how these components work together to crawl the web&#8230;</p><h3>4. Web Crawler Components Coordination</h3><p>There are a few ways to coordinate the crawler components. Each option has its tradeoffs:</p><h4>Approach #1: Synchronous communication</h4><p>Each component exposes an API and calls the next component directly. If different components run inside the same service (microservice), they can call each other via local method calls.</p><h4>Approach #2: Choreography</h4><p>Each component publishes an event when it finishes its work. The next component consumes the event and continues the workflow. This is also known as event-driven architecture.</p><h4>Approach #3: Orchestration</h4><p>Add an orchestrator to manage the crawler&#8217;s lifecycle. The orchestrator triggers each step, tracks progress, and handles retries. Components can still communicate synchronously or asynchronously, depending on what fits.</p><p><em>&#8230;So which approach fits best here?</em></p><p>You might have heard the statement: <em>&#8220;</em>Everything is a tradeoff in system design.&#8221; This is very true: all approaches are best in one scenario but can be the worst in others.</p><p>Let&#8217;s do a trade-off analysis for the web crawler system:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WiZW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ac2f8b-c9bd-41ab-9f9a-30fb3c7c9643_1298x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WiZW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ac2f8b-c9bd-41ab-9f9a-30fb3c7c9643_1298x768.png 424w, https://substackcdn.com/image/fetch/$s_!WiZW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ac2f8b-c9bd-41ab-9f9a-30fb3c7c9643_1298x768.png 848w, https://substackcdn.com/image/fetch/$s_!WiZW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ac2f8b-c9bd-41ab-9f9a-30fb3c7c9643_1298x768.png 1272w, https://substackcdn.com/image/fetch/$s_!WiZW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ac2f8b-c9bd-41ab-9f9a-30fb3c7c9643_1298x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WiZW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ac2f8b-c9bd-41ab-9f9a-30fb3c7c9643_1298x768.png" width="1298" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f9ac2f8b-c9bd-41ab-9f9a-30fb3c7c9643_1298x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1298,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!WiZW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ac2f8b-c9bd-41ab-9f9a-30fb3c7c9643_1298x768.png 424w, https://substackcdn.com/image/fetch/$s_!WiZW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ac2f8b-c9bd-41ab-9f9a-30fb3c7c9643_1298x768.png 848w, https://substackcdn.com/image/fetch/$s_!WiZW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ac2f8b-c9bd-41ab-9f9a-30fb3c7c9643_1298x768.png 1272w, https://substackcdn.com/image/fetch/$s_!WiZW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ac2f8b-c9bd-41ab-9f9a-30fb3c7c9643_1298x768.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 role="img" 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><title></title><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><figcaption class="image-caption">Figure 2. Web Crawler Orchestration Approaches</figcaption></figure></div><p>For the crawler, Approach #3 (Orchestration) makes more sense. Here&#8217;s why:</p><ul><li><p>End-to-end monitoring: You can track, retry, or debug each component.</p></li><li><p>Failure handling: If a component is unhealthy, the orchestrator can trigger a retry, pause, or reroute work.</p></li><li><p>Scheduling support: Orchestrator can schedule recrawls and also handle new URLs discovered during crawling.</p></li></ul><p>Next, let&#8217;s combine these components and create a high-level diagram&#8230;</p><h3>5. Web Crawler System Components</h3><p>Figure 3 shows the end-to-end workflow.</p><p>The blocks in the diagram are logical components, not separate microservices. You can deploy them together or separately, depending on scale, cost, and operational needs.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nKmH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf4e560d-cf34-4434-a45e-c08c4bbc14bf_781x371.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nKmH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf4e560d-cf34-4434-a45e-c08c4bbc14bf_781x371.png 424w, https://substackcdn.com/image/fetch/$s_!nKmH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf4e560d-cf34-4434-a45e-c08c4bbc14bf_781x371.png 848w, https://substackcdn.com/image/fetch/$s_!nKmH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf4e560d-cf34-4434-a45e-c08c4bbc14bf_781x371.png 1272w, https://substackcdn.com/image/fetch/$s_!nKmH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf4e560d-cf34-4434-a45e-c08c4bbc14bf_781x371.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nKmH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf4e560d-cf34-4434-a45e-c08c4bbc14bf_781x371.png" width="781" height="371" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cf4e560d-cf34-4434-a45e-c08c4bbc14bf_781x371.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:371,&quot;width&quot;:781,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!nKmH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf4e560d-cf34-4434-a45e-c08c4bbc14bf_781x371.png 424w, https://substackcdn.com/image/fetch/$s_!nKmH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf4e560d-cf34-4434-a45e-c08c4bbc14bf_781x371.png 848w, https://substackcdn.com/image/fetch/$s_!nKmH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf4e560d-cf34-4434-a45e-c08c4bbc14bf_781x371.png 1272w, https://substackcdn.com/image/fetch/$s_!nKmH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf4e560d-cf34-4434-a45e-c08c4bbc14bf_781x371.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 role="img" 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><title></title><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><figcaption class="image-caption">Figure 3. Web Crawler System Design</figcaption></figure></div><p>Let&#8217;s summarize all the components and workflow:</p><ol><li><p>URL Frontier</p><ul><li><p>Starts with seed URLs and outputs the next URLs to crawl.</p></li></ul></li><li><p>URL goes through certain validations, such as:</p><ul><li><p>URL uniqueness (have we seen this URL before?)</p></li><li><p>Verification in robots.txt cache (is crawling allowed?)</p></li><li><p>Fetch IP address from DNS cache. This cache is continuously updated once the URL is fetched from the internet.</p></li></ul></li><li><p>Webpage Fetcher System</p><ul><li><p>Downloads the page content and stores it in the content database.</p></li><li><p>Some pages load content in multiple steps using JavaScript. For this, fetcher may need a headless browser to render the page and get the final content.</p></li><li><p>To save bandwidth, the system can cache shared resources, such as common JavaScript and CSS files, instead of downloading them repeatedly.</p></li></ul></li><li><p>Webpage Processing System</p><ul><li><p>Parses the downloaded page to extract new links. Then it filters these links using rules such as:</p><ul><li><p>Blocklists</p></li><li><p>URL patterns</p></li><li><p>Region-based restrictions</p></li></ul></li></ul></li><li><p>Feedback loop</p><ul><li><p>The extracted URLs are then sent back to the URL frontier, and the crawl cycle continues.</p></li></ul></li></ol><p>NOTE: A Domain Name System (<strong>DNS</strong>) handles mapping between domain names (such as <code>google.com</code>) to their IP addresses. </p><p>Web crawler&#8217;s job finishes as soon as the web page is downloaded and stored. Search engine then takes this content, builds indexes, and serves user queries.</p><p>Next, let&#8217;s explore the architecture of the search engine system&#8230;</p><div><hr></div><blockquote><p><em><strong>This newsletter is inspired by Chapter 15 of the O&#8217;Reilly book &#8220;<a href="https://msdeepsingh.com/books/">System Design on AWS</a>&#8221;. Get a copy of the book right now.</strong></em></p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Onlo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Onlo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.png 424w, https://substackcdn.com/image/fetch/$s_!Onlo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.png 848w, https://substackcdn.com/image/fetch/$s_!Onlo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.png 1272w, https://substackcdn.com/image/fetch/$s_!Onlo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Onlo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.png" width="1456" height="920" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:920,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1732564,&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://newsletter.systemdesign.one/i/188371881?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Onlo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.png 424w, https://substackcdn.com/image/fetch/$s_!Onlo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.png 848w, https://substackcdn.com/image/fetch/$s_!Onlo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.png 1272w, https://substackcdn.com/image/fetch/$s_!Onlo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8e811b7-9ae4-42aa-8690-ab775f7d5058_2218x1402.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 role="img" 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><title></title><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><p><em><strong>Reminder: this is a teaser of the subscriber-only post, exclusive to my golden members.</strong></em></p><p>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>Full access to system design case studies</strong></p></li><li><p>FREE access to (coming) Design, Build, Scale newsletter series</p></li><li><p><strong>FREE access to (coming) popular interview question breakdowns</strong></p></li></ul><p>And more!</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p>
      <p>
          <a href="https://newsletter.systemdesign.one/p/web-crawler-system-design">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Timsort Algorithm - A Deep Dive]]></title><description><![CDATA[#123: The Fastest Real-World Sorting Algorithm]]></description><link>https://newsletter.systemdesign.one/p/timsort-algorithm</link><guid isPermaLink="false">https://newsletter.systemdesign.one/p/timsort-algorithm</guid><dc:creator><![CDATA[Neo Kim]]></dc:creator><pubDate>Thu, 19 Feb 2026 11:20:21 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/911f89b9-13e8-4180-88c9-0125c1c6b654_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/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">Get my system design playbook for FREE on newsletter signup:</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 post outlines Timsort, a popular sorting algorithm known for its speed and efficiency.</p><ul><li><p><em><a href="https://newsletter.systemdesign.one/p/timsort-algorithm/?action=share">Share this post</a> &amp; I'll send you some rewards for the referrals.</em></p></li></ul><div><hr></div><p>Timsort is one of those foundational sorting algorithms used everywhere, but most explanations of how it works shy away from going into its behavior in depth.</p><p>We are going to fix that in this newsletter.</p><p>By the end, not only will you be able to explain how Timsort works at various levels of detail, but you will also see a simplified JavaScript implementation so you can see how the concepts translate into an implementation you can try out on your own computer.</p><p>Let&#8217;s dive in!</p><div><hr></div><h3><strong><a href="https://codenewsletter.ai/subscribe?utm_source=nl_ad_system">Find out why 150K+ engineers read The Code twice a week (Partner)</a></strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://codenewsletter.ai/subscribe?utm_source=nl_ad_system" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!w80U!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 424w, https://substackcdn.com/image/fetch/$s_!w80U!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 848w, https://substackcdn.com/image/fetch/$s_!w80U!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!w80U!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!w80U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg" width="1271" height="699" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:699,&quot;width&quot;:1271,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:303786,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:&quot;https://codenewsletter.ai/subscribe?utm_source=nl_ad_system&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/179236490?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!w80U!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 424w, https://substackcdn.com/image/fetch/$s_!w80U!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 848w, https://substackcdn.com/image/fetch/$s_!w80U!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!w80U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe30ba00c-653e-421b-af50-f5b48536f36b_1271x699.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 role="img" 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><title></title><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>Tech moves fast, but you&#8217;re still playing catch-up?</p><p>That&#8217;s exactly why 150K+ engineers working at Google, Meta, and Apple read <a href="https://codenewsletter.ai/subscribe?utm_source=nl_ad_system">The Code</a> twice a week.</p><p>Here&#8217;s what you get:</p><ul><li><p><strong>Curated tech news that shapes your career </strong>- Filtered from thousands of sources so you know what&#8217;s coming 6 months early.</p></li><li><p><strong>Practical resources you can use immediately</strong> - Real tutorials and tools that solve actual engineering problems.</p></li><li><p><strong>Research papers and insights decoded</strong> - We break down complex tech so you understand what matters.</p></li></ul><p>All delivered twice a week in just 2 short emails.</p><p><strong>Sign up and get access to the Ultimate Claude code guide to ship 5X faster.</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://codenewsletter.ai/subscribe?utm_source=nl_ad_system&quot;,&quot;text&quot;:&quot;Join 150K+ Engineers&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://codenewsletter.ai/subscribe?utm_source=nl_ad_system"><span>Join 150K+ Engineers</span></a></p><p>(Thanks for partnering on this post and sharing the ultimate <a href="https://codenewsletter.ai/subscribe?utm_source=nl_ad_system">claude code guide</a>.)</p><div><hr></div><p>I want to introduce <a href="https://www.kirupa.com">Kirupa Chinnathambi</a>, a connoisseur of explaining hard technical topics in a simple, easy-to-digest way:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://www.kirupa.com" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fHMF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0f4cd89-1974-403d-a8be-18330cefcd10_1600x913.png 424w, https://substackcdn.com/image/fetch/$s_!fHMF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0f4cd89-1974-403d-a8be-18330cefcd10_1600x913.png 848w, https://substackcdn.com/image/fetch/$s_!fHMF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0f4cd89-1974-403d-a8be-18330cefcd10_1600x913.png 1272w, https://substackcdn.com/image/fetch/$s_!fHMF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0f4cd89-1974-403d-a8be-18330cefcd10_1600x913.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fHMF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0f4cd89-1974-403d-a8be-18330cefcd10_1600x913.png" width="1456" height="831" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a0f4cd89-1974-403d-a8be-18330cefcd10_1600x913.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:831,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://www.kirupa.com&quot;,&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="" srcset="https://substackcdn.com/image/fetch/$s_!fHMF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0f4cd89-1974-403d-a8be-18330cefcd10_1600x913.png 424w, https://substackcdn.com/image/fetch/$s_!fHMF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0f4cd89-1974-403d-a8be-18330cefcd10_1600x913.png 848w, https://substackcdn.com/image/fetch/$s_!fHMF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0f4cd89-1974-403d-a8be-18330cefcd10_1600x913.png 1272w, https://substackcdn.com/image/fetch/$s_!fHMF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0f4cd89-1974-403d-a8be-18330cefcd10_1600x913.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 role="img" 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><title></title><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>He has been blogging since 1998 (hello, Geocities!)&nbsp;and has turned this hobby into a way to help hundreds of thousands of people through numerous articles,&nbsp;<a href="https://www.youtube.com/kirupa">videos</a>,&nbsp;<a href="https://forum.kirupa.com">community forum posts</a>,&nbsp;<a href="https://www.kirupa.chat">a&nbsp;popular newsletter</a>, and <a href="https://www.amazon.com/stores/Kirupa-Chinnathambi/author/B001KCY8XW">best-selling books</a>.</p><p>In parallel, he is <a href="https://www.linkedin.com/in/kirupa/">a hands-on Product Manager</a>&nbsp;at Microsoft, working at the intersection of how AI and developers can build great things faster and more securely on Windows.</p><div><hr></div><h2><strong>Introduction</strong></h2><p>When it comes to sorting algorithms, none of them is perfect.</p><p>Take a look at the following table of running times for the sorting algorithms we&#8217;ve seen so far:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iRr9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5536d79-6528-4272-a1b8-28433e5f60cd_1222x710.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iRr9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5536d79-6528-4272-a1b8-28433e5f60cd_1222x710.png 424w, https://substackcdn.com/image/fetch/$s_!iRr9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5536d79-6528-4272-a1b8-28433e5f60cd_1222x710.png 848w, https://substackcdn.com/image/fetch/$s_!iRr9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5536d79-6528-4272-a1b8-28433e5f60cd_1222x710.png 1272w, https://substackcdn.com/image/fetch/$s_!iRr9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5536d79-6528-4272-a1b8-28433e5f60cd_1222x710.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iRr9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5536d79-6528-4272-a1b8-28433e5f60cd_1222x710.png" width="1222" height="710" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d5536d79-6528-4272-a1b8-28433e5f60cd_1222x710.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:710,&quot;width&quot;:1222,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!iRr9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5536d79-6528-4272-a1b8-28433e5f60cd_1222x710.png 424w, https://substackcdn.com/image/fetch/$s_!iRr9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5536d79-6528-4272-a1b8-28433e5f60cd_1222x710.png 848w, https://substackcdn.com/image/fetch/$s_!iRr9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5536d79-6528-4272-a1b8-28433e5f60cd_1222x710.png 1272w, https://substackcdn.com/image/fetch/$s_!iRr9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5536d79-6528-4272-a1b8-28433e5f60cd_1222x710.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 role="img" 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><title></title><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>These sorting algorithms that seem perfect often show really poor behavior in worst-case scenarios. Their best-case performance may be suboptimal, too.</p><p>Take quicksort<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a>, for example.</p><p>Quicksort looks pretty good, right? On average, it runs at a very respectable <strong>O(n log n)</strong> time. Now, what if we ask it to sort a fully sorted collection of values, and our pivot selection is having an off day? In this case, quicksort will slow to a crawl and sort our input with an <strong>O(n&#178;)</strong> time.</p><p>That makes it as bad as some of our slowest sorting algorithms.</p><p>The opposite holds true as well.</p><p>Our slowest sorting algorithms, like Selection Sort, Insertion Sort, or Bubble Sort, have the potential to run really fast. For example, Bubble Sort normally runs at <strong>O(n&#178;)</strong>. If the values we ask it to sort happen to already be sorted, Bubble Sort will sort the values at a blazing fast <strong>O(n)</strong> time.</p><p>That&#8217;s even faster than Quicksort&#8217;s best sorting time:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2GH6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65506452-7321-4bb3-9eb9-a4f5791acefe_1096x1052.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2GH6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65506452-7321-4bb3-9eb9-a4f5791acefe_1096x1052.jpeg 424w, https://substackcdn.com/image/fetch/$s_!2GH6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65506452-7321-4bb3-9eb9-a4f5791acefe_1096x1052.jpeg 848w, https://substackcdn.com/image/fetch/$s_!2GH6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65506452-7321-4bb3-9eb9-a4f5791acefe_1096x1052.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!2GH6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65506452-7321-4bb3-9eb9-a4f5791acefe_1096x1052.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2GH6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65506452-7321-4bb3-9eb9-a4f5791acefe_1096x1052.jpeg" width="1096" height="1052" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/65506452-7321-4bb3-9eb9-a4f5791acefe_1096x1052.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1052,&quot;width&quot;:1096,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!2GH6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65506452-7321-4bb3-9eb9-a4f5791acefe_1096x1052.jpeg 424w, https://substackcdn.com/image/fetch/$s_!2GH6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65506452-7321-4bb3-9eb9-a4f5791acefe_1096x1052.jpeg 848w, https://substackcdn.com/image/fetch/$s_!2GH6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65506452-7321-4bb3-9eb9-a4f5791acefe_1096x1052.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!2GH6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65506452-7321-4bb3-9eb9-a4f5791acefe_1096x1052.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 role="img" 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><title></title><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>How well our sorting algorithms work depends largely on the arrangement of our unsorted input values:</p><ol><li><p>Are the input values random?</p></li><li><p>Are they already sorted?</p></li><li><p>Are they sorted in reverse?</p></li><li><p>Is the range of values inside them large or small?</p></li></ol><p>Based on our answers to these questions, the performance of our sorting algorithms will vary.</p><p>As we described a few seconds ago, seemingly great sorting algorithms will crumble with the wrong arrangement of values, and terrible sorting algorithms will shine on the same arrangement of values.</p><p>So...what can we do here?</p><p>Instead of using a single sorting algorithm for our data, we can choose from a variety of sorting algorithms optimized for the kind of data we are dealing with. We can use something known as a <strong>hybrid sorting algorithm</strong>. A hybrid sorting algorithm takes advantage of the strengths of multiple sorting algorithms to create some sort of a super algorithm&#8230;<a href="https://upload.wikimedia.org/wikipedia/commons/0/09/Tyrannosaurus-rex-Profile-steveoc86.png">like our T-Rex over here</a>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!f0uB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F192c747c-2995-46c8-992c-ba4bb9f33787_1600x727.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!f0uB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F192c747c-2995-46c8-992c-ba4bb9f33787_1600x727.png 424w, https://substackcdn.com/image/fetch/$s_!f0uB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F192c747c-2995-46c8-992c-ba4bb9f33787_1600x727.png 848w, https://substackcdn.com/image/fetch/$s_!f0uB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F192c747c-2995-46c8-992c-ba4bb9f33787_1600x727.png 1272w, https://substackcdn.com/image/fetch/$s_!f0uB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F192c747c-2995-46c8-992c-ba4bb9f33787_1600x727.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!f0uB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F192c747c-2995-46c8-992c-ba4bb9f33787_1600x727.png" width="1456" height="662" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/192c747c-2995-46c8-992c-ba4bb9f33787_1600x727.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:662,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!f0uB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F192c747c-2995-46c8-992c-ba4bb9f33787_1600x727.png 424w, https://substackcdn.com/image/fetch/$s_!f0uB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F192c747c-2995-46c8-992c-ba4bb9f33787_1600x727.png 848w, https://substackcdn.com/image/fetch/$s_!f0uB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F192c747c-2995-46c8-992c-ba4bb9f33787_1600x727.png 1272w, https://substackcdn.com/image/fetch/$s_!f0uB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F192c747c-2995-46c8-992c-ba4bb9f33787_1600x727.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 role="img" 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><title></title><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>By relying on multiple sorting algorithms, we can <strong>minimize the worst-case behavior of individual sorting algorithms</strong> by switching between algorithms based on the characteristics of the unsorted input data being sorted.</p><p>In this newsletter, we are going to learn about one of the greatest hybrid sorting algorithms ever created. We are going to learn about <strong>Timsort</strong>.</p><p>Onward.</p><div><hr></div><div class="captioned-button-wrap" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/timsort-algorithm?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="CaptionedButtonToDOM"><div class="preamble"><p class="cta-caption">Share this post &amp; earn rewards for referrals.</p></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/timsort-algorithm?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/timsort-algorithm?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p></div><div><hr></div><h2>What is Timsort?</h2><blockquote><p>Timsort is a hybrid sorting algorithm that combines the best features of two other sorting algorithms:</p><ul><li><p>Merge sort (where you divide your input, sort, merge recursively),</p></li><li><p>Insertion sort (where you start from a blank output and insert elements into place).</p></li></ul></blockquote><p>The key idea behind Timsort is <strong>to take advantage of the existing order in the data</strong>. It&#8217;s especially efficient for real-world scenarios where the values we&#8217;ll be sorting will often have some pre-existing order or patterns.</p><p>The way Timsort works can be grossly oversimplified as follows:</p><ol><li><p>Divide the data into small chunks</p></li><li><p>Sort these chunks using Insertion sort</p></li><li><p>Merge the sorted chunks using a smart merging strategy found in Merge sort</p></li></ol><p>The best way to make sense of how Timsort works is by walking through an example, so we&#8217;ll do that next.</p><div><hr></div><h2>Walkthrough</h2><p>As with all great sorting algorithm walkthroughs, we&#8217;re going to start with some unsorted data that needs to be sorted:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!m0jS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ebf99c-e853-43b9-a20f-303e0924593b_1169x174.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!m0jS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ebf99c-e853-43b9-a20f-303e0924593b_1169x174.png 424w, https://substackcdn.com/image/fetch/$s_!m0jS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ebf99c-e853-43b9-a20f-303e0924593b_1169x174.png 848w, https://substackcdn.com/image/fetch/$s_!m0jS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ebf99c-e853-43b9-a20f-303e0924593b_1169x174.png 1272w, https://substackcdn.com/image/fetch/$s_!m0jS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ebf99c-e853-43b9-a20f-303e0924593b_1169x174.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!m0jS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ebf99c-e853-43b9-a20f-303e0924593b_1169x174.png" width="1169" height="174" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e5ebf99c-e853-43b9-a20f-303e0924593b_1169x174.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:174,&quot;width&quot;:1169,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!m0jS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ebf99c-e853-43b9-a20f-303e0924593b_1169x174.png 424w, https://substackcdn.com/image/fetch/$s_!m0jS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ebf99c-e853-43b9-a20f-303e0924593b_1169x174.png 848w, https://substackcdn.com/image/fetch/$s_!m0jS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ebf99c-e853-43b9-a20f-303e0924593b_1169x174.png 1272w, https://substackcdn.com/image/fetch/$s_!m0jS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ebf99c-e853-43b9-a20f-303e0924593b_1169x174.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This list of unsorted values is pretty long to help us better appreciate how Timsort works. To help make all of this data easier for us to visualize here, let&#8217;s wrap this long list of data as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lmgp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3f8d5a-f871-41e5-ba51-deab2e94c1f6_1078x407.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lmgp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3f8d5a-f871-41e5-ba51-deab2e94c1f6_1078x407.png 424w, https://substackcdn.com/image/fetch/$s_!lmgp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3f8d5a-f871-41e5-ba51-deab2e94c1f6_1078x407.png 848w, https://substackcdn.com/image/fetch/$s_!lmgp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3f8d5a-f871-41e5-ba51-deab2e94c1f6_1078x407.png 1272w, https://substackcdn.com/image/fetch/$s_!lmgp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3f8d5a-f871-41e5-ba51-deab2e94c1f6_1078x407.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lmgp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3f8d5a-f871-41e5-ba51-deab2e94c1f6_1078x407.png" width="1078" height="407" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1b3f8d5a-f871-41e5-ba51-deab2e94c1f6_1078x407.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:407,&quot;width&quot;:1078,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!lmgp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3f8d5a-f871-41e5-ba51-deab2e94c1f6_1078x407.png 424w, https://substackcdn.com/image/fetch/$s_!lmgp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3f8d5a-f871-41e5-ba51-deab2e94c1f6_1078x407.png 848w, https://substackcdn.com/image/fetch/$s_!lmgp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3f8d5a-f871-41e5-ba51-deab2e94c1f6_1078x407.png 1272w, https://substackcdn.com/image/fetch/$s_!lmgp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3f8d5a-f871-41e5-ba51-deab2e94c1f6_1078x407.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 role="img" 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><title></title><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>Nothing about our data has changed except how we can represent it on this page.</p><p>The first thing we do with Timsort is divide the data we wish to sort into smaller chunks. These chunks are more formally known as <em><strong>runs</strong></em>. The size of these runs usually varies between 32 and 64 items, but for our example, we&#8217;ll keep the size of our runs much smaller at 4:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!o_n9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57a90a0e-fa1e-4a4c-8e61-804dca6a6db1_1078x439.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!o_n9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57a90a0e-fa1e-4a4c-8e61-804dca6a6db1_1078x439.png 424w, https://substackcdn.com/image/fetch/$s_!o_n9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57a90a0e-fa1e-4a4c-8e61-804dca6a6db1_1078x439.png 848w, https://substackcdn.com/image/fetch/$s_!o_n9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57a90a0e-fa1e-4a4c-8e61-804dca6a6db1_1078x439.png 1272w, https://substackcdn.com/image/fetch/$s_!o_n9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57a90a0e-fa1e-4a4c-8e61-804dca6a6db1_1078x439.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!o_n9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57a90a0e-fa1e-4a4c-8e61-804dca6a6db1_1078x439.png" width="1078" height="439" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/57a90a0e-fa1e-4a4c-8e61-804dca6a6db1_1078x439.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:439,&quot;width&quot;:1078,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!o_n9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57a90a0e-fa1e-4a4c-8e61-804dca6a6db1_1078x439.png 424w, https://substackcdn.com/image/fetch/$s_!o_n9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57a90a0e-fa1e-4a4c-8e61-804dca6a6db1_1078x439.png 848w, https://substackcdn.com/image/fetch/$s_!o_n9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57a90a0e-fa1e-4a4c-8e61-804dca6a6db1_1078x439.png 1272w, https://substackcdn.com/image/fetch/$s_!o_n9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57a90a0e-fa1e-4a4c-8e61-804dca6a6db1_1078x439.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 role="img" 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><title></title><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>Notice that we divided our entire unsorted collection into runs of four items each, except for the last run, which only has two values.</p><h3>Sorting with Insertion Sort</h3><p>Now that we have our runs, <strong>we apply insertion sort</strong> on each run to sort these values. We sort our first run:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rltF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35359dcb-aede-47bd-8a14-53e3e8d5c9f2_1078x533.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rltF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35359dcb-aede-47bd-8a14-53e3e8d5c9f2_1078x533.png 424w, https://substackcdn.com/image/fetch/$s_!rltF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35359dcb-aede-47bd-8a14-53e3e8d5c9f2_1078x533.png 848w, https://substackcdn.com/image/fetch/$s_!rltF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35359dcb-aede-47bd-8a14-53e3e8d5c9f2_1078x533.png 1272w, https://substackcdn.com/image/fetch/$s_!rltF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35359dcb-aede-47bd-8a14-53e3e8d5c9f2_1078x533.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rltF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35359dcb-aede-47bd-8a14-53e3e8d5c9f2_1078x533.png" width="1078" height="533" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/35359dcb-aede-47bd-8a14-53e3e8d5c9f2_1078x533.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:533,&quot;width&quot;:1078,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!rltF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35359dcb-aede-47bd-8a14-53e3e8d5c9f2_1078x533.png 424w, https://substackcdn.com/image/fetch/$s_!rltF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35359dcb-aede-47bd-8a14-53e3e8d5c9f2_1078x533.png 848w, https://substackcdn.com/image/fetch/$s_!rltF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35359dcb-aede-47bd-8a14-53e3e8d5c9f2_1078x533.png 1272w, https://substackcdn.com/image/fetch/$s_!rltF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35359dcb-aede-47bd-8a14-53e3e8d5c9f2_1078x533.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 role="img" 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><title></title><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>Next, we sort our second run:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Z6VZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F812005d2-7105-456c-96f8-5b6a495c8046_1078x533.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Z6VZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F812005d2-7105-456c-96f8-5b6a495c8046_1078x533.png 424w, https://substackcdn.com/image/fetch/$s_!Z6VZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F812005d2-7105-456c-96f8-5b6a495c8046_1078x533.png 848w, https://substackcdn.com/image/fetch/$s_!Z6VZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F812005d2-7105-456c-96f8-5b6a495c8046_1078x533.png 1272w, https://substackcdn.com/image/fetch/$s_!Z6VZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F812005d2-7105-456c-96f8-5b6a495c8046_1078x533.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Z6VZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F812005d2-7105-456c-96f8-5b6a495c8046_1078x533.png" width="1078" height="533" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/812005d2-7105-456c-96f8-5b6a495c8046_1078x533.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:533,&quot;width&quot;:1078,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!Z6VZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F812005d2-7105-456c-96f8-5b6a495c8046_1078x533.png 424w, https://substackcdn.com/image/fetch/$s_!Z6VZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F812005d2-7105-456c-96f8-5b6a495c8046_1078x533.png 848w, https://substackcdn.com/image/fetch/$s_!Z6VZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F812005d2-7105-456c-96f8-5b6a495c8046_1078x533.png 1272w, https://substackcdn.com/image/fetch/$s_!Z6VZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F812005d2-7105-456c-96f8-5b6a495c8046_1078x533.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 role="img" 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><title></title><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 sorting repeats until all of our individual runs are sorted:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ejCR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46a5be24-c9bd-46ca-9702-9b441fe36031_1078x439.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ejCR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46a5be24-c9bd-46ca-9702-9b441fe36031_1078x439.png 424w, https://substackcdn.com/image/fetch/$s_!ejCR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46a5be24-c9bd-46ca-9702-9b441fe36031_1078x439.png 848w, https://substackcdn.com/image/fetch/$s_!ejCR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46a5be24-c9bd-46ca-9702-9b441fe36031_1078x439.png 1272w, https://substackcdn.com/image/fetch/$s_!ejCR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46a5be24-c9bd-46ca-9702-9b441fe36031_1078x439.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ejCR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46a5be24-c9bd-46ca-9702-9b441fe36031_1078x439.png" width="1078" height="439" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/46a5be24-c9bd-46ca-9702-9b441fe36031_1078x439.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:439,&quot;width&quot;:1078,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!ejCR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46a5be24-c9bd-46ca-9702-9b441fe36031_1078x439.png 424w, https://substackcdn.com/image/fetch/$s_!ejCR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46a5be24-c9bd-46ca-9702-9b441fe36031_1078x439.png 848w, https://substackcdn.com/image/fetch/$s_!ejCR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46a5be24-c9bd-46ca-9702-9b441fe36031_1078x439.png 1272w, https://substackcdn.com/image/fetch/$s_!ejCR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46a5be24-c9bd-46ca-9702-9b441fe36031_1078x439.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 role="img" 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><title></title><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>An important detail is that only the values within each run are sorted.</p><p>In aggregate, our collection of items is still unsorted. We will address that next.</p><h3>Merging Runs</h3><p>The final step is to take our individually sorted runs and merge them into larger and larger sorted runs. At the end of all this, the result will be one combined sorted collection of data.</p><p>We start by merging adjacent runs together, and I have color-coded the adjacent runs that will be merged first:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!aa8r!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F843efce7-68d1-4a27-85fc-bac0b3a4ce95_1078x439.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!aa8r!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F843efce7-68d1-4a27-85fc-bac0b3a4ce95_1078x439.png 424w, https://substackcdn.com/image/fetch/$s_!aa8r!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F843efce7-68d1-4a27-85fc-bac0b3a4ce95_1078x439.png 848w, https://substackcdn.com/image/fetch/$s_!aa8r!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F843efce7-68d1-4a27-85fc-bac0b3a4ce95_1078x439.png 1272w, https://substackcdn.com/image/fetch/$s_!aa8r!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F843efce7-68d1-4a27-85fc-bac0b3a4ce95_1078x439.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!aa8r!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F843efce7-68d1-4a27-85fc-bac0b3a4ce95_1078x439.png" width="1078" height="439" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/843efce7-68d1-4a27-85fc-bac0b3a4ce95_1078x439.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:439,&quot;width&quot;:1078,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!aa8r!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F843efce7-68d1-4a27-85fc-bac0b3a4ce95_1078x439.png 424w, https://substackcdn.com/image/fetch/$s_!aa8r!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F843efce7-68d1-4a27-85fc-bac0b3a4ce95_1078x439.png 848w, https://substackcdn.com/image/fetch/$s_!aa8r!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F843efce7-68d1-4a27-85fc-bac0b3a4ce95_1078x439.png 1272w, https://substackcdn.com/image/fetch/$s_!aa8r!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F843efce7-68d1-4a27-85fc-bac0b3a4ce95_1078x439.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 role="img" 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><title></title><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 merging operation will use a subset of merge sort&#8217;s capabilities, where we need to merge the individually sorted runs into a final sorted order.</p><p>After the first round of merging, our collection will look as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HtID!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74b5bf2a-4d8a-41c4-b866-59668a441d97_1078x407.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HtID!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74b5bf2a-4d8a-41c4-b866-59668a441d97_1078x407.png 424w, https://substackcdn.com/image/fetch/$s_!HtID!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74b5bf2a-4d8a-41c4-b866-59668a441d97_1078x407.png 848w, https://substackcdn.com/image/fetch/$s_!HtID!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74b5bf2a-4d8a-41c4-b866-59668a441d97_1078x407.png 1272w, https://substackcdn.com/image/fetch/$s_!HtID!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74b5bf2a-4d8a-41c4-b866-59668a441d97_1078x407.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HtID!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74b5bf2a-4d8a-41c4-b866-59668a441d97_1078x407.png" width="1078" height="407" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/74b5bf2a-4d8a-41c4-b866-59668a441d97_1078x407.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:407,&quot;width&quot;:1078,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!HtID!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74b5bf2a-4d8a-41c4-b866-59668a441d97_1078x407.png 424w, https://substackcdn.com/image/fetch/$s_!HtID!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74b5bf2a-4d8a-41c4-b866-59668a441d97_1078x407.png 848w, https://substackcdn.com/image/fetch/$s_!HtID!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74b5bf2a-4d8a-41c4-b866-59668a441d97_1078x407.png 1272w, https://substackcdn.com/image/fetch/$s_!HtID!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74b5bf2a-4d8a-41c4-b866-59668a441d97_1078x407.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 role="img" 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><title></title><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>Our runs are now around double in size. We now repeat the process by merging adjacent runs again. After this round of merging, we will be left with two sorted runs:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-XZc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b50739d-29e7-4cec-85c4-163683730706_1078x407.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-XZc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b50739d-29e7-4cec-85c4-163683730706_1078x407.png 424w, https://substackcdn.com/image/fetch/$s_!-XZc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b50739d-29e7-4cec-85c4-163683730706_1078x407.png 848w, https://substackcdn.com/image/fetch/$s_!-XZc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b50739d-29e7-4cec-85c4-163683730706_1078x407.png 1272w, https://substackcdn.com/image/fetch/$s_!-XZc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b50739d-29e7-4cec-85c4-163683730706_1078x407.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-XZc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b50739d-29e7-4cec-85c4-163683730706_1078x407.png" width="1078" height="407" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9b50739d-29e7-4cec-85c4-163683730706_1078x407.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:407,&quot;width&quot;:1078,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!-XZc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b50739d-29e7-4cec-85c4-163683730706_1078x407.png 424w, https://substackcdn.com/image/fetch/$s_!-XZc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b50739d-29e7-4cec-85c4-163683730706_1078x407.png 848w, https://substackcdn.com/image/fetch/$s_!-XZc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b50739d-29e7-4cec-85c4-163683730706_1078x407.png 1272w, https://substackcdn.com/image/fetch/$s_!-XZc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b50739d-29e7-4cec-85c4-163683730706_1078x407.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 role="img" 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><title></title><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>We are almost done here. All that remains is one last step, where we merge our two unsorted runs to create our sorted output:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RAds!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77fe7c3f-52cb-4fad-bd87-bebd77cc3724_1078x407.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RAds!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77fe7c3f-52cb-4fad-bd87-bebd77cc3724_1078x407.png 424w, https://substackcdn.com/image/fetch/$s_!RAds!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77fe7c3f-52cb-4fad-bd87-bebd77cc3724_1078x407.png 848w, https://substackcdn.com/image/fetch/$s_!RAds!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77fe7c3f-52cb-4fad-bd87-bebd77cc3724_1078x407.png 1272w, https://substackcdn.com/image/fetch/$s_!RAds!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77fe7c3f-52cb-4fad-bd87-bebd77cc3724_1078x407.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RAds!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77fe7c3f-52cb-4fad-bd87-bebd77cc3724_1078x407.png" width="1078" height="407" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/77fe7c3f-52cb-4fad-bd87-bebd77cc3724_1078x407.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:407,&quot;width&quot;:1078,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!RAds!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77fe7c3f-52cb-4fad-bd87-bebd77cc3724_1078x407.png 424w, https://substackcdn.com/image/fetch/$s_!RAds!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77fe7c3f-52cb-4fad-bd87-bebd77cc3724_1078x407.png 848w, https://substackcdn.com/image/fetch/$s_!RAds!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77fe7c3f-52cb-4fad-bd87-bebd77cc3724_1078x407.png 1272w, https://substackcdn.com/image/fetch/$s_!RAds!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77fe7c3f-52cb-4fad-bd87-bebd77cc3724_1078x407.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 role="img" 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><title></title><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 this moment, no further runs need to be merged.</p><p>Timsort is finished sorting our data. Also, at this very moment, you probably have many questions about what exactly happened to make Timsort seem like a superior sorting algorithm to most other sorting algorithms out there.</p><p>We&#8217;ll address that next.</p><div><hr></div><div class="captioned-button-wrap" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/timsort-algorithm?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="CaptionedButtonToDOM"><div class="preamble"><p class="cta-caption">Share this post &amp; earn rewards for referrals.</p></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/timsort-algorithm?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/timsort-algorithm?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p></div><div><hr></div><h2>Optimizations</h2><p>The above walkthrough highlighted how we can use Timsort to sort our unsorted collection of numbers.</p><p>We broke our larger input into runs, sorted each run using insertion sort, and then merged adjacent runs until we had a single fully sorted run.</p><p>If we analyzed our walkthrough at face value, Timsort&#8217;s performance may not seem very fast when we have n items, n<sup>2</sup> running time for insertion sort, and a logarithmic running time for merging values. This is where some optimizations Timsort is known for kick in&#8230;dramatically speeding things up in many cases.</p><p>These optimizations focus on detecting common patterns in our data and customizing next steps based on how the data is structured.</p><h3>Detecting Ascending and Descending Runs</h3><p>The worst-case running time for insertion sort occurs when the values to be sorted are in reverse order.</p><p>To avoid this, Timsort will try to identify runs that are strictly in reverse (aka descending) order and do an in-place reverse on them first before attempting to sort and merge them:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IXH-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae72dc3-9e36-4c0c-8225-d61e9b12401f_885x772.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IXH-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae72dc3-9e36-4c0c-8225-d61e9b12401f_885x772.png 424w, https://substackcdn.com/image/fetch/$s_!IXH-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae72dc3-9e36-4c0c-8225-d61e9b12401f_885x772.png 848w, https://substackcdn.com/image/fetch/$s_!IXH-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae72dc3-9e36-4c0c-8225-d61e9b12401f_885x772.png 1272w, https://substackcdn.com/image/fetch/$s_!IXH-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae72dc3-9e36-4c0c-8225-d61e9b12401f_885x772.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IXH-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae72dc3-9e36-4c0c-8225-d61e9b12401f_885x772.png" width="885" height="772" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aae72dc3-9e36-4c0c-8225-d61e9b12401f_885x772.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:772,&quot;width&quot;:885,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!IXH-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae72dc3-9e36-4c0c-8225-d61e9b12401f_885x772.png 424w, https://substackcdn.com/image/fetch/$s_!IXH-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae72dc3-9e36-4c0c-8225-d61e9b12401f_885x772.png 848w, https://substackcdn.com/image/fetch/$s_!IXH-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae72dc3-9e36-4c0c-8225-d61e9b12401f_885x772.png 1272w, https://substackcdn.com/image/fetch/$s_!IXH-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae72dc3-9e36-4c0c-8225-d61e9b12401f_885x772.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 role="img" 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><title></title><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 best-case performance of insertion sort occurs when the runs are in ascending order.</p><p>In these cases, <strong>the runs are left as-is</strong>. There is no need to sort them. The only real work Timsort will need to perform is merging, which is consistently fast.</p><h3>Galloping Mode and Already Sorted Runs</h3><p>Galloping mode (also known as <em><strong>binary search insertion</strong></em> by distant friends and relatives) is an optimization technique used in Timsort algorithm <strong>during the merging phase</strong>. It&#8217;s designed to handle cases where a run has many elements that are already in their final sorted position relative to the other run.</p><p>Here&#8217;s how it works:</p><ol><li><p>During merging, if Timsort notices that many consecutive elements from one run are being chosen, it switches to galloping mode.</p></li><li><p>In galloping mode, instead of comparing elements one by one, Timsort jumps (or &#8220;gallops&#8221;) over multiple elements at a time, making the merging faster</p></li><li><p>This can significantly reduce the number of comparisons needed when merging runs that are already partially ordered relative to each other.</p></li></ol><p>This will make more sense with an example, so here are two sorted runs we would like to merge:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nYJ_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3682d308-215a-4c44-b38e-96e6d40c1f7d_872x255.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nYJ_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3682d308-215a-4c44-b38e-96e6d40c1f7d_872x255.png 424w, https://substackcdn.com/image/fetch/$s_!nYJ_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3682d308-215a-4c44-b38e-96e6d40c1f7d_872x255.png 848w, https://substackcdn.com/image/fetch/$s_!nYJ_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3682d308-215a-4c44-b38e-96e6d40c1f7d_872x255.png 1272w, https://substackcdn.com/image/fetch/$s_!nYJ_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3682d308-215a-4c44-b38e-96e6d40c1f7d_872x255.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nYJ_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3682d308-215a-4c44-b38e-96e6d40c1f7d_872x255.png" width="872" height="255" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3682d308-215a-4c44-b38e-96e6d40c1f7d_872x255.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:255,&quot;width&quot;:872,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!nYJ_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3682d308-215a-4c44-b38e-96e6d40c1f7d_872x255.png 424w, https://substackcdn.com/image/fetch/$s_!nYJ_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3682d308-215a-4c44-b38e-96e6d40c1f7d_872x255.png 848w, https://substackcdn.com/image/fetch/$s_!nYJ_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3682d308-215a-4c44-b38e-96e6d40c1f7d_872x255.png 1272w, https://substackcdn.com/image/fetch/$s_!nYJ_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3682d308-215a-4c44-b38e-96e6d40c1f7d_872x255.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 role="img" 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><title></title><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 an unoptimized merge, we would compare each element between both runs and add the smaller of the values to our merged collection.</p><p>When we look at the values in Run A, we can see that the first five numbers are all consistently less than the first value in Run B. If we elaborate on that using a loose array-like syntax, we have:</p><ul><li><p>Compare RunA[0] (1) with RunB[0] (10): 1 is smaller, so 1 is added to the merged collection.</p></li><li><p>Compare RunA[1] (2) with RunB[0] (10): 2 is smaller, so 2 is added to the merged collection.</p></li><li><p>Compare RunA[2] (3) with RunB[0] (10): 3 is smaller, so 3 is added to the merged collection.</p></li><li><p>Compare RunA[3] (4) with RunB[0] (10): 4 is smaller, so 4 is added to the merged collection.</p></li><li><p>Compare RunA[4] (5) with RunB[0] (10): 5 is smaller, so 5 is added to the merged collection.</p></li></ul><p>At this point, our merged collection looks as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cNEK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a3ae8d5-ad5d-4f4f-8b8a-01e023058a3a_888x423.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cNEK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a3ae8d5-ad5d-4f4f-8b8a-01e023058a3a_888x423.png 424w, https://substackcdn.com/image/fetch/$s_!cNEK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a3ae8d5-ad5d-4f4f-8b8a-01e023058a3a_888x423.png 848w, https://substackcdn.com/image/fetch/$s_!cNEK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a3ae8d5-ad5d-4f4f-8b8a-01e023058a3a_888x423.png 1272w, https://substackcdn.com/image/fetch/$s_!cNEK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a3ae8d5-ad5d-4f4f-8b8a-01e023058a3a_888x423.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cNEK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a3ae8d5-ad5d-4f4f-8b8a-01e023058a3a_888x423.png" width="888" height="423" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0a3ae8d5-ad5d-4f4f-8b8a-01e023058a3a_888x423.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:423,&quot;width&quot;:888,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!cNEK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a3ae8d5-ad5d-4f4f-8b8a-01e023058a3a_888x423.png 424w, https://substackcdn.com/image/fetch/$s_!cNEK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a3ae8d5-ad5d-4f4f-8b8a-01e023058a3a_888x423.png 848w, https://substackcdn.com/image/fetch/$s_!cNEK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a3ae8d5-ad5d-4f4f-8b8a-01e023058a3a_888x423.png 1272w, https://substackcdn.com/image/fetch/$s_!cNEK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a3ae8d5-ad5d-4f4f-8b8a-01e023058a3a_888x423.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 role="img" 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><title></title><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>Now, Timsort will compare RunA[5] (31) with RunB[0] (10):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NCXQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e087b53-8ea3-4f3f-8276-9c14fcd622da_888x423.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NCXQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e087b53-8ea3-4f3f-8276-9c14fcd622da_888x423.png 424w, https://substackcdn.com/image/fetch/$s_!NCXQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e087b53-8ea3-4f3f-8276-9c14fcd622da_888x423.png 848w, https://substackcdn.com/image/fetch/$s_!NCXQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e087b53-8ea3-4f3f-8276-9c14fcd622da_888x423.png 1272w, https://substackcdn.com/image/fetch/$s_!NCXQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e087b53-8ea3-4f3f-8276-9c14fcd622da_888x423.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NCXQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e087b53-8ea3-4f3f-8276-9c14fcd622da_888x423.png" width="888" height="423" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3e087b53-8ea3-4f3f-8276-9c14fcd622da_888x423.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:423,&quot;width&quot;:888,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!NCXQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e087b53-8ea3-4f3f-8276-9c14fcd622da_888x423.png 424w, https://substackcdn.com/image/fetch/$s_!NCXQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e087b53-8ea3-4f3f-8276-9c14fcd622da_888x423.png 848w, https://substackcdn.com/image/fetch/$s_!NCXQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e087b53-8ea3-4f3f-8276-9c14fcd622da_888x423.png 1272w, https://substackcdn.com/image/fetch/$s_!NCXQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e087b53-8ea3-4f3f-8276-9c14fcd622da_888x423.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 role="img" 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><title></title><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 this point, 10 is smaller than 31, so Timsort will now check the next few elements from Run B to see if they should be added in bulk:</p><ul><li><p>Compare RunA[5] (31) with RunB[1] (11): 11 is smaller, so Timsort continues.</p></li><li><p>Compare RunA[5] (20) with RunB[2] (12): 12 is smaller, so Timsort continues.</p></li><li><p>Compare RunA[5] (20) with RunB[3] (14): 14 is smaller, so Timsort continues.</p></li><li><p>Compare RunA[5] (20) with RunB[4] (16): 16 is smaller, so Timsort continues.</p></li><li><p>Compare RunA[5] (20) with RunB[5] (17): 17 is smaller, so Timsort continues.</p></li><li><p>Compare RunA[5] (20) with RunB[6] (18): 18 is smaller, so Timsort continues.</p></li></ul><p>Since all elements in Run B are smaller than RunA[5], Timsort <strong>adds them all at once</strong> to the merged collection:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Itir!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00297836-84cf-4947-9c3c-1df30f9a2414_1386x423.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Itir!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00297836-84cf-4947-9c3c-1df30f9a2414_1386x423.png 424w, https://substackcdn.com/image/fetch/$s_!Itir!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00297836-84cf-4947-9c3c-1df30f9a2414_1386x423.png 848w, https://substackcdn.com/image/fetch/$s_!Itir!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00297836-84cf-4947-9c3c-1df30f9a2414_1386x423.png 1272w, https://substackcdn.com/image/fetch/$s_!Itir!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00297836-84cf-4947-9c3c-1df30f9a2414_1386x423.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Itir!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00297836-84cf-4947-9c3c-1df30f9a2414_1386x423.png" width="1386" height="423" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/00297836-84cf-4947-9c3c-1df30f9a2414_1386x423.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:423,&quot;width&quot;:1386,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!Itir!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00297836-84cf-4947-9c3c-1df30f9a2414_1386x423.png 424w, https://substackcdn.com/image/fetch/$s_!Itir!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00297836-84cf-4947-9c3c-1df30f9a2414_1386x423.png 848w, https://substackcdn.com/image/fetch/$s_!Itir!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00297836-84cf-4947-9c3c-1df30f9a2414_1386x423.png 1272w, https://substackcdn.com/image/fetch/$s_!Itir!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00297836-84cf-4947-9c3c-1df30f9a2414_1386x423.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 role="img" 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><title></title><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>After adding all the elements from Run B, Timsort reverts to the regular comparison mode and continues merging the remaining items. In this case, both 31 and 48 from Run A will be added to the end of the merged collection.</p><p>By using galloping mode, Timsort can speed up merging by quickly adding multiple consecutive elements from one run when it&#8217;s clear they are all smaller (or larger) than the next element in the other run.</p><p>This reduces the number of comparisons and overall sorting time, especially when merging runs of significantly different sizes.</p><h3>Adaptive Merging</h3><p>Timsort&#8217;s merging strategy is adaptive, meaning it can vary the merging order based on the sizes of the runs. The goal is to maintain balance among the runs and avoid having a single, large run at the end that would make the final merge costly.</p><p>For example, let&#8217;s say these are the runs we are dealing with:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!D0ei!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe10d8756-f520-46b7-b94a-956cc66614a3_656x556.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!D0ei!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe10d8756-f520-46b7-b94a-956cc66614a3_656x556.png 424w, https://substackcdn.com/image/fetch/$s_!D0ei!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe10d8756-f520-46b7-b94a-956cc66614a3_656x556.png 848w, https://substackcdn.com/image/fetch/$s_!D0ei!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe10d8756-f520-46b7-b94a-956cc66614a3_656x556.png 1272w, https://substackcdn.com/image/fetch/$s_!D0ei!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe10d8756-f520-46b7-b94a-956cc66614a3_656x556.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!D0ei!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe10d8756-f520-46b7-b94a-956cc66614a3_656x556.png" width="656" height="556" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e10d8756-f520-46b7-b94a-956cc66614a3_656x556.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:556,&quot;width&quot;:656,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!D0ei!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe10d8756-f520-46b7-b94a-956cc66614a3_656x556.png 424w, https://substackcdn.com/image/fetch/$s_!D0ei!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe10d8756-f520-46b7-b94a-956cc66614a3_656x556.png 848w, https://substackcdn.com/image/fetch/$s_!D0ei!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe10d8756-f520-46b7-b94a-956cc66614a3_656x556.png 1272w, https://substackcdn.com/image/fetch/$s_!D0ei!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe10d8756-f520-46b7-b94a-956cc66614a3_656x556.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 role="img" 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><title></title><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 actual values of the runs aren&#8217;t important.</p><p>What is important is the size of the runs. To avoid any run from being too large and making the merge waaaaay unbalanced, we start by merging the two smallest runs:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vssW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e3f01b-2b87-4818-8a61-eb25f9ecec4a_804x556.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vssW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e3f01b-2b87-4818-8a61-eb25f9ecec4a_804x556.png 424w, https://substackcdn.com/image/fetch/$s_!vssW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e3f01b-2b87-4818-8a61-eb25f9ecec4a_804x556.png 848w, https://substackcdn.com/image/fetch/$s_!vssW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e3f01b-2b87-4818-8a61-eb25f9ecec4a_804x556.png 1272w, https://substackcdn.com/image/fetch/$s_!vssW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e3f01b-2b87-4818-8a61-eb25f9ecec4a_804x556.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vssW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e3f01b-2b87-4818-8a61-eb25f9ecec4a_804x556.png" width="804" height="556" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/89e3f01b-2b87-4818-8a61-eb25f9ecec4a_804x556.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:556,&quot;width&quot;:804,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!vssW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e3f01b-2b87-4818-8a61-eb25f9ecec4a_804x556.png 424w, https://substackcdn.com/image/fetch/$s_!vssW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e3f01b-2b87-4818-8a61-eb25f9ecec4a_804x556.png 848w, https://substackcdn.com/image/fetch/$s_!vssW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e3f01b-2b87-4818-8a61-eb25f9ecec4a_804x556.png 1272w, https://substackcdn.com/image/fetch/$s_!vssW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e3f01b-2b87-4818-8a61-eb25f9ecec4a_804x556.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 role="img" 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><title></title><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 would result in Runs C and D merging to create Run CD:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qFSd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd289c60-a306-4f28-b699-c0c887ffdbc6_670x396.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qFSd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd289c60-a306-4f28-b699-c0c887ffdbc6_670x396.png 424w, https://substackcdn.com/image/fetch/$s_!qFSd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd289c60-a306-4f28-b699-c0c887ffdbc6_670x396.png 848w, https://substackcdn.com/image/fetch/$s_!qFSd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd289c60-a306-4f28-b699-c0c887ffdbc6_670x396.png 1272w, https://substackcdn.com/image/fetch/$s_!qFSd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd289c60-a306-4f28-b699-c0c887ffdbc6_670x396.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qFSd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd289c60-a306-4f28-b699-c0c887ffdbc6_670x396.png" width="670" height="396" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fd289c60-a306-4f28-b699-c0c887ffdbc6_670x396.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:396,&quot;width&quot;:670,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!qFSd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd289c60-a306-4f28-b699-c0c887ffdbc6_670x396.png 424w, https://substackcdn.com/image/fetch/$s_!qFSd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd289c60-a306-4f28-b699-c0c887ffdbc6_670x396.png 848w, https://substackcdn.com/image/fetch/$s_!qFSd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd289c60-a306-4f28-b699-c0c887ffdbc6_670x396.png 1272w, https://substackcdn.com/image/fetch/$s_!qFSd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd289c60-a306-4f28-b699-c0c887ffdbc6_670x396.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 role="img" 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><title></title><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 process continues to ensure that the smallest runs are merged into a final merge pair with similar sizes.</p><h3>Insertion Sort All the Way for Smaller Inputs</h3><p>Yes, insertion sort is a slow sorting algorithm.</p><p>When sorting a small number of values, though, this slowness isn&#8217;t very noticeable. This is especially true in a world where our computers can process millions and billions (and trillions?) of operations a second.</p><p>For this reason, Timsort will often fall back to using plain old insertion sort when the size of the input it is trying to sort is less than the run size threshold, which is usually 32 or 64 items in length:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!axD8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e84bc36-c984-4289-9e37-5ce3226dee75_969x924.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!axD8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e84bc36-c984-4289-9e37-5ce3226dee75_969x924.png 424w, https://substackcdn.com/image/fetch/$s_!axD8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e84bc36-c984-4289-9e37-5ce3226dee75_969x924.png 848w, https://substackcdn.com/image/fetch/$s_!axD8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e84bc36-c984-4289-9e37-5ce3226dee75_969x924.png 1272w, https://substackcdn.com/image/fetch/$s_!axD8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e84bc36-c984-4289-9e37-5ce3226dee75_969x924.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!axD8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e84bc36-c984-4289-9e37-5ce3226dee75_969x924.png" width="969" height="924" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e84bc36-c984-4289-9e37-5ce3226dee75_969x924.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:924,&quot;width&quot;:969,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!axD8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e84bc36-c984-4289-9e37-5ce3226dee75_969x924.png 424w, https://substackcdn.com/image/fetch/$s_!axD8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e84bc36-c984-4289-9e37-5ce3226dee75_969x924.png 848w, https://substackcdn.com/image/fetch/$s_!axD8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e84bc36-c984-4289-9e37-5ce3226dee75_969x924.png 1272w, https://substackcdn.com/image/fetch/$s_!axD8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e84bc36-c984-4289-9e37-5ce3226dee75_969x924.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 role="img" 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><title></title><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 avoids the added overhead of the merging operation, breaking runs, and so on.</p><h3>Tying it All Together</h3><p>Why is Timsort so efficient?</p><p>It&#8217;s because it tries to detect patterns in the sorted data and special-case the sorting behavior accordingly. Whether by identifying natural runs, detecting reversed runs, using galloping mode to avoid unnecessary merging-related work, enforcing minimum run lengths, or performing adaptive merges, Timsort seeks the most efficient path whenever possible.</p><p>A subtle but important detail is that these pattern matching optimizations ensure that Timsort performs well on&nbsp;<em><strong>partially sorted</strong></em>&nbsp;data, which is the most common type&nbsp;we will encounter in the real world.</p><div><hr></div><h2>Performance Characteristics</h2><p>Timsort is one of the best sorting algorithms out there, and we can see it live up to its grandness when we summarize its time and memory complexity below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GLi7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd146d73d-b6b3-4252-ba3a-3298b1f9f50c_1262x346.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GLi7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd146d73d-b6b3-4252-ba3a-3298b1f9f50c_1262x346.png 424w, https://substackcdn.com/image/fetch/$s_!GLi7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd146d73d-b6b3-4252-ba3a-3298b1f9f50c_1262x346.png 848w, https://substackcdn.com/image/fetch/$s_!GLi7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd146d73d-b6b3-4252-ba3a-3298b1f9f50c_1262x346.png 1272w, https://substackcdn.com/image/fetch/$s_!GLi7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd146d73d-b6b3-4252-ba3a-3298b1f9f50c_1262x346.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GLi7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd146d73d-b6b3-4252-ba3a-3298b1f9f50c_1262x346.png" width="1262" height="346" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d146d73d-b6b3-4252-ba3a-3298b1f9f50c_1262x346.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:346,&quot;width&quot;:1262,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!GLi7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd146d73d-b6b3-4252-ba3a-3298b1f9f50c_1262x346.png 424w, https://substackcdn.com/image/fetch/$s_!GLi7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd146d73d-b6b3-4252-ba3a-3298b1f9f50c_1262x346.png 848w, https://substackcdn.com/image/fetch/$s_!GLi7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd146d73d-b6b3-4252-ba3a-3298b1f9f50c_1262x346.png 1272w, https://substackcdn.com/image/fetch/$s_!GLi7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd146d73d-b6b3-4252-ba3a-3298b1f9f50c_1262x346.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 role="img" 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><title></title><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 its best, Timsort can run in linear time.</p><p>This happens when the data is already sorted or nearly sorted as part of a few large runs, and we know that Insertion Sort runs in linear time for sorted data:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5h7d!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbc59d2-2606-47eb-847e-7ad076bbf5d1_1047x1600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5h7d!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbc59d2-2606-47eb-847e-7ad076bbf5d1_1047x1600.png 424w, https://substackcdn.com/image/fetch/$s_!5h7d!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbc59d2-2606-47eb-847e-7ad076bbf5d1_1047x1600.png 848w, https://substackcdn.com/image/fetch/$s_!5h7d!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbc59d2-2606-47eb-847e-7ad076bbf5d1_1047x1600.png 1272w, https://substackcdn.com/image/fetch/$s_!5h7d!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbc59d2-2606-47eb-847e-7ad076bbf5d1_1047x1600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5h7d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbc59d2-2606-47eb-847e-7ad076bbf5d1_1047x1600.png" width="1047" height="1600" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3cbc59d2-2606-47eb-847e-7ad076bbf5d1_1047x1600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1600,&quot;width&quot;:1047,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!5h7d!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbc59d2-2606-47eb-847e-7ad076bbf5d1_1047x1600.png 424w, https://substackcdn.com/image/fetch/$s_!5h7d!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbc59d2-2606-47eb-847e-7ad076bbf5d1_1047x1600.png 848w, https://substackcdn.com/image/fetch/$s_!5h7d!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbc59d2-2606-47eb-847e-7ad076bbf5d1_1047x1600.png 1272w, https://substackcdn.com/image/fetch/$s_!5h7d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbc59d2-2606-47eb-847e-7ad076bbf5d1_1047x1600.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 role="img" 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><title></title><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>Merging runs is a fast operation as well, and if we throw in any optimizations, such as galloping mode if the range of sorted numbers doesn&#8217;t overlap, the merging is almost a trivial operation.</p><p>In the average and worst cases, Timsort runs at <strong>O(n log n)</strong>.</p><p>The bulk of the complexity here goes into identifying runs and merging them. This puts its performance on par with Quicksort&#8217;s average performance, but Timsort&#8217;s optimizations give it an edge as being a <em><strong>faster</strong></em> <strong>O(n log n)</strong>!</p><p>This is validated by benchmarks <a href="https://v8.dev/blog/array-sort">such as the following</a> that compares Timsort with Quicksort on partially sorted data:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QoMd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50155d7d-0996-46cb-a074-6630c751dbfc_1600x994.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QoMd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50155d7d-0996-46cb-a074-6630c751dbfc_1600x994.png 424w, https://substackcdn.com/image/fetch/$s_!QoMd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50155d7d-0996-46cb-a074-6630c751dbfc_1600x994.png 848w, https://substackcdn.com/image/fetch/$s_!QoMd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50155d7d-0996-46cb-a074-6630c751dbfc_1600x994.png 1272w, https://substackcdn.com/image/fetch/$s_!QoMd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50155d7d-0996-46cb-a074-6630c751dbfc_1600x994.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QoMd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50155d7d-0996-46cb-a074-6630c751dbfc_1600x994.png" width="1456" height="905" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/50155d7d-0996-46cb-a074-6630c751dbfc_1600x994.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:905,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!QoMd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50155d7d-0996-46cb-a074-6630c751dbfc_1600x994.png 424w, https://substackcdn.com/image/fetch/$s_!QoMd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50155d7d-0996-46cb-a074-6630c751dbfc_1600x994.png 848w, https://substackcdn.com/image/fetch/$s_!QoMd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50155d7d-0996-46cb-a074-6630c751dbfc_1600x994.png 1272w, https://substackcdn.com/image/fetch/$s_!QoMd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50155d7d-0996-46cb-a074-6630c751dbfc_1600x994.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 role="img" 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><title></title><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>Notice how much faster Timsort is compared to Quicksort.</p><p>The more Timsort is used in real-world data scenarios, the more we&#8217;ll see it soaring faster than every other sorting algorithm we have seen so far.</p><p>Lastly, from a space point of view, Timsort needs an <strong>O(n)</strong> amount of memory to run. This has to do with the data structures Timsort creates behind the scenes when merging the runs.</p><div><hr></div><h2>The Code</h2><p>Timsort is a very complex sorting algorithm to implement.</p><p>The core insertion sort and merging capabilities are straightforward. Identifying and handling all the various patterns to optimize for...is less straightforward. For that reason, most examples of Timsort we will run into are based on the original Python implementation itself. I am not going to paste the massive amount of code needed to implement Timsort in JavaScript.</p><p>Instead, here is a <a href="https://github.com/kirupa/kirupa/blob/master/data_structures_algorithms/timsort.htm">link to the GitHub repo</a> where I took <a href="https://github.com/mziccard/node-timsort">Marco Ziccardi&#8217;s Node.js implementation</a> of Timsort and turned it into something that works in the browser:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!t2KH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83226ab-8e31-459b-8d75-46650f4e27bd_1600x1180.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!t2KH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83226ab-8e31-459b-8d75-46650f4e27bd_1600x1180.png 424w, https://substackcdn.com/image/fetch/$s_!t2KH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83226ab-8e31-459b-8d75-46650f4e27bd_1600x1180.png 848w, https://substackcdn.com/image/fetch/$s_!t2KH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83226ab-8e31-459b-8d75-46650f4e27bd_1600x1180.png 1272w, https://substackcdn.com/image/fetch/$s_!t2KH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83226ab-8e31-459b-8d75-46650f4e27bd_1600x1180.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!t2KH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83226ab-8e31-459b-8d75-46650f4e27bd_1600x1180.png" width="1456" height="1074" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b83226ab-8e31-459b-8d75-46650f4e27bd_1600x1180.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1074,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&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="" srcset="https://substackcdn.com/image/fetch/$s_!t2KH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83226ab-8e31-459b-8d75-46650f4e27bd_1600x1180.png 424w, https://substackcdn.com/image/fetch/$s_!t2KH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83226ab-8e31-459b-8d75-46650f4e27bd_1600x1180.png 848w, https://substackcdn.com/image/fetch/$s_!t2KH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83226ab-8e31-459b-8d75-46650f4e27bd_1600x1180.png 1272w, https://substackcdn.com/image/fetch/$s_!t2KH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83226ab-8e31-459b-8d75-46650f4e27bd_1600x1180.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 role="img" 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><title></title><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 we scan through the code, we&#8217;ll see a lot of familiar patterns. Towards the bottom, the example code to initialize Timsort and use it to sort some values is provided:</p><pre><code>let example = [-7, 10, 50, 3, 940, 1, 4, -8, 24, 40, 33, 12, 10];

// Comparison function
function numberCompare(a, b) {
  return a - b;
}

// Sort our example array
timsort.sort(example, numberCompare);
console.log(example);</code></pre><p>Feel free to try it out and use this in your own projects, but as we will discuss in a few moments, Timsort is already the default sorting algorithm used in many situations in our favorite programming languages.</p><div><hr></div><h2>Conclusion</h2><p>Timsort, as the preeminent hybrid sorting algorithm, is among the fastest sorting algorithms available.</p><p>When we say this, this <em><strong>fastest</strong></em> isn&#8217;t qualified with caveats where the unsorted input needs to be of a certain arrangement. Timsort&#8217;s worst-case behavior is very good. Timsort&#8217;s best-case behavior is very, VERY good. The upper and lower bounds of its performance make it an excellent choice for any kind of unsorted (or sorted) input we throw at it. This flexibility and power are what make Timsort one of the&nbsp;<a href="https://www.kirupa.com/data_structures_algorithms/default_sorting_algorithms.htm">default sorting algorithms</a>&nbsp;in programming languages such as Python, Java, Rust, and more.</p><p>Now, Timsort isn&#8217;t the only hybrid sorting algorithm in town.</p><p>Another popular hybrid sorting algorithm is <strong><a href="https://en.wikipedia.org/wiki/Introsort">introsort</a></strong> (sometimes referred to as <strong>introspective sort</strong>), which uses a combination of quicksort, heapsort, and insertion sort for its sorting shenanigans. Introsort is the default sorting algorithm in Swift, C#, and other languages. As we look ahead into the future and run into more interesting and new data scenarios, we may see more hybrid sorting algorithms emerge.</p><p>We are in the early days, so there will be more fun times ahead with hybrid sorting algorithms.</p><div><hr></div><p>&#128075; I&#8217;d like to thank <strong><a href="https://www.linkedin.com/in/kirupa/">Kirupa</a></strong> for sharing this deep dive into Timsort.</p><p>For more explanations of popular data structures and algorithms, his <a href="https://www.amazon.com/exec/obidos/ASIN/0138222290/kirupacom">Absolute Beginner&#8217;s Guide to Algorithms</a> book is just what you (or a friend) will need.</p><p>You can catch all of his online content at <a href="http://kirupa.com">KIRUPA.com</a> and his <a href="https://www.kirupa.chat">newsletter</a>.</p><div><hr></div><p>I launched <strong>Design, Build, Scale</strong> (newsletter series exclusive to PAID subscribers).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://newsletter.systemdesign.one/subscribe?yearly=true" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jG0C!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jG0C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/63fca468-adce-4713-97a0-203c35bc1c60_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;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:null,&quot;href&quot;:&quot;https://newsletter.systemdesign.one/subscribe?yearly=true&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/179076610?img=https%3A%2F%2Fsubstackcdn.com%2Fimage%2Ffetch%2F%24s_%21jG0C%21%2Cf_auto%2Cq_auto%3Agood%2Cfl_progressive%3Asteep%2Fhttps%253A%252F%252Fsubstack-post-media.s3.amazonaws.com%252Fpublic%252Fimages%252F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!jG0C!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 424w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 848w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.png 1272w, https://substackcdn.com/image/fetch/$s_!jG0C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63fca468-adce-4713-97a0-203c35bc1c60_1200x630.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 role="img" 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><title></title><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>When you upgrade, you&#8217;ll get:</p><ul><li><p><strong>High-level architecture of real-world systems.</strong></p></li><li><p>Deep dive into how popular real-world systems actually work.</p></li><li><p><strong>How real-world systems handle scale, reliability, and performance.</strong></p></li><li><p>10x the results you currently get with 1/10th of your time, energy, and effort.</p></li></ul><p><strong>&#128073; <a href="https://newsletter.systemdesign.one/subscribe?yearly=true">CLICK HERE TO ACCESS DESIGN, BUILD, SCALE!</a></strong></p><div><hr></div><p>If you find this newsletter valuable, share it with a friend, and subscribe if you haven&#8217;t already. There are <a href="http://newsletter.systemdesign.one/subscribe?group=true">group discounts</a>, <a href="http://newsletter.systemdesign.one/subscribe?gift=true">gift options</a>, and <a href="https://newsletter.systemdesign.one/leaderboard">referral rewards</a> available.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://www.linkedin.com/in/nk-systemdesign-one/" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png" width="152" height="152" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:320,&quot;width&quot;:320,&quot;resizeWidth&quot;:152,&quot;bytes&quot;:74009,&quot;alt&quot;:&quot;Author Neo Kim; System design case studies&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://www.linkedin.com/in/nk-systemdesign-one/&quot;,&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="Author Neo Kim; System design case studies" title="Author Neo Kim; System design case studies" srcset="https://substackcdn.com/image/fetch/$s_!bEFk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 424w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 848w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1272w, https://substackcdn.com/image/fetch/$s_!bEFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f94ab8c-0d67-4775-992e-05e09ab710db_320x320.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption"><strong>&#128075; Find me on <a href="https://www.linkedin.com/in/nk-systemdesign-one/">LinkedIn</a> | <a href="https://x.com/intent/follow?screen_name=systemdesignone">Twitter</a> | <a href="https://www.threads.net/@systemdesignone">Threads</a> | <a href="https://www.instagram.com/systemdesignone/">Instagram</a></strong></figcaption></figure></div><div><hr></div><p><strong>Want to reach 200K+ tech professionals at scale? </strong>&#128240;</p><p>If your company wants to reach 200K+ tech professionals, <a href="https://newsletter.systemdesign.one/p/sponsorship">advertise with me</a>.</p><div><hr></div><p>Thank you for supporting this newsletter.</p><p>You are now 200,001+ readers strong, very close to 201k. Let&#8217;s try to get 201k readers by 25 February. Consider sharing this post with your friends and get rewards.</p><p>Y&#8217;all are the best.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6oWl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png" width="590" height="368.75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:800,&quot;resizeWidth&quot;:590,&quot;bytes&quot;:87878,&quot;alt&quot;:&quot;system design newsletter&quot;,&quot;title&quot;:&quot;system design newsletter&quot;,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesign.one/i/163380418?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="system design newsletter" title="system design newsletter" srcset="https://substackcdn.com/image/fetch/$s_!6oWl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 424w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 848w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.png 1272w, https://substackcdn.com/image/fetch/$s_!6oWl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e739087-a910-4643-be36-997b6dd5b4af_800x500.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 role="img" 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><title></title><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 class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesign.one/p/timsort-algorithm?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesign.one/p/timsort-algorithm?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p>If you aren&#8217;t familiar with quicksort, glance through <a href="https://www.kirupa.com/sorts/quicksort.htm">this deep dive</a>.</p><p></p></div></div>]]></content:encoded></item></channel></rss>