<?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[System Design Codex]]></title><description><![CDATA[The best place to learn practical System Design with concepts and case studies]]></description><link>https://newsletter.systemdesigncodex.com</link><image><url>https://substackcdn.com/image/fetch/$s_!wAIR!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1adf652d-a848-4f3c-9100-3f025578ae11_256x256.png</url><title>System Design Codex</title><link>https://newsletter.systemdesigncodex.com</link></image><generator>Substack</generator><lastBuildDate>Sat, 11 Jul 2026 16:02:55 GMT</lastBuildDate><atom:link href="https://newsletter.systemdesigncodex.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Saurabh Dashora]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[systemcodex@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[systemcodex@substack.com]]></itunes:email><itunes:name><![CDATA[Saurabh Dashora]]></itunes:name></itunes:owner><itunes:author><![CDATA[Saurabh Dashora]]></itunes:author><googleplay:owner><![CDATA[systemcodex@substack.com]]></googleplay:owner><googleplay:email><![CDATA[systemcodex@substack.com]]></googleplay:email><googleplay:author><![CDATA[Saurabh Dashora]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Essential Non Functional Requirements]]></title><description><![CDATA[Don't miss them]]></description><link>https://newsletter.systemdesigncodex.com/p/essential-non-functional-requirements</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/essential-non-functional-requirements</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 07 Jul 2026 08:33:34 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!WnJU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><span>When designing and building software systems, developers often focus on </span><em>what</em><span> the system does&#8212;this is the functional part. But just as critical is how the system behaves under real-world conditions.</span></p><p><span>That&#8217;s where </span><strong>non-functional requirements (NFRs)</strong><span> come into play.</span></p><p><span>Non-functional requirements define the </span><strong>quality attributes</strong><span> of a system: its reliability, responsiveness, scalability, flexibility, and more. These aspects don&#8217;t deal with features directly but ensure the system delivers a robust experience.</span></p><p>Here are 8 essential non-functional requirements that every developer should know&#8212;along with how to implement them in practice.</p><h3><strong>1 - Availability</strong></h3><p><strong>What it means:</strong><br><br><span>Availability ensures that your system is operational and accessible when users need it.</span></p><p><strong>Why it matters:</strong><br><br><span>If your system goes down during peak usage (e.g., an e-commerce flash sale), you risk losing revenue and user trust.</span></p><p><strong>How to implement:</strong><br><br><span>Use </span><strong>Load Balancers</strong><span> (like NGINX, HAProxy, or AWS ELB) to distribute incoming traffic across multiple instances of your application. This ensures that no single failure point can bring the whole system down. Combine this with </span><strong>health checks</strong><span> and </span><strong>failover mechanisms</strong><span> for maximum availability.</span></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WnJU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WnJU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.png 424w, https://substackcdn.com/image/fetch/$s_!WnJU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.png 848w, https://substackcdn.com/image/fetch/$s_!WnJU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.png 1272w, https://substackcdn.com/image/fetch/$s_!WnJU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WnJU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.png" width="1456" height="1021" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8c656489-710f-4dd3-9392-c670ae392954_3730x2615.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1021,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:333068,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesigncodex.com/i/169523142?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.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_!WnJU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.png 424w, https://substackcdn.com/image/fetch/$s_!WnJU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.png 848w, https://substackcdn.com/image/fetch/$s_!WnJU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.png 1272w, https://substackcdn.com/image/fetch/$s_!WnJU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c656489-710f-4dd3-9392-c670ae392954_3730x2615.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/U125TuguEQFtAn4Uq1DK?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>2 - Latency</strong></h3><p><strong>What it means:</strong><br><br><span>Latency is the time it takes for a user&#8217;s request to receive a response. Lower latency equals faster, smoother user experiences.</span></p><p><strong>Why it matters:</strong><br><br><span>Users won&#8217;t wait forever. Studies show that even a 100ms delay can impact user engagement and conversions.</span></p><p><strong>How to implement:</strong><br><br><span>Deploy a </span><strong>Content Delivery Network (CDN)</strong><span> like Cloudflare, Akamai, or Amazon CloudFront to cache static content closer to the end user. This reduces travel time for requests and significantly speeds up asset delivery.</span></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QKTT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QKTT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.png 424w, https://substackcdn.com/image/fetch/$s_!QKTT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.png 848w, https://substackcdn.com/image/fetch/$s_!QKTT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.png 1272w, https://substackcdn.com/image/fetch/$s_!QKTT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QKTT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.png" width="1456" height="1595" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1595,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1024137,&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://newsletter.systemdesigncodex.com/i/169523142?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.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_!QKTT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.png 424w, https://substackcdn.com/image/fetch/$s_!QKTT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.png 848w, https://substackcdn.com/image/fetch/$s_!QKTT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.png 1272w, https://substackcdn.com/image/fetch/$s_!QKTT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec0bd214-8c5a-4a9b-8951-325aaf295aa1_3864x4233.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"><a href="https://app.eraser.io/workspace/U125TuguEQFtAn4Uq1DK?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>3 - Scalability</strong></h3><p><strong>What it means:</strong><br><br><span>Scalability is the system&#8217;s ability to handle increasing workloads by efficiently adding resources.</span></p><p><strong>Why it matters:</strong><br><br><span>Your app may work great with 1,000 users, but what happens when it hits 1 million?</span></p><p><strong>How to implement:</strong><br><br><span>Use </span><strong>data replication</strong><span> to distribute load across multiple database nodes. Combine this with </span><strong>horizontal scaling</strong><span> for stateless services using container orchestrators like Kubernetes. Design APIs to handle concurrent users gracefully.</span></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-1lP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-1lP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!-1lP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!-1lP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!-1lP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-1lP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.png" width="1456" height="996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:175243,&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://newsletter.systemdesigncodex.com/i/169523142?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.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_!-1lP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!-1lP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!-1lP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!-1lP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6ddc30d-5543-4b5d-83c2-241790e94727_1929x1319.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"><a href="https://app.eraser.io/workspace/U125TuguEQFtAn4Uq1DK?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>4 - Durability</strong></h3><p><strong>What it means:</strong><br><br><span>Durability ensures that once data is stored, it remains safe&#8212;even in the case of power loss, crashes, or system failures.</span></p><p><strong>Why it matters:</strong><br><br><span>If users lose their transaction history, passwords, or saved preferences, your app loses credibility.</span></p><p><strong>How to implement:</strong><br><br><span>Use </span><strong>transaction logs</strong><span> or </span><strong>write-ahead logs</strong><span> (WAL) to persist operations before applying them to the database. Systems like PostgreSQL and MySQL have this built in. In distributed storage, use replicated, fault-tolerant data stores like Amazon S3, Cassandra, or HDFS.</span></p><h3><strong>5 - Consistency</strong></h3><p><strong>What it means:</strong><br><br><span>Consistency means that users see a reliable and accurate state of data&#8212;even when multiple servers or databases are involved.</span></p><p><strong>Why it matters:</strong><br><br><span>If user A updates their profile but user B sees outdated data, that&#8217;s a poor experience.</span></p><p><strong>How to implement:</strong><br><br><span>In distributed systems, </span><strong>eventual consistency</strong><span> is often used instead of strict real-time consistency. Systems like DynamoDB and Cassandra ensure that all nodes will </span><em>eventually</em><span> reflect the same data. Use </span><strong>conflict resolution strategies</strong><span> and </span><strong>data versioning</strong><span> when needed.</span></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kcvJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kcvJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.png 424w, https://substackcdn.com/image/fetch/$s_!kcvJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.png 848w, https://substackcdn.com/image/fetch/$s_!kcvJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.png 1272w, https://substackcdn.com/image/fetch/$s_!kcvJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!kcvJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.png" width="1456" height="911" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:911,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:175265,&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://newsletter.systemdesigncodex.com/i/169523142?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.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_!kcvJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.png 424w, https://substackcdn.com/image/fetch/$s_!kcvJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.png 848w, https://substackcdn.com/image/fetch/$s_!kcvJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.png 1272w, https://substackcdn.com/image/fetch/$s_!kcvJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f3e7643-99e5-4a07-843c-17b07ef5c292_2107x1318.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"><a href="https://app.eraser.io/workspace/U125TuguEQFtAn4Uq1DK?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>6 - Modularity</strong></h3><p><strong>What it means:</strong><br><br><span>Modularity means breaking down the system into independent, manageable components.</span></p><p><strong>Why it matters:</strong><br><br><span>Tightly coupled systems are hard to scale, test, or modify. Modularity gives you agility.</span></p><p><strong>How to implement:</strong><br><br><span>Follow principles of </span><strong>loose coupling</strong><span> (components interact via interfaces or contracts) and </span><strong>high cohesion</strong><span> (each module has a single purpose). Use design patterns like </span><strong>microservices</strong><span>, </span><strong>layered architecture</strong><span>, or </span><strong>hexagonal architecture</strong><span> to promote modularity.</span></p><h3><strong>7 - Configurability</strong></h3><p><strong>What it means:</strong><br><br><span>Configurability allows you to modify system behavior without deploying new code.</span></p><p><strong>Why it matters:</strong><br><br><span>Want to enable a new feature or change system behavior across environments (dev, test, prod)? Doing this without code changes is a big win.</span></p><p><strong>How to implement:</strong><br><br><span>Use </span><strong>Configuration-as-Code</strong><span> with tools like Terraform, Ansible, or Helm to manage infrastructure settings in version control. Also, expose runtime configuration via environment variables or centralized config servers (e.g., Spring Cloud Config).</span></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!upkt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!upkt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.png 424w, https://substackcdn.com/image/fetch/$s_!upkt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.png 848w, https://substackcdn.com/image/fetch/$s_!upkt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.png 1272w, https://substackcdn.com/image/fetch/$s_!upkt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!upkt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.png" width="1022" height="1013" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1013,&quot;width&quot;:1022,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:64548,&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://newsletter.systemdesigncodex.com/i/169523142?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.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_!upkt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.png 424w, https://substackcdn.com/image/fetch/$s_!upkt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.png 848w, https://substackcdn.com/image/fetch/$s_!upkt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.png 1272w, https://substackcdn.com/image/fetch/$s_!upkt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93af5971-b033-433f-9250-72a2f216cc9e_1022x1013.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"><a href="https://app.eraser.io/workspace/U125TuguEQFtAn4Uq1DK?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>8 - Resiliency</strong></h3><p><strong>What it means:</strong><br><br><span>Resiliency is the system&#8217;s ability to recover gracefully from faults or disruptions.</span></p><p><strong>Why it matters:</strong><br><br><span>Failures are inevitable. What matters is how well your system handles them.</span></p><p><strong>How to implement:</strong><br><br><span>Introduce </span><strong>message queues</strong><span> (like RabbitMQ, Kafka, or AWS SQS) to decouple producers and consumers. This allows parts of your system to fail or restart without losing data. Also use </span><strong>circuit breakers</strong><span>, </span><strong>retry logic</strong><span>, and </span><strong>backoff strategies</strong><span> to handle transient issues.</span></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zFL5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zFL5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.png 424w, https://substackcdn.com/image/fetch/$s_!zFL5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.png 848w, https://substackcdn.com/image/fetch/$s_!zFL5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.png 1272w, https://substackcdn.com/image/fetch/$s_!zFL5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zFL5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.png" width="1456" height="878" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:878,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:168387,&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://newsletter.systemdesigncodex.com/i/169523142?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.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_!zFL5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.png 424w, https://substackcdn.com/image/fetch/$s_!zFL5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.png 848w, https://substackcdn.com/image/fetch/$s_!zFL5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.png 1272w, https://substackcdn.com/image/fetch/$s_!zFL5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac30e1c2-7354-47ad-937a-fed4ad1274e3_2175x1312.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"><a href="https://app.eraser.io/workspace/U125TuguEQFtAn4Uq1DK?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>&#128073; So - which other NFRs will you add to the list?</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/essential-non-functional-requirements/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/essential-non-functional-requirements/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today!</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/essential-non-functional-requirements?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.systemdesigncodex.com/p/essential-non-functional-requirements?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[How to Explain Tech Stuff to Non-Tech Colleagues]]></title><description><![CDATA[Some tips]]></description><link>https://newsletter.systemdesigncodex.com/p/how-to-explain-tech-stuff-to-non</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/how-to-explain-tech-stuff-to-non</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Wed, 01 Jul 2026 06:00:36 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!p-0A!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Today&#8217;s topic is slightly different from the usual System Design topics. It&#8217;s about communicating your technical ideas and details to a non-technical audience for maximum impact.</p><p><strong>Have you ever struggled to explain a tech concept to someone who has never seen a line of code in their life?</strong></p><p>Yes, we have all been there at some point or the other.</p><p>It may be hard for a new developer to imagine, but a large number of your colleagues are going to come from a non-tech background. And you need to interact with them every now and then. In some roles, this interaction will be extremely important.</p><p>However, one thing is certain.</p><p>If you want to grow as a developer, you must learn how to talk tech stuff with non-tech colleagues.</p><blockquote><p><em><strong>Trust me - this is the key to your success, whether you are in an organization or if you are running your own freelance business.</strong></em></p></blockquote><p><span>But frankly speaking, it&#8217;s </span><em>not</em><span> as tough as we make it out to be.</span></p><p><span>Over the years, I have always relied on what I call the </span><strong>Communication Iceberg </strong><span>to get my ideas across as effectively as possible. The iceberg contains many tools for abstracting the technical stuff while engaging with non-technical folks in what can sometimes be career-defining interactions.</span></p><p>However, it&#8217;s important to understand when and how to use these tools. And that&#8217;s what we will be covering in this post.</p><p>For better clarity, I have divided the tips into two categories.</p><h2><strong>1 - The General Tips</strong></h2><p>Some things that you must do at a bare minimum while explaining programming concepts to a non-tech audience:</p><ul><li><p><strong>Use analogies</strong><span> - Instead of using terms like servers and requests, try relating them to real-world examples such as waiters and orders in a restaurant.</span></p></li><li><p><strong>Avoid acronyms and jargon</strong><span> - Wherever possible, use plain language to explain a concept instead of an acronym or jargon.</span></p></li><li><p><strong>Explain stuff visually</strong><span> - Use visual aids such as flowcharts, diagrams or graphs instead of long-winded explanations.</span></p></li><li><p><strong>Use storytelling</strong><span> - Everyone loves stories. They are powerful tools to capture the attention of a non-tech audience. For example, instead of saying version control, build a story of a team of developers sharing their code and tracking changes.</span></p></li><li><p><strong>Focus on the big picture </strong><span>- Don&#8217;t jump into the deep end of a tech concept. Try to start with the big picture and ease your non-tech audience into learning more about complex topics.</span></p></li><li><p><strong>Encourage questions</strong><span> - Don&#8217;t be a robot while explaining a concept. The more questions you can encourage people to ask, the more you will be able to get them involved and make them understand the topic.</span></p></li></ul><p>Here&#8217;s a diagram that can help you make more sense of these strategies</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!p-0A!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!p-0A!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.png 424w, https://substackcdn.com/image/fetch/$s_!p-0A!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.png 848w, https://substackcdn.com/image/fetch/$s_!p-0A!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.png 1272w, https://substackcdn.com/image/fetch/$s_!p-0A!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!p-0A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.png" width="1456" height="594" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:594,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:250745,&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://newsletter.systemdesigncodex.com/i/165607816?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.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_!p-0A!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.png 424w, https://substackcdn.com/image/fetch/$s_!p-0A!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.png 848w, https://substackcdn.com/image/fetch/$s_!p-0A!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.png 1272w, https://substackcdn.com/image/fetch/$s_!p-0A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0042b456-f82e-4809-aa7d-cd26dbe7939a_3113x1270.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"><a href="https://app.eraser.io/workspace/hMrUpW4b3q1nclHJdXFb?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h2><strong>2 - Role-Specific Tips</strong></h2><p>The general tips can take you a long way.</p><p>But an organization is made up of many roles. People come from different backgrounds. They have different goals to achieve or agendas to pursue depending on their position.</p><p>I have experienced that it can be extremely fruitful to understand your audience better and tailor your message accordingly.</p><p>Here are a few tips that can help you out with specific roles.</p><h3><strong>Managers</strong></h3><p><span>When you talk to a manager, try to focus on the </span><strong>business impact</strong><span> of your technical work.</span></p><p>Always use data and metrics to push your point rather than plain old conviction.</p><p>Instead of saying:</p><blockquote><p><em><strong>&#8220;We need to use this technology because it&#8217;s so good and futuristic&#8221;</strong></em></p></blockquote><p>Try proposing:</p><blockquote><p><strong>&#8220;</strong><em><strong>By implementing this new technology, we are able to save the company $50,000 in operational costs each quarter, while also increasing our efficiency by 20%. These savings can be reinvested into other areas of the business to drive growth.</strong></em><strong>&#8221;</strong></p></blockquote><p>Here&#8217;s a more detailed schematic on how you can go about gathering this information by involving various stakeholders.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wOYZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wOYZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.png 424w, https://substackcdn.com/image/fetch/$s_!wOYZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.png 848w, https://substackcdn.com/image/fetch/$s_!wOYZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.png 1272w, https://substackcdn.com/image/fetch/$s_!wOYZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wOYZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.png" width="1456" height="1724" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1724,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:472577,&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://newsletter.systemdesigncodex.com/i/165607816?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.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_!wOYZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.png 424w, https://substackcdn.com/image/fetch/$s_!wOYZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.png 848w, https://substackcdn.com/image/fetch/$s_!wOYZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.png 1272w, https://substackcdn.com/image/fetch/$s_!wOYZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc90da4d1-a265-4c96-a541-1fb6578441af_2155x2551.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"><a href="https://app.eraser.io/workspace/hMrUpW4b3q1nclHJdXFb?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Sales Team</strong></h3><p>A sales team is interested in one thing - selling stuff. When communicating with them about your technical work, focus on how it helps them achieve their goals.</p><p>Here&#8217;s an example:</p><blockquote><p><em><strong>&#8220;Our new software upgrade will enable your sales team to access customer data in real-time, providing them with the insights they need to close deals faster.&#8221;</strong></em></p></blockquote><p>Following this approach directly links your software with their KPI and increases their chances of funding your project.</p><h3><strong>Clients</strong></h3><p>Clients are like potential buyers for your technical product. They might be the reason for your product&#8217;s existence in the first place.</p><p>When communicating with clients, avoid technical jargon and use plain language to explain your work. Focus on the end results and how your work will benefit the client.</p><p>Instead of saying:</p><blockquote><p><em><strong>&#8220;We&#8217;re using AWS Lambda to create serverless functions.&#8221;</strong></em></p></blockquote><p>Try saying:</p><blockquote><p><em><strong>&#8220;We&#8217;re building a system that can handle millions of requests without worrying about server capacity, which means your application will run smoothly with minimal downtime.&#8221;</strong></em></p></blockquote><p>Get into the technical jargon after you&#8217;ve sold the main benefit, and only when it is really required.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!p-WA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!p-WA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.png 424w, https://substackcdn.com/image/fetch/$s_!p-WA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.png 848w, https://substackcdn.com/image/fetch/$s_!p-WA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.png 1272w, https://substackcdn.com/image/fetch/$s_!p-WA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!p-WA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.png" width="1230" height="824" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:824,&quot;width&quot;:1230,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:124428,&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://newsletter.systemdesigncodex.com/i/165607816?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.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_!p-WA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.png 424w, https://substackcdn.com/image/fetch/$s_!p-WA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.png 848w, https://substackcdn.com/image/fetch/$s_!p-WA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.png 1272w, https://substackcdn.com/image/fetch/$s_!p-WA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F373def72-a00a-40b0-bfe2-a68318c98d21_1230x824.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"><a href="https://app.eraser.io/workspace/hMrUpW4b3q1nclHJdXFb?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>General Audience</strong></h3><p>As a software developer, you might need to share your knowledge and experience with a hall full of people. In such cases, you can&#8217;t automatically count on the audience to know about your area of expertise.</p><p><span>When communicating with colleagues who may </span><em>not</em><span> be familiar with your area of expertise, try to use analogies or real-world examples to explain technical concepts.</span></p><p>For example, explaining API security to someone who&#8217;s not familiar with the area is tough.</p><p>Try to create analogies like comparing it to locking your front door to keep burglars out. It&#8217;s the same idea, but instead of a physical key, you introduce a special code and create a mental picture for your audience.</p><p><span>&#128073; </span><strong>So, which other tips or strategies will you add to the list?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-to-explain-tech-stuff-to-non/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/how-to-explain-tech-stuff-to-non/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-to-explain-tech-stuff-to-non?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.systemdesigncodex.com/p/how-to-explain-tech-stuff-to-non?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Monolith to Service Architecture]]></title><description><![CDATA[Top Strategies]]></description><link>https://newsletter.systemdesigncodex.com/p/monolith-to-service-architecture</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/monolith-to-service-architecture</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 23 Jun 2026 07:55:12 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!dc_j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Moving from a monolithic architecture&#8212;where all functionality is bundled together&#8212;into a microservices architecture isn&#8217;t a flip of a switch. It&#8217;s a complex journey that, if done recklessly, can cause more harm than good.</p><p>That&#8217;s why smart teams follow specific transition patterns. These patterns help reduce risk, maintain stability, and allow the system to evolve gradually rather than completely rebuild.</p><p>Here are 4 such patterns that can help you:</p><h2><strong>1 - Strangler Fig Pattern</strong></h2><p>The Strangler Fig Pattern is perhaps the most famous strategy for modernizing monolithic systems. It&#8217;s inspired by how a strangler fig tree grows around an existing tree, eventually replacing it.</p><h3><strong>How It Works:</strong></h3><ul><li><p>An API gateway or proxy is placed in front of the monolith.</p></li><li><p>New features or refactored versions of existing features are developed as independent microservices.</p></li><li><p>The gateway routes requests:</p><ul><li><p>To the monolith for old functionality.</p></li><li><p>To the new microservices for updated functionality.</p></li></ul></li><li><p>Over time, as more functionality is moved out, the monolith shrinks until it can be retired.</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_!dc_j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dc_j!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 424w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 848w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 1272w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dc_j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png" width="1456" height="1928" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1928,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1125530,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesigncodex.com/i/162377004?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.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_!dc_j!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 424w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 848w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 1272w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/ZYjvO92sJEJvJ4AeSdu1?origin=share">You can play around with the image on Eraser.io</a></figcaption></figure></div><h3><strong>Why It&#8217;s Powerful:</strong></h3><ul><li><p>Incremental migration with minimal disruption.</p></li><li><p>Reduces the big-bang rewrite risk.</p></li><li><p>You can prioritize extracting high-value or high-risk components first.</p></li></ul><blockquote><p>Real-world use: Many enterprises use this approach when dealing with legacy systems where complete rewrites would be risky and expensive.</p></blockquote><div><hr></div><h2><strong>2 - Parallel Run Pattern</strong></h2><p>The Parallel Run Pattern involves running the old monolith and new microservices together for a period of time. Instead of replacing immediately, you redirect a portion of traffic to microservices to validate their behavior.</p><h3><strong>How It Works:</strong></h3><ul><li><p>Both the monolith and the new microservices are deployed simultaneously.</p></li><li><p>Certain user requests or workflows are mirrored or split-routed:</p><ul><li><p>Some go to the monolith.</p></li><li><p>Some go to the microservices.</p></li></ul></li><li><p>The output or behavior is compared to ensure that the new system is functionally equivalent.</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_!jkhR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jkhR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 424w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 848w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 1272w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jkhR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png" width="1369" height="1020" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1020,&quot;width&quot;:1369,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:120877,&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://newsletter.systemdesigncodex.com/i/162377004?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.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_!jkhR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 424w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 848w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 1272w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.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"><a href="https://app.eraser.io/workspace/ZYjvO92sJEJvJ4AeSdu1?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Why It&#8217;s Useful:</strong></h3><ul><li><p>Catch errors early before full migration.</p></li><li><p>Allows thorough real-world testing.</p></li><li><p>You can gradually increase traffic to the microservices as confidence builds.</p></li></ul><blockquote><p>Pro Tip: Use feature flags and automated comparison testing to make this process smoother.</p></blockquote><div><hr></div><h2><strong>3 - The Collaborator Pattern</strong></h2><p>The Collaborator Pattern is a clever way to augment the monolith without touching its core logic immediately. It allows you to extend the system by attaching microservices around it.</p><h3><strong>How It Works:</strong></h3><ul><li><p>Instead of replacing a functionality inside the monolith, you decorate or wrap existing modules with microservices that add new features.</p></li><li><p>The monolith still handles the original core behavior.</p></li><li><p>Microservices add enhanced behavior, enrich responses, or intercept and modify calls.</p></li></ul><h3><strong>Why It&#8217;s Valuable:</strong></h3><ul><li><p>Minimal disruption to the monolith.</p></li><li><p>Let&#8217;s you introduce new functionality faster without waiting for core refactoring.</p></li><li><p>Helps test microservice integration with live traffic early.</p></li></ul><blockquote><p><strong>Example:</strong> Suppose you have a monolith that processes orders, but you want to add a new discount service. Instead of modifying the order logic, you add a microservice that &#8220;decorates&#8221; order responses with discount information.</p></blockquote><div><hr></div><h2><strong>4 - Change Data Capture (CDC)</strong></h2><p>One of the biggest challenges during a transition is data synchronization. Change Data Capture (CDC) provides a solution by streaming real-time database changes from the monolith to the new microservices.</p><h3><strong>How It Works:</strong></h3><ul><li><p>Tools like Debezium, Kafka Connect, or AWS DMS monitor the monolith&#8217;s database transaction logs.</p></li><li><p>Whenever a change happens (insert, update, delete), the change is captured and streamed to interested microservices.</p></li><li><p>This allows microservices to react in near real-time without needing tight coupling to the monolith&#8217;s database.</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_!H2eS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!H2eS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 424w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 848w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 1272w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!H2eS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png" width="1456" height="695" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:695,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:157197,&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://newsletter.systemdesigncodex.com/i/162377004?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.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_!H2eS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 424w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 848w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 1272w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.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"><a href="https://app.eraser.io/workspace/ZYjvO92sJEJvJ4AeSdu1?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Why It&#8217;s Critical:</strong></h3><ul><li><p>Enables event-driven architectures during the transition.</p></li><li><p>Allows microservices to maintain their own data stores based on monolith changes.</p></li><li><p>Reduces reliance on synchronous API calls to the monolith.</p></li></ul><blockquote><p><strong>Important Tip: Be cautious about schema evolution; changes to the monolith database schema must be carefully coordinated with CDC consumers.</strong></p></blockquote><div><hr></div><h2><strong>How These Patterns Work Together</strong></h2><p>Transitioning from a monolith isn&#8217;t about choosing just one pattern&#8212;it&#8217;s about orchestrating them together:</p><ul><li><p>Start with the Strangler Fig to route traffic intelligently.</p></li><li><p>Run critical paths in parallel to build trust in the new system.</p></li><li><p>Decorate existing functionalities to add features without destabilizing the core.</p></li><li><p>Stream changes using CDC to gradually separate data ownership.</p></li></ul><p><strong>So - have you used any of these patterns?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/monolith-to-service-architecture/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/monolith-to-service-architecture/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/monolith-to-service-architecture?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.systemdesigncodex.com/p/monolith-to-service-architecture?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[How to Scale Kubernetes]]></title><description><![CDATA[Top Strategies to Know About]]></description><link>https://newsletter.systemdesigncodex.com/p/how-to-scale-kubernetes</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/how-to-scale-kubernetes</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 16 Jun 2026 07:15:28 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!GEkV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Kubernetes has become the go-to platform for running containerized applications in production. The real power of Kubernetes lies in scalability.</p><p>As traffic to your application grows, Kubernetes offers several built-in and customizable scaling strategies to keep your system responsive, efficient, and cost-effective.</p><p>In this article, we&#8217;ll explore the most essential Kubernetes scaling strategies you should know.</p><h2><strong>1 - Horizontal Pod Autoscaling (HPA)</strong></h2><p>This is the most commonly used scaling method in Kubernetes.</p><p>The Horizontal Pod Autoscaler (HPA) automatically increases or decreases the number of pod replicas in a Deployment, StatefulSet, or ReplicaSet based on observed resource usage. Most often, it watches CPU utilization, memory usage, or even custom application-level metrics like request rates.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GEkV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GEkV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.png 424w, https://substackcdn.com/image/fetch/$s_!GEkV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.png 848w, https://substackcdn.com/image/fetch/$s_!GEkV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.png 1272w, https://substackcdn.com/image/fetch/$s_!GEkV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GEkV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.png" width="1456" height="791" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:791,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:106815,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesigncodex.com/i/166692217?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.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_!GEkV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.png 424w, https://substackcdn.com/image/fetch/$s_!GEkV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.png 848w, https://substackcdn.com/image/fetch/$s_!GEkV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.png 1272w, https://substackcdn.com/image/fetch/$s_!GEkV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd35d666a-2de7-4cb7-b1df-18f96d090ed8_1608x874.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/6X5BbBPb3h0HbPyBoM9g?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Example:</strong></h3><p>If you set a target CPU utilization of 70% and your application crosses that threshold consistently, HPA might spin up more pod replicas to balance the load.</p><h3><strong>Key Benefits:</strong></h3><ul><li><p>Keeps applications responsive during high traffic.</p></li><li><p>Scales down during idle periods to save resources and cost.</p></li><li><p>Works well for stateless workloads like web servers, APIs, etc.</p></li></ul><h3><strong>Things to Watch:</strong></h3><ul><li><p>Requires metrics server to be installed in the cluster.</p></li><li><p>Doesn&#8217;t handle increasing pod resources&#8212;only the number of pods.</p></li></ul><h2><strong>2 - Vertical Pod Autoscaling (VPA)</strong></h2><p>Where HPA adds or removes pods, Vertical Pod Autoscaling (VPA) focuses on resizing the pods themselves.</p><p>VPA automatically adjusts the CPU and memory requests/limits for each pod based on its actual usage. This is especially useful for workloads where scaling out is either inefficient or impractical&#8212;such as batch jobs, data processing, or single-instance services.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZbJD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZbJD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.png 424w, https://substackcdn.com/image/fetch/$s_!ZbJD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.png 848w, https://substackcdn.com/image/fetch/$s_!ZbJD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.png 1272w, https://substackcdn.com/image/fetch/$s_!ZbJD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZbJD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.png" width="1456" height="772" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:772,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:117678,&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://newsletter.systemdesigncodex.com/i/166692217?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.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_!ZbJD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.png 424w, https://substackcdn.com/image/fetch/$s_!ZbJD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.png 848w, https://substackcdn.com/image/fetch/$s_!ZbJD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.png 1272w, https://substackcdn.com/image/fetch/$s_!ZbJD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99f0f98c-b161-4d2e-9c8d-5e472e51f953_1653x876.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"><a href="https://app.eraser.io/workspace/6X5BbBPb3h0HbPyBoM9g?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Example:</strong></h3><p>If your application consistently uses more memory than allocated, VPA can increase the memory limits so the pod doesn&#8217;t get OOM-killed (Out of Memory error).</p><h3><strong>Key Benefits:</strong></h3><ul><li><p>Prevents over-provisioning or under-provisioning of resources.</p></li><li><p>Helps optimize performance for memory-heavy or CPU-intensive tasks.</p></li></ul><h3><strong>Things to Watch:</strong></h3><ul><li><p>Restart of pods is often required for VPA to apply changes.</p></li><li><p>Doesn&#8217;t work well with HPA simultaneously unless specifically configured.</p></li><li><p>May lead to high memory usage if not monitored properly.</p></li></ul><h2><strong>3 - Cluster Autoscaling</strong></h2><p>While HPA and VPA manage scaling at the pod level, Cluster Autoscaler takes care of scaling at the infrastructure level&#8212;specifically, the number of worker nodes in your Kubernetes cluster.</p><p>When pods can&#8217;t be scheduled due to resource shortages (e.g., not enough CPU or memory across nodes), the Cluster Autoscaler works with your cloud provider (like AWS, GCP, Azure) to add more nodes. Similarly, if some nodes are underutilized and their pods can be moved elsewhere, it can safely scale the cluster down.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-fZC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-fZC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.png 424w, https://substackcdn.com/image/fetch/$s_!-fZC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.png 848w, https://substackcdn.com/image/fetch/$s_!-fZC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.png 1272w, https://substackcdn.com/image/fetch/$s_!-fZC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-fZC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.png" width="1456" height="665" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:665,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:134158,&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://newsletter.systemdesigncodex.com/i/166692217?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.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_!-fZC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.png 424w, https://substackcdn.com/image/fetch/$s_!-fZC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.png 848w, https://substackcdn.com/image/fetch/$s_!-fZC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.png 1272w, https://substackcdn.com/image/fetch/$s_!-fZC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbb0d403-5efb-4489-9a61-f232e3997471_2228x1017.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"><a href="https://app.eraser.io/workspace/6X5BbBPb3h0HbPyBoM9g?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Example:</strong></h3><p>If a new workload comes in and there&#8217;s not enough room on current nodes, the autoscaler adds a new node automatically.</p><h3><strong>Key Benefits:</strong></h3><ul><li><p>Handles infrastructure elasticity based on demand.</p></li><li><p>Complements HPA by ensuring there are enough nodes to host additional pods.</p></li><li><p>Reduces costs by removing idle nodes.</p></li></ul><h3><strong>Things to Watch:</strong></h3><ul><li><p>Needs correct configuration of node groups and cloud provider APIs.</p></li><li><p>Works best in cloud environments with auto-provisioning support.</p></li></ul><h2><strong>Conclusion: Choose What Fits Your Workload</strong></h2><p>Kubernetes provides a flexible toolbox for scaling. Here&#8217;s a quick summary:</p><ul><li><p>HPA is great for stateless, load-balanced apps.</p></li><li><p>VPA is ideal for apps with unpredictable or variable resource needs.</p></li><li><p>Cluster Autoscaler ensures infrastructure scales with your workloads.</p></li></ul><p><strong>So, which scaling strategies have you used?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-to-scale-kubernetes/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/how-to-scale-kubernetes/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-to-scale-kubernetes?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.systemdesigncodex.com/p/how-to-scale-kubernetes?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Key Components of a Prod Web Application]]></title><description><![CDATA[A big picture view...]]></description><link>https://newsletter.systemdesigncodex.com/p/key-components-of-a-prod-web-application</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/key-components-of-a-prod-web-application</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 09 Jun 2026 07:56:22 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!q0fl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Building a web application in a development environment is one thing. But running it reliably in production, where real users depend on performance, scalability, and uptime, is a whole different challenge.</p><p>A modern production web application is more than just code deployed to a server&#8212;it&#8217;s a carefully designed ecosystem with various tools and components working together to ensure speed, resilience, observability, and scalability.</p><p>Here&#8217;s a breakdown of the essential components that make up a production-grade web application.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!q0fl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!q0fl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.png 424w, https://substackcdn.com/image/fetch/$s_!q0fl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.png 848w, https://substackcdn.com/image/fetch/$s_!q0fl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!q0fl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!q0fl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.png" width="1456" height="950" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:950,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:285623,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesigncodex.com/i/163983207?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.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_!q0fl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.png 424w, https://substackcdn.com/image/fetch/$s_!q0fl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.png 848w, https://substackcdn.com/image/fetch/$s_!q0fl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!q0fl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6bc327-f286-4cfb-953a-0ebf3ba07a6c_2875x1875.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/Me3P6mBtWUe12GQAcVkk?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h2><strong>1 - CI/CD Pipelines</strong></h2><p>Every production-ready system starts with Continuous Integration and Continuous Deployment (CI/CD) pipelines.</p><ul><li><p>CI automates code testing, linting, and merging to ensure only high-quality code enters the main branch.</p></li><li><p>CD ensures that the latest version of the app can be reliably and repeatably deployed to production servers.</p></li></ul><p>Tools like GitHub Actions, Jenkins, GitLab CI, and CircleCI help automate the full pipeline&#8212;from code commit to deployment&#8212;reducing human error and accelerating release cycles.</p><p>&#128204; <em>Bonus</em>: You can also add blue/green deployments or canary rollouts to minimize deployment risk.</p><h2><strong>2 - Client Requests and DNS Resolution</strong></h2><p>Everything starts with a user in a web browser entering a domain like <code>example.com</code>.</p><ul><li><p>The browser performs DNS resolution to find the IP address of your app server.</p></li><li><p>Once resolved, the request travels over the internet to your server infrastructure.</p></li></ul><p>This initial handshake is critical&#8212;it&#8217;s where performance optimizations like DNS caching and HTTP/2 can shave off precious milliseconds.</p><h2><strong>3 - Load Balancers and Reverse Proxies</strong></h2><p>When traffic hits your infrastructure, it passes through a load balancer or reverse proxy (like Nginx, HAProxy, or AWS ALB).</p><ul><li><p>These tools distribute incoming requests across multiple application servers to ensure high availability and avoid overloading any single instance.</p></li><li><p>They also handle SSL termination, URL rewriting, and sometimes even basic caching.</p></li></ul><p>In a distributed architecture, load balancing is essential for scalability and fault tolerance.</p><h2><strong>4 - Content Delivery Network (CDN)</strong></h2><p>For serving static assets (like images, CSS, JavaScript, fonts), modern apps rely on CDNs such as Cloudflare, Akamai, or AWS CloudFront.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JFWU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JFWU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.png 424w, https://substackcdn.com/image/fetch/$s_!JFWU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.png 848w, https://substackcdn.com/image/fetch/$s_!JFWU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.png 1272w, https://substackcdn.com/image/fetch/$s_!JFWU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JFWU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.png" width="1456" height="800" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:800,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:547088,&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://newsletter.systemdesigncodex.com/i/163983207?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.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_!JFWU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.png 424w, https://substackcdn.com/image/fetch/$s_!JFWU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.png 848w, https://substackcdn.com/image/fetch/$s_!JFWU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.png 1272w, https://substackcdn.com/image/fetch/$s_!JFWU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91a35cd7-213a-4ba9-a8f8-eb655727ea8b_4276x2349.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"><a href="https://app.eraser.io/workspace/Me3P6mBtWUe12GQAcVkk?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><ul><li><p>CDNs cache content on edge servers close to users, reducing latency and load on your origin servers.</p></li><li><p>They also add security layers like DDoS protection, WAFs (Web Application Firewalls), and TLS encryption.</p></li></ul><p>Your app feels faster, especially for users across different geographies.</p><h2><strong>5 - API Layer for Business Logic</strong></h2><p>Modern web applications are often split between frontend and backend. The frontend communicates with the backend through RESTful or GraphQL 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_!9en7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff600ca83-4351-4c52-821e-5bd48f494598_1148x818.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9en7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff600ca83-4351-4c52-821e-5bd48f494598_1148x818.png 424w, https://substackcdn.com/image/fetch/$s_!9en7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff600ca83-4351-4c52-821e-5bd48f494598_1148x818.png 848w, https://substackcdn.com/image/fetch/$s_!9en7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff600ca83-4351-4c52-821e-5bd48f494598_1148x818.png 1272w, https://substackcdn.com/image/fetch/$s_!9en7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff600ca83-4351-4c52-821e-5bd48f494598_1148x818.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9en7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff600ca83-4351-4c52-821e-5bd48f494598_1148x818.png" width="1148" height="818" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f600ca83-4351-4c52-821e-5bd48f494598_1148x818.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:818,&quot;width&quot;:1148,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:118912,&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://newsletter.systemdesigncodex.com/i/163983207?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff600ca83-4351-4c52-821e-5bd48f494598_1148x818.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_!9en7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff600ca83-4351-4c52-821e-5bd48f494598_1148x818.png 424w, https://substackcdn.com/image/fetch/$s_!9en7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff600ca83-4351-4c52-821e-5bd48f494598_1148x818.png 848w, https://substackcdn.com/image/fetch/$s_!9en7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff600ca83-4351-4c52-821e-5bd48f494598_1148x818.png 1272w, https://substackcdn.com/image/fetch/$s_!9en7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff600ca83-4351-4c52-821e-5bd48f494598_1148x818.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"><a href="https://app.eraser.io/workspace/Me3P6mBtWUe12GQAcVkk?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><ul><li><p>These APIs handle authentication, business logic, user data, and session management.</p></li><li><p>They act as the interface between the web app and core backend services, often sitting behind versioning, rate limits, and authentication layers like OAuth or JWT.</p></li></ul><p>A well-structured API layer makes your app modular and scalable.</p><h2><strong>6 - Databases and Distributed Caches</strong></h2><p>To serve dynamic content, your application needs to fetch and store data efficiently.</p><ul><li><p>Databases (like PostgreSQL, MySQL, or MongoDB) store persistent data.</p></li><li><p>Distributed caches (like Redis or Memcached) hold frequently accessed data in memory for rapid retrieval.</p></li></ul><p>Using caching for session storage, search results, or product listings can reduce database pressure and improve user experience.</p><h2><strong>7 - Job Queues and Background Workers</strong></h2><p>Some tasks don&#8217;t need to happen during the user&#8217;s request-response cycle. These include:</p><ul><li><p>Sending emails</p></li><li><p>Generating reports</p></li><li><p>Processing images</p></li><li><p>Syncing data with external APIs</p></li></ul><p>Instead of delaying the user, these tasks are pushed to a job queue (like RabbitMQ, Sidekiq, Celery, or Bull) and picked up by background workers for processing.</p><p>This keeps your app fast and responsive while handling heavy lifting asynchronously.</p><h2><strong>8 - Search Services</strong></h2><p>If your application supports search&#8212;like product search in e-commerce or user-generated content&#8212;you&#8217;ll need full-text search engines such as Elasticsearch or Apache Solr.</p><ul><li><p>These services index your data in real-time.</p></li><li><p>They support fuzzy search, autocomplete, faceted search, and ranking.</p></li></ul><p>A dedicated search service provides richer search experiences and better performance than SQL <code>LIKE</code> queries.</p><h2><strong>9 - Monitoring and Observability</strong></h2><p>When your app is live, you need to know what&#8217;s happening under the hood&#8212;from response times to error rates.</p><p>Monitoring tools like:</p><ul><li><p>Grafana (dashboards)</p></li><li><p>Prometheus (metrics collection)</p></li><li><p>Sentry (error reporting)</p></li><li><p>Datadog or New Relic (APM)</p></li></ul><p>...provide real-time insights into your app&#8217;s health, usage patterns, and performance bottlenecks.</p><p>Good observability helps you catch issues early before they affect users.</p><h2><strong>10 - Alerting and Incident Management</strong></h2><p>When something does go wrong, the right people need to know immediately.</p><ul><li><p>Alerting tools like PagerDuty, Opsgenie, or Slack integrations send notifications based on thresholds (e.g., CPU &gt; 90%, 5xx errors &gt; 5%).</p></li><li><p>Developers or DevOps teams are alerted automatically and can start resolution quickly.</p></li></ul><p>Fast alerts = faster response = reduced downtime.</p><p>So, what else will you add to the list?</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/key-components-of-a-prod-web-application/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/key-components-of-a-prod-web-application/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/key-components-of-a-prod-web-application?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.systemdesigncodex.com/p/key-components-of-a-prod-web-application?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[How to Design APIs]]></title><description><![CDATA[Key considerations to keep in mind]]></description><link>https://newsletter.systemdesigncodex.com/p/how-to-design-apis</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/how-to-design-apis</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 02 Jun 2026 06:41:25 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!zQ0f!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A poorly designed API can lead to hard-to-maintain code, frustrated clients, security risks, and performance bottlenecks. On the other hand, a well-designed API is predictable, consistent, scalable, and developer-friendly.</p><p>Here are <strong>five key considerations</strong> every developer should keep in mind when designing APIs.</p><h2><strong>1 - The Interface</strong></h2><p>At its core, an API is an <strong>interface between systems</strong>&#8212;a contract that defines how a client can interact with a service. This involves defining:</p><ul><li><p><strong>Resources</strong>: What are the core entities (e.g., users, products, orders)?</p></li><li><p><strong>Endpoints</strong>: How can clients interact with those resources? (<code>GET /users</code>, <code>POST /orders</code>, etc.)</p></li><li><p><strong>Request and Response Formats</strong>: Are you using JSON or XML? Are you following consistent naming conventions and data structures?</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_!zQ0f!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zQ0f!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.png 424w, https://substackcdn.com/image/fetch/$s_!zQ0f!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.png 848w, https://substackcdn.com/image/fetch/$s_!zQ0f!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.png 1272w, https://substackcdn.com/image/fetch/$s_!zQ0f!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zQ0f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.png" width="1171" height="1232" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1232,&quot;width&quot;:1171,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:105188,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesigncodex.com/i/162853625?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.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_!zQ0f!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.png 424w, https://substackcdn.com/image/fetch/$s_!zQ0f!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.png 848w, https://substackcdn.com/image/fetch/$s_!zQ0f!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.png 1272w, https://substackcdn.com/image/fetch/$s_!zQ0f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7e70869-41cc-4dfd-b079-234395a30cc7_1171x1232.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/E4eHe6XDiG9tvRYqg2sZ?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>A good interface:</p><ul><li><p>Follows <strong>clear naming conventions</strong> (nouns for resources, verbs for actions).</p></li><li><p>Uses <strong>predictable URI structures</strong> (e.g., <code>/users/123/orders</code>).</p></li><li><p>Provides <strong>useful and consistent HTTP status codes</strong> (e.g., <code>200 OK</code>, <code>201 Created</code>, <code>404 Not Found</code>).</p></li></ul><p>&#128204; <em>Tip</em>: Treat your API as a product. Even if internal, others will consume it, making their experience intuitive.</p><h2><strong>2 - API Paradigms</strong></h2><p>There&#8217;s no one-size-fits-all API style. The best choice depends on the use case, performance needs, and client flexibility.</p><p>Here are the most common paradigms:</p><ul><li><p><strong>REST (Representational State Transfer)</strong>: Resource-based, stateless, widely used. Ideal for CRUD operations and simplicity.</p></li><li><p><strong>GraphQL</strong>: Flexible query-based paradigm where clients define the shape of the response. Great for reducing over-fetching or under-fetching of data.</p></li><li><p><strong>gRPC</strong>: High-performance, binary-based RPC protocol developed by Google. Ideal for internal service-to-service communication, especially in high-throughput systems.</p></li></ul><p>Each has trade-offs:</p><ul><li><p>REST is easy to understand and cacheable.</p></li><li><p>GraphQL is client-flexible but complex to secure.</p></li><li><p>gRPC is blazing fast but not browser-native.</p></li></ul><p>Choose the paradigm that best aligns with your goals&#8212;don&#8217;t force everything into REST just because it&#8217;s common.</p><h2><strong>3 - Modeling Relationships</strong></h2><p>In most real-world systems, entities don&#8217;t exist in isolation. A user has multiple orders, a blog post has comments, a product has reviews.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GBqM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GBqM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.png 424w, https://substackcdn.com/image/fetch/$s_!GBqM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.png 848w, https://substackcdn.com/image/fetch/$s_!GBqM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.png 1272w, https://substackcdn.com/image/fetch/$s_!GBqM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GBqM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.png" width="1456" height="597" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:597,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:72678,&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://newsletter.systemdesigncodex.com/i/162853625?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.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_!GBqM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.png 424w, https://substackcdn.com/image/fetch/$s_!GBqM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.png 848w, https://substackcdn.com/image/fetch/$s_!GBqM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.png 1272w, https://substackcdn.com/image/fetch/$s_!GBqM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741751c9-b782-419c-bbf9-8fe690790ff8_1461x599.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"><a href="https://app.eraser.io/workspace/E4eHe6XDiG9tvRYqg2sZ?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>Your API should make <strong>these relationships clear and accessible</strong>.</p><h3><strong>Example:</strong></h3><p>Instead of:</p><pre><code><code>GET /orders?userId=123</code></code></pre><p>Prefer:</p><pre><code><code>GET /users/123/orders</code></code></pre><p>This conveys the hierarchy and makes the relationship between resources explicit. It also improves discoverability and maintains <strong>semantic clarity</strong> in your endpoints.</p><p>For GraphQL, relationships are naturally expressed in the schema and resolved on demand:</p><pre><code><code>{
  user(id: "123") {
    name
    orders {
      id
      amount
    }
  }
}</code></code></pre><p>Maintaining a clear, logical structure in how your API presents relationships improves both usability and maintainability.</p><h2><strong>4 - Versioning</strong></h2><p>APIs evolve. New features are added, bugs are fixed, data models change. But existing clients may still rely on older behaviors. That&#8217;s why <strong>versioning</strong> is essential.</p><p>There are a few common strategies:</p><ul><li><p><strong>URI versioning</strong>: <code>/v1/users</code>, <code>/v2/users</code></p></li><li><p><strong>Header versioning</strong>: <code>Accept: application/vnd.myapi.v2+json</code></p></li><li><p><strong>Query param versioning</strong>: <code>/users?version=2</code></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_!wqoE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wqoE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.png 424w, https://substackcdn.com/image/fetch/$s_!wqoE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.png 848w, https://substackcdn.com/image/fetch/$s_!wqoE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.png 1272w, https://substackcdn.com/image/fetch/$s_!wqoE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wqoE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.png" width="986" height="888" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:888,&quot;width&quot;:986,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:60450,&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://newsletter.systemdesigncodex.com/i/162853625?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.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_!wqoE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.png 424w, https://substackcdn.com/image/fetch/$s_!wqoE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.png 848w, https://substackcdn.com/image/fetch/$s_!wqoE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.png 1272w, https://substackcdn.com/image/fetch/$s_!wqoE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e01feda-51af-42cd-823a-cd9f63720ab8_986x888.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"><a href="https://app.eraser.io/workspace/E4eHe6XDiG9tvRYqg2sZ?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>The goal is to:</p><ul><li><p>Avoid breaking existing clients.</p></li><li><p>Communicate clearly that a change has occurred.</p></li><li><p>Allow parallel support for legacy and modern clients.</p></li></ul><p>&#128204; <em>Tip</em>: Only bump a version when there&#8217;s a <strong>breaking change</strong>. Try to evolve APIs <strong>additively</strong> where possible.</p><h2><strong>5 - Rate Limiting</strong></h2><p>Without rate limiting, a single client could overload your system with thousands of requests per second, whether by accident or maliciously.</p><p><strong>Rate limiting</strong> controls how many requests a client can make in a given time window (e.g., 100 requests per minute). This protects your backend and ensures fair usage across consumers.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zGC4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zGC4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.png 424w, https://substackcdn.com/image/fetch/$s_!zGC4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.png 848w, https://substackcdn.com/image/fetch/$s_!zGC4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.png 1272w, https://substackcdn.com/image/fetch/$s_!zGC4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zGC4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.png" width="1456" height="461" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:461,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:124803,&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://newsletter.systemdesigncodex.com/i/162853625?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.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_!zGC4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.png 424w, https://substackcdn.com/image/fetch/$s_!zGC4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.png 848w, https://substackcdn.com/image/fetch/$s_!zGC4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.png 1272w, https://substackcdn.com/image/fetch/$s_!zGC4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa674d8c0-8cc6-4104-b9f7-6bc83b797f8b_2312x732.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"><a href="https://app.eraser.io/workspace/E4eHe6XDiG9tvRYqg2sZ?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>Common techniques:</p><ul><li><p><strong>Fixed window</strong>: Simple count per time bucket.</p></li><li><p><strong>Sliding window</strong>: Smoother traffic shaping.</p></li><li><p><strong>Token bucket</strong>: Allows occasional bursts within a defined limit.</p></li></ul><p>Rate limits are often communicated using headers:</p><pre><code><code>X-RateLimit-Limit: 100
X-RateLimit-Remaining: 20
X-RateLimit-Reset: 1650000000</code></code></pre><p>You can apply different limits based on:</p><ul><li><p>API key or access token</p></li><li><p>User role (e.g., free vs. paid)</p></li><li><p>Endpoint type (e.g., heavy vs. light operations)</p></li></ul><p>&#128204; <em>Pro Tip</em>: Always document your rate limits and include them in your API responses.</p><p>&#128073; <strong>So, which other key considerations do you keep while designing APIs?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-to-design-apis/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/how-to-design-apis/comments"><span>Leave a comment</span></a></p><div><hr></div><h1><strong>Shoutout</strong></h1><p>Here are some interesting articles I&#8217;ve read recently:</p><ul><li><p><a href="https://strategizeyourcareer.com/p/the-10-software-engineering-acronyms?r=1m1f9z&amp;utm_campaign=post&amp;utm_medium=web&amp;showWelcomeOnShare=false">The 10 Software Engineering Acronyms You MUST Know</a> by<strong> </strong><a href="https://open.substack.com/users/170998285-fran-soto?utm_source=mentions">Fran Soto</a></p></li><li><p><a href="https://newsletter.systemdesignclassroom.com/p/every-outbox-needs-an-inbox?r=1m1f9z&amp;utm_campaign=post&amp;utm_medium=web&amp;showWelcomeOnShare=false">Every Outbox Needs an Inbox</a> by <a href="https://open.substack.com/users/98661477-raul-junco?utm_source=mentions">Raul Junco</a></p></li><li><p><a href="https://open.substack.com/pub/hungrymindsdev/p/how-a-single-zip-file-saved-my-server?r=1m1f9z&amp;utm_campaign=post&amp;utm_medium=web&amp;showWelcomeOnShare=false">How A Single ZIP File Saved My Server From 1000s of Attacks (Code Inside)</a><strong> </strong>by<strong> </strong><a href="https://open.substack.com/users/23673358-alexandre-zajac?utm_source=mentions">Alexandre Zajac</a></p></li><li><p><a href="https://newsletter.francofernando.com/p/hashing-in-coding-interviews?r=1m1f9z&amp;utm_campaign=post&amp;utm_medium=web&amp;showWelcomeOnShare=false">Hashing in Coding Interviews</a> by <a href="https://open.substack.com/users/47169986-franco-fernando?utm_source=mentions">Franco Fernando</a></p></li></ul><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-to-design-apis?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.systemdesigncodex.com/p/how-to-design-apis?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p>]]></content:encoded></item><item><title><![CDATA[How to Move from Monolith to a Service Based Architecture]]></title><description><![CDATA[Strategies worth knowing]]></description><link>https://newsletter.systemdesigncodex.com/p/how-to-move-from-monolith-to-a-service</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/how-to-move-from-monolith-to-a-service</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 26 May 2026 07:58:51 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!dc_j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Moving from a monolithic architecture&#8212;where all functionality is bundled together&#8212;into a microservices architecture isn&#8217;t a flip of a switch. It&#8217;s a complex journey that, if done recklessly, can cause more harm than good.</p><p>That&#8217;s why smart teams follow specific transition patterns. These patterns help reduce risk, maintain stability, and allow the system to evolve gradually rather than completely rebuild.</p><p>Here are 4 such patterns that can help you:</p><h2><strong>1 - Strangler Fig Pattern</strong></h2><p>The Strangler Fig Pattern is perhaps the most famous strategy for modernizing monolithic systems. It&#8217;s inspired by how a strangler fig tree grows around an existing tree, eventually replacing it.</p><h3><strong>How It Works:</strong></h3><ul><li><p>An API gateway or proxy is placed in front of the monolith.</p></li><li><p>New features or refactored versions of existing features are developed as independent microservices.</p></li><li><p>The gateway routes requests:</p><ul><li><p>To the monolith for old functionality.</p></li><li><p>To the new microservices for updated functionality.</p></li></ul></li><li><p>Over time, as more functionality is moved out, the monolith shrinks until it can be retired.</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_!dc_j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dc_j!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 424w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 848w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 1272w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dc_j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png" width="1456" height="1928" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1928,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1125530,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesigncodex.com/i/162377004?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.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_!dc_j!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 424w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 848w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.png 1272w, https://substackcdn.com/image/fetch/$s_!dc_j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac89744a-2f7b-4ed6-9bd4-1bc070a88881_3420x4528.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/ZYjvO92sJEJvJ4AeSdu1?origin=share">You can play around with the image on Eraser.io</a></figcaption></figure></div><h3><strong>Why It&#8217;s Powerful:</strong></h3><ul><li><p>Incremental migration with minimal disruption.</p></li><li><p>Reduces the big-bang rewrite risk.</p></li><li><p>You can prioritize extracting high-value or high-risk components first.</p></li></ul><blockquote><blockquote><p>Real-world use: Many enterprises use this approach when dealing with legacy systems where complete rewrites would be risky and expensive.</p></blockquote></blockquote><div><hr></div><h2><strong>2 - Parallel Run Pattern</strong></h2><p>The Parallel Run Pattern involves running the old monolith and new microservices together for a period of time. Instead of replacing immediately, you redirect a portion of traffic to microservices to validate their behavior.</p><h3><strong>How It Works:</strong></h3><ul><li><p>Both the monolith and the new microservices are deployed simultaneously.</p></li><li><p>Certain user requests or workflows are mirrored or split-routed:</p><ul><li><p>Some go to the monolith.</p></li><li><p>Some go to the microservices.</p></li></ul></li><li><p>The output or behavior is compared to ensure that the new system is functionally equivalent.</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_!jkhR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jkhR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 424w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 848w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 1272w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jkhR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png" width="1369" height="1020" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1020,&quot;width&quot;:1369,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:120877,&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://newsletter.systemdesigncodex.com/i/162377004?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.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_!jkhR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 424w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 848w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.png 1272w, https://substackcdn.com/image/fetch/$s_!jkhR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803c0f37-c610-4f2c-8d07-21e44658287d_1369x1020.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"><a href="https://app.eraser.io/workspace/ZYjvO92sJEJvJ4AeSdu1?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Why It&#8217;s Useful:</strong></h3><ul><li><p>Catch errors early before full migration.</p></li><li><p>Allows thorough real-world testing.</p></li><li><p>You can gradually increase traffic to the microservices as confidence builds.</p></li></ul><blockquote><blockquote><p>Pro Tip: Use feature flags and automated comparison testing to make this process smoother.</p></blockquote></blockquote><div><hr></div><h2><strong>3 - The Collaborator Pattern</strong></h2><p>The Collaborator Pattern is a clever way to augment the monolith without touching its core logic immediately. It allows you to extend the system by attaching microservices around it.</p><h3><strong>How It Works:</strong></h3><ul><li><p>Instead of replacing a functionality inside the monolith, you decorate or wrap existing modules with microservices that add new features.</p></li><li><p>The monolith still handles the original core behavior.</p></li><li><p>Microservices add enhanced behavior, enrich responses, or intercept and modify calls.</p></li></ul><h3><strong>Why It&#8217;s Valuable:</strong></h3><ul><li><p>Minimal disruption to the monolith.</p></li><li><p>Let&#8217;s you introduce new functionality faster without waiting for core refactoring.</p></li><li><p>Helps test microservice integration with live traffic early.</p></li></ul><blockquote><blockquote><p><strong>Example:</strong> Suppose you have a monolith that processes orders, but you want to add a new discount service. Instead of modifying the order logic, you add a microservice that &#8220;decorates&#8221; order responses with discount information.</p></blockquote></blockquote><div><hr></div><h2><strong>4 - Change Data Capture (CDC)</strong></h2><p>One of the biggest challenges during a transition is data synchronization. Change Data Capture (CDC) provides a solution by streaming real-time database changes from the monolith to the new microservices.</p><h3><strong>How It Works:</strong></h3><ul><li><p>Tools like Debezium, Kafka Connect, or AWS DMS monitor the monolith&#8217;s database transaction logs.</p></li><li><p>Whenever a change happens (insert, update, delete), the change is captured and streamed to interested microservices.</p></li><li><p>This allows microservices to react in near real-time without needing tight coupling to the monolith&#8217;s database.</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_!H2eS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!H2eS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 424w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 848w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 1272w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!H2eS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png" width="1456" height="695" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:695,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:157197,&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://newsletter.systemdesigncodex.com/i/162377004?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.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_!H2eS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 424w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 848w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.png 1272w, https://substackcdn.com/image/fetch/$s_!H2eS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0ee0abe-ca37-42c0-a3fa-994282c5e005_1932x922.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"><a href="https://app.eraser.io/workspace/ZYjvO92sJEJvJ4AeSdu1?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Why It&#8217;s Critical:</strong></h3><ul><li><p>Enables event-driven architectures during the transition.</p></li><li><p>Allows microservices to maintain their own data stores based on monolith changes.</p></li><li><p>Reduces reliance on synchronous API calls to the monolith.</p></li></ul><blockquote><blockquote><p>Important Tip: Be cautious about schema evolution; changes to the monolith database schema must be carefully coordinated with CDC consumers.</p></blockquote></blockquote><div><hr></div><h2><strong>How These Patterns Work Together</strong></h2><p>Transitioning from a monolith isn&#8217;t about choosing just one pattern&#8212;it&#8217;s about orchestrating them together:</p><ul><li><p>Start with the Strangler Fig to route traffic intelligently.</p></li><li><p>Run critical paths in parallel to build trust in the new system.</p></li><li><p>Decorate existing functionalities to add features without destabilizing the core.</p></li><li><p>Stream changes using CDC to gradually separate data ownership.</p></li></ul><p><strong>So - have you used any of these patterns?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-to-move-from-monolith-to-a-service/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/how-to-move-from-monolith-to-a-service/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-to-move-from-monolith-to-a-service?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.systemdesigncodex.com/p/how-to-move-from-monolith-to-a-service?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p>]]></content:encoded></item><item><title><![CDATA[Database Locking Mechanisms]]></title><description><![CDATA[Pessimistic vs Optimistic]]></description><link>https://newsletter.systemdesigncodex.com/p/database-locking-mechanisms</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/database-locking-mechanisms</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 19 May 2026 06:27:39 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!TfFp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In multi-user applications, where multiple processes or users might attempt to read or update the same data simultaneously, ensuring data consistency and integrity becomes crucial. This is where locking mechanisms come into play.</p><p>Locks help prevent conflicting updates that can lead to issues like lost updates, dirty reads, or phantom reads. However, not all locking strategies are created equal. Two of the most common approaches&#8212;Pessimistic Locking and Optimistic Locking&#8212;offer different trade-offs between safety and performance.</p><p>Let&#8217;s dive into what these strategies are, how they differ, and when you should use one over the other.</p><h2><strong>What Is Pessimistic Locking?</strong></h2><p>Pessimistic locking takes a &#8220;better safe than sorry&#8221; approach. It assumes that conflicts are likely to happen, so it locks the data preemptively before any updates are made.</p><h3><strong>How It Works:</strong></h3><p>When a user or process wants to read and update a piece of data:</p><ol><li><p>It acquires a lock on the data.</p></li><li><p>Other users/processes are blocked from accessing or modifying that data until the lock is released.</p></li><li><p>Once the operation is complete, the lock is released.</p></li></ol><p>This strategy is often enforced at the database level, using exclusive locks (e.g., <code>SELECT ... FOR UPDATE</code> in SQL).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TfFp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TfFp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.png 424w, https://substackcdn.com/image/fetch/$s_!TfFp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.png 848w, https://substackcdn.com/image/fetch/$s_!TfFp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.png 1272w, https://substackcdn.com/image/fetch/$s_!TfFp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TfFp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.png" width="1456" height="2393" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/453eed41-da52-43e0-82d6-229bd15483db_1720x2827.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2393,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:306211,&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://newsletter.systemdesigncodex.com/i/161349484?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.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_!TfFp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.png 424w, https://substackcdn.com/image/fetch/$s_!TfFp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.png 848w, https://substackcdn.com/image/fetch/$s_!TfFp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.png 1272w, https://substackcdn.com/image/fetch/$s_!TfFp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F453eed41-da52-43e0-82d6-229bd15483db_1720x2827.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"><a href="https://app.eraser.io/workspace/vPAIB7ChVQN7jSiwiOoB?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Advantages:</strong></h3><p>&#9989; Guarantees data integrity&#8212;conflicts are prevented before they can happen.<br><br>&#9989; Ideal for critical updates, such as financial transactions or inventory management.</p><h3><strong>Disadvantages:</strong></h3><p>&#10060; Reduces concurrency&#8212;other users may be blocked, even if they want to read the data.<br><br>&#10060; Can lead to deadlocks if multiple processes wait on each other&#8217;s locks.<br><br>&#10060; Affects system performance under high contention.</p><h3><strong>Best Used For:</strong></h3><ul><li><p>Systems with high contention on the same data.</p></li><li><p>Workloads that require strong consistency, like banking or booking systems.</p></li></ul><h2><strong>What Is Optimistic Locking?</strong></h2><p>Optimistic locking takes a &#8220;conflicts are rare&#8221; approach. Instead of locking data up front, it allows multiple users to access and even modify the same data concurrently, and checks for conflicts only at commit time.</p><h3><strong>How It Works:</strong></h3><ol><li><p>When data is read, its version number or timestamp is recorded.</p></li><li><p>The user modifies the data without acquiring a lock.</p></li><li><p>When trying to write the update back:</p><ul><li><p>The system checks whether the version number or timestamp has changed since it was read.</p></li><li><p>If unchanged &#8594; update is applied.</p></li><li><p>If changed &#8594; conflict is detected &#8594; operation is aborted or retried.</p></li></ul></li></ol><p>This is commonly implemented in application code or supported by ORM frameworks like Hibernate, Entity Framework, etc.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IzL2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IzL2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.png 424w, https://substackcdn.com/image/fetch/$s_!IzL2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.png 848w, https://substackcdn.com/image/fetch/$s_!IzL2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.png 1272w, https://substackcdn.com/image/fetch/$s_!IzL2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IzL2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.png" width="1456" height="2515" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2515,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:321640,&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://newsletter.systemdesigncodex.com/i/161349484?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.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_!IzL2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.png 424w, https://substackcdn.com/image/fetch/$s_!IzL2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.png 848w, https://substackcdn.com/image/fetch/$s_!IzL2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.png 1272w, https://substackcdn.com/image/fetch/$s_!IzL2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa877ed87-f584-484a-bd32-3781d4b284ce_1637x2828.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"><a href="https://app.eraser.io/workspace/vPAIB7ChVQN7jSiwiOoB?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Advantages:</strong></h3><p>&#9989; Allows high concurrency and throughput, as there are no locks during read and modify phases.<br><br>&#9989; Avoids blocking and deadlock scenarios.<br><br>&#9989; Ideal for read-heavy applications with low conflict rates.</p><h3><strong>Disadvantages:</strong></h3><p>&#10060; Requires retry logic for failed transactions.<br><br>&#10060; May lead to wasted computation if conflicts are detected late.<br><br>&#10060; Not suitable for high-conflict scenarios.</p><h3><strong>Best Used For:</strong></h3><ul><li><p>Applications with many reads and few writes (e.g., social media feeds, reporting dashboards).</p></li><li><p>Distributed systems where locking is expensive or impractical.</p></li></ul><h2><strong>Best Practices for Using Locking Mechanisms</strong></h2><p>Whether you&#8217;re using pessimistic or optimistic locking, here are some tips to ensure your locking strategy works effectively:</p><ol><li><p><strong>Hold Locks for the Minimum Time Possible</strong></p><ul><li><p>Long-held locks reduce concurrency and increase the risk of contention or deadlocks.</p></li></ul></li><li><p><strong>Use Fine-Grained Locking</strong></p><ul><li><p>Lock only what&#8217;s necessary. For example, prefer row-level locks over table-level locks to reduce lock scope.</p></li></ul></li><li><p><strong>Implement Retry Logic (for Optimistic Locking)</strong></p><ul><li><p>Always anticipate that a commit may fail and prepare to retry the operation with the latest data.</p></li></ul></li><li><p><strong>Monitor and Tune Locking Behavior</strong></p><ul><li><p>Use database tools and logs to detect high lock wait times or deadlocks.</p></li></ul></li><li><p><strong>Choose Based on Your Data Patterns</strong></p><ul><li><p>If users are frequently updating the same records, pessimistic locking may be safer.</p></li><li><p>If updates are rare or distributed, optimistic locking will give you better performance.</p></li></ul></li></ol><p>So - which locking strategy have you used the most?</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/database-locking-mechanisms/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/database-locking-mechanisms/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/database-locking-mechanisms?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.systemdesigncodex.com/p/database-locking-mechanisms?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Top Deployment Strategies]]></title><description><![CDATA[Every developer should know these]]></description><link>https://newsletter.systemdesigncodex.com/p/top-deployment-strategies</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/top-deployment-strategies</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 12 May 2026 07:05:17 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!3QNJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Deploying new features to an application is one of the most sensitive stages in the software development lifecycle. A small mistake during deployment can lead to downtime, data loss, or a broken experience for your users. On the other hand, a well-chosen deployment strategy can ensure minimal risk, zero downtime, and faster feedback loops.</p><p>In this article, we&#8217;ll dive into five popular deployment strategies.</p><h2><strong>1 - Blue/Green Deployment</strong></h2><p>Blue/Green deployment is a zero-downtime strategy that uses two identical environments: Blue (live) and Green (staging/next).</p><h3><strong>How It Works:</strong></h3><ul><li><p>The Blue environment runs the current production version.</p></li><li><p>The new version is deployed to the Green environment, which is isolated from users.</p></li><li><p>After thorough testing, traffic is redirected from Blue to Green via the load balancer or DNS change.</p></li><li><p>If a problem is discovered, traffic can quickly be switched back to Blue.</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_!3QNJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3QNJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.png 424w, https://substackcdn.com/image/fetch/$s_!3QNJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.png 848w, https://substackcdn.com/image/fetch/$s_!3QNJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.png 1272w, https://substackcdn.com/image/fetch/$s_!3QNJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3QNJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.png" width="1134" height="720" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:720,&quot;width&quot;:1134,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:101162,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesigncodex.com/i/160170171?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.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_!3QNJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.png 424w, https://substackcdn.com/image/fetch/$s_!3QNJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.png 848w, https://substackcdn.com/image/fetch/$s_!3QNJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.png 1272w, https://substackcdn.com/image/fetch/$s_!3QNJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecf0fd13-d140-452e-9cb7-3372460d3e94_1134x720.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/uvsMPGovFMdljgRje9Mc?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Pros:</strong></h3><p>&#9989; Enables instant rollback.<br><br>&#9989; Ensures a seamless user experience with no downtime.<br><br>&#9989; Both environments can be tested independently.</p><h3><strong>Cons:</strong></h3><p>&#10060; Requires double the infrastructure, which increases cost.<br><br>&#10060; Managing two environments adds operational complexity.</p><h3><strong>Best For:</strong></h3><ul><li><p>Applications requiring zero downtime (e.g., fintech, healthcare).</p></li><li><p>Mission-critical production environments.</p></li></ul><h2><strong>2 - Canary Deployment</strong></h2><p>Inspired by canary birds in coal mines, canary deployment rolls out new changes to a small subset of users first, allowing you to monitor and validate the new version before a full-scale rollout.</p><h3><strong>How It Works:</strong></h3><ul><li><p>Deploy the new version to a small group (e.g., 1-5% of users or traffic).</p></li><li><p>Monitor for errors, latency, performance, and user behavior.</p></li><li><p>Gradually increase exposure&#8212;10%, 25%, 50%, until 100%.</p></li><li><p>If something goes wrong, roll back quickly before most users are affected.</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_!hw3U!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hw3U!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.png 424w, https://substackcdn.com/image/fetch/$s_!hw3U!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.png 848w, https://substackcdn.com/image/fetch/$s_!hw3U!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.png 1272w, https://substackcdn.com/image/fetch/$s_!hw3U!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hw3U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.png" width="1161" height="952" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:952,&quot;width&quot;:1161,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:123155,&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://newsletter.systemdesigncodex.com/i/160170171?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.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_!hw3U!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.png 424w, https://substackcdn.com/image/fetch/$s_!hw3U!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.png 848w, https://substackcdn.com/image/fetch/$s_!hw3U!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.png 1272w, https://substackcdn.com/image/fetch/$s_!hw3U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a16edf-1e90-41c9-b7ba-a4d7b802d05f_1161x952.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"><a href="https://app.eraser.io/workspace/uvsMPGovFMdljgRje9Mc?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Pros:</strong></h3><p>&#9989; Helps catch issues early with minimal user impact.<br><br>&#9989; Enables progressive delivery.<br><br>&#9989; Reduces blast radius of failure.</p><h3><strong>Cons:</strong></h3><p>&#10060; Requires careful monitoring and alerting.<br><br>&#10060; Slightly more complex to automate and test.<br><br>&#10060; Choosing a representative canary group is crucial and non-trivial.</p><h3><strong>Best For:</strong></h3><ul><li><p>Large-scale applications where instant full rollouts are risky.</p></li><li><p>SaaS platforms needing <strong>real-world validation</strong> before going live.</p></li></ul><h2><strong>3 - A/B Testing</strong></h2><p>While not strictly a deployment strategy, A/B testing can be used as part of your release process when you want to compare different variations of a feature and measure which one performs better.</p><h3><strong>How It Works:</strong></h3><ul><li><p>Two or more variations (A, B, &#8230;) of a feature are deployed.</p></li><li><p>Users are split into random test groups, each interacting with a different version.</p></li><li><p>User engagement metrics like click-through rate, conversion, retention are tracked.</p></li><li><p>The winner is chosen based on data, and the best version becomes the default.</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_!vZKu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vZKu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.png 424w, https://substackcdn.com/image/fetch/$s_!vZKu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.png 848w, https://substackcdn.com/image/fetch/$s_!vZKu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.png 1272w, https://substackcdn.com/image/fetch/$s_!vZKu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vZKu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.png" width="1406" height="690" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:690,&quot;width&quot;:1406,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:75443,&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://newsletter.systemdesigncodex.com/i/160170171?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.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_!vZKu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.png 424w, https://substackcdn.com/image/fetch/$s_!vZKu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.png 848w, https://substackcdn.com/image/fetch/$s_!vZKu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.png 1272w, https://substackcdn.com/image/fetch/$s_!vZKu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcadb47-f950-485d-b5c0-f597371e9546_1406x690.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"><a href="https://app.eraser.io/workspace/uvsMPGovFMdljgRje9Mc?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Pros:</strong></h3><p>&#9989; Allows data-driven decisions.<br><br>&#9989; Great for validating UX, UI, or feature effectiveness.<br><br>&#9989; Works well with analytics tools and experimentation platforms.</p><h3><strong>Cons:</strong></h3><p>&#10060; Needs large user base to draw statistically significant conclusions.<br><br>&#10060; Can lead to technical debt if multiple experiments run in parallel without clean-up.<br><br>&#10060; Managing state and consistency between versions can be tricky.</p><h3><strong>Best For:</strong></h3><ul><li><p>B2C products focusing on user behavior optimization.</p></li><li><p>Experiment-driven product teams.</p></li></ul><h2><strong>4 - Feature Flag Deployment</strong></h2><p>Feature flags (also known as feature toggles) are a powerful way to deploy code without activating it immediately. Think of them as remote-controlled switches for turning features on or off.</p><h3><strong>How It Works:</strong></h3><ul><li><p>New features are deployed behind a feature flag, which controls whether the code is active or hidden.</p></li><li><p>Flags can be toggled for specific users, teams, or environments.</p></li><li><p>They can be used in combination with Canary, A/B testing, or staged rollouts.</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_!LhVT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LhVT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.png 424w, https://substackcdn.com/image/fetch/$s_!LhVT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.png 848w, https://substackcdn.com/image/fetch/$s_!LhVT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.png 1272w, https://substackcdn.com/image/fetch/$s_!LhVT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LhVT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.png" width="1456" height="608" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:608,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:114810,&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://newsletter.systemdesigncodex.com/i/160170171?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.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_!LhVT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.png 424w, https://substackcdn.com/image/fetch/$s_!LhVT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.png 848w, https://substackcdn.com/image/fetch/$s_!LhVT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.png 1272w, https://substackcdn.com/image/fetch/$s_!LhVT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed725ec-5884-4605-839b-d16e8becbd19_2001x835.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"><a href="https://app.eraser.io/workspace/uvsMPGovFMdljgRje9Mc?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Pros:</strong></h3><p>&#9989; Allows safe deployment with delayed exposure.<br><br>&#9989; Enables continuous integration and faster releases.<br><br>&#9989; Supports experimentation and rollback without redeploying.</p><h3><strong>Cons:</strong></h3><p>&#10060; Managing many flags can be complex&#8212;especially across teams.<br><br>&#10060; Risk of stale flags if not removed post-release.<br><br>&#10060; Requires discipline and tools to manage flag lifecycle (e.g., LaunchDarkly, Unleash).</p><h3><strong>Best For:</strong></h3><ul><li><p>Teams practicing continuous delivery.</p></li><li><p>Environments where experiments and granular rollouts are common.</p></li></ul><h2><strong>5 - Rolling Deployment</strong></h2><p>A Rolling Deployment replaces old application versions with new ones incrementally, usually one server or pod at a time. It&#8217;s commonly used in Kubernetes, AWS ECS, or traditional VM-based deployments.</p><h3><strong>How It Works:</strong></h3><ul><li><p>The load balancer directs traffic only to healthy instances.</p></li><li><p>A subset of instances is taken offline and updated.</p></li><li><p>Once healthy, traffic resumes, and the next batch is updated.</p></li><li><p>The process continues until all instances are updated.</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_!DHW1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DHW1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.png 424w, https://substackcdn.com/image/fetch/$s_!DHW1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.png 848w, https://substackcdn.com/image/fetch/$s_!DHW1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.png 1272w, https://substackcdn.com/image/fetch/$s_!DHW1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DHW1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.png" width="1456" height="854" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:854,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:129986,&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://newsletter.systemdesigncodex.com/i/160170171?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.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_!DHW1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.png 424w, https://substackcdn.com/image/fetch/$s_!DHW1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.png 848w, https://substackcdn.com/image/fetch/$s_!DHW1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.png 1272w, https://substackcdn.com/image/fetch/$s_!DHW1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b4ba1-cc18-4338-8ecf-c0f3d5b1c77e_1459x856.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"><a href="https://app.eraser.io/workspace/uvsMPGovFMdljgRje9Mc?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Pros:</strong></h3><p>&#9989; Reduces downtime during updates.<br><br>&#9989; No need for duplicate environments like Blue/Green.<br><br>&#9989; Well-suited for containerized and microservice environments.</p><h3><strong>Cons:</strong></h3><p>&#10060; May cause temporary inconsistencies (e.g., different versions running simultaneously).<br><br>&#10060; Rollback is harder than with Blue/Green, especially mid-deployment.<br><br>&#10060; Can lead to incompatible states if changes aren&#8217;t backward compatible.</p><h3><strong>Best For:</strong></h3><ul><li><p>Applications where zero downtime is needed, but budget or simplicity rules out Blue/Green.</p></li><li><p>Kubernetes-native deployments.</p></li></ul><h2><strong>Choosing the Right Strategy</strong></h2><p>There&#8217;s no one-size-fits-all deployment strategy. Your choice depends on:</p><ul><li><p>Downtime tolerance</p></li><li><p>User base size and segmentation</p></li><li><p>Infrastructure complexity</p></li><li><p>Cost constraints</p></li><li><p>Need for experimentation and analytics</p></li></ul><p><strong>&#128073; So - which deployment strategies have you used?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/top-deployment-strategies/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/top-deployment-strategies/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/top-deployment-strategies?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.systemdesigncodex.com/p/top-deployment-strategies?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p>]]></content:encoded></item><item><title><![CDATA[How Terraform Works]]></title><description><![CDATA[Step by step]]></description><link>https://newsletter.systemdesigncodex.com/p/how-terraform-works</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/how-terraform-works</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 05 May 2026 07:41:46 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!WTAN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Managing infrastructure manually is not just inefficient&#8212;it&#8217;s also prone to human error, inconsistencies, and scalability issues.</p><p>Terraform is one tool that makes this task easy.</p><p>Whether you&#8217;re setting up a single virtual machine or orchestrating hundreds of microservices, Terraform helps you scale infrastructure efficiently and reliably.</p><p>Here&#8217;s a quick introduction to how it works. The diagram below shows the complete flow:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WTAN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WTAN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.png 424w, https://substackcdn.com/image/fetch/$s_!WTAN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.png 848w, https://substackcdn.com/image/fetch/$s_!WTAN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.png 1272w, https://substackcdn.com/image/fetch/$s_!WTAN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WTAN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.png" width="1456" height="1456" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.png&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;:326238,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesigncodex.com/i/159656142?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.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_!WTAN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.png 424w, https://substackcdn.com/image/fetch/$s_!WTAN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.png 848w, https://substackcdn.com/image/fetch/$s_!WTAN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.png 1272w, https://substackcdn.com/image/fetch/$s_!WTAN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de7f00b-4ce1-4b7c-8d0b-1a912c58eef4_2395x2395.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/4hvopAXHfFrnWgE0vXXp?origin=share">The diagram has been generated using Eraser&#8217;s AI diagram feature</a></figcaption></figure></div><h2><strong>Stage 1: Write Infrastructure as Code</strong></h2><p>At the heart of Terraform is the concept of Infrastructure as Code (IaC). Instead of provisioning resources manually through cloud dashboards or CLI tools, you describe your infrastructure in <code>.tf</code> files using the HashiCorp Configuration Language (HCL).</p><h3><strong>Key Elements:</strong></h3><ul><li><p><strong>Resources:</strong> Define infrastructure components like EC2 instances, S3 buckets, load balancers, or Kubernetes clusters.</p></li><li><p><strong>Providers:</strong> Define which platform you are provisioning resources in&#8212;AWS, Azure, GCP, etc.</p></li><li><p><strong>Variables:</strong> Allow parameterization of your code to support reusability and flexibility.</p></li><li><p><strong>Modules:</strong> Group common resource configurations into reusable building blocks. Modules can be custom-built or pulled from the Terraform Registry, which hosts hundreds of community-verified modules.</p></li></ul><p>See the below example of a terraform configuration</p><pre><code><code>provider "aws" {
  region = "us-east-1"
}

resource "aws_instance" "web" {
  ami           = var.ami_id
  instance_type = "t2.micro"
}</code></code></pre><p>This simple example defines a web server in AWS, using a variable for the AMI ID.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ADZ4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ADZ4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.png 424w, https://substackcdn.com/image/fetch/$s_!ADZ4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.png 848w, https://substackcdn.com/image/fetch/$s_!ADZ4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.png 1272w, https://substackcdn.com/image/fetch/$s_!ADZ4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ADZ4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.png" width="1045" height="1070" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1070,&quot;width&quot;:1045,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:66780,&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://newsletter.systemdesigncodex.com/i/159656142?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.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_!ADZ4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.png 424w, https://substackcdn.com/image/fetch/$s_!ADZ4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.png 848w, https://substackcdn.com/image/fetch/$s_!ADZ4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.png 1272w, https://substackcdn.com/image/fetch/$s_!ADZ4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8529dc7b-d0a1-411b-9087-6c724ac822f9_1045x1070.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"><a href="https://app.eraser.io/workspace/4hvopAXHfFrnWgE0vXXp?origin=share">The diagram has been generated using Eraser&#8217;s AI diagram feature</a></figcaption></figure></div><p>In larger projects, you can organize your infrastructure into multiple environments (dev, staging, prod) using modules and workspaces.</p><h2><strong>Stage 2: Terraform Plan &#8211; Preview Before Execution</strong></h2><p>After writing your configuration, you need to understand what changes Terraform will make. That&#8217;s where <code>terraform plan</code> comes in.</p><h3><strong>How It Works:</strong></h3><ul><li><p>Terraform reads your current state from a state file (we&#8217;ll come back to this later).</p></li><li><p>It compares the desired state defined in your <code>.tf</code> files with the actual state of resources.</p></li><li><p>It then generates an execution plan, showing what resources will be created, updated, or destroyed.</p></li></ul><p>This gives you a safe, auditable preview of what Terraform intends to do&#8212;no surprises.</p><h3><strong>Why It Matters:</strong></h3><ul><li><p>Prevents unintended changes.</p></li><li><p>Can be automated in CI/CD pipelines to enforce consistency across environments.</p></li><li><p>Detects drift between actual and declared infrastructure state.</p></li></ul><p>In a collaborative workflow, running <code>terraform plan</code> in a pull request helps your team review proposed infrastructure changes just like they would with application code.</p><h2><strong>Stage 3: Terraform Apply &#8211; Provision Infrastructure</strong></h2><p>Once the plan is approved, it&#8217;s time to apply the changes using <code>terraform apply</code>.</p><h3><strong>What Happens During Apply:</strong></h3><ul><li><p>Terraform uses the execution plan to make API calls to the appropriate cloud provider(s).</p></li><li><p>It provisions, updates, or destroys infrastructure as needed.</p></li><li><p>As each action completes, Terraform updates the state file to reflect the new current state of the infrastructure.</p></li></ul><p>Terraform is idempotent, meaning you can apply the same configuration multiple times and it won&#8217;t duplicate resources. It only changes what&#8217;s necessary.</p><h3><strong>Providers Supported:</strong></h3><p>Terraform supports dozens of providers, including:</p><ul><li><p><strong>Cloud platforms</strong>: AWS, GCP, Azure, Oracle Cloud</p></li><li><p><strong>Containers and orchestration</strong>: Kubernetes, Docker</p></li><li><p><strong>Monitoring</strong>: Datadog, New Relic</p></li><li><p><strong>Databases</strong>: PostgreSQL, MySQL</p></li><li><p><strong>Others</strong>: GitHub, Vault, Consul</p></li></ul><p>This wide support makes Terraform ideal for managing <strong>entire ecosystems</strong> in a unified way.</p><h2><strong>Stage 4: Infrastructure Ready &#8211; The Role of State</strong></h2><p>Once resources are provisioned, Terraform maintains a state file (usually <code>terraform.tfstate</code>) that acts as the single source of truth for the deployed infrastructure.</p><h3><strong>Why State Matters:</strong></h3><ul><li><p>Tracks the current configuration and status of all resources.</p></li><li><p>Enables Terraform to understand what changes need to happen in future runs.</p></li><li><p>Allows collaboration across teams using remote backends like Terraform Cloud, S3 with DynamoDB, or Azure Storage.</p></li></ul><p>For teams, storing state remotely with locking mechanisms ensures that only one person (or pipeline) modifies infrastructure at a time&#8212;preventing race conditions and accidental overwrites.</p><h2><strong>Scaling with Terraform</strong></h2><p>Terraform scales easily from a single developer managing a test environment to enterprise teams managing hundreds of services across regions. Here&#8217;s how:</p><ul><li><p><strong>Modular design:</strong> You can create reusable modules and compose them into larger systems.</p></li><li><p><strong>Automated pipelines:</strong> Easily integrated into CI/CD for consistent deployment.</p></li><li><p><strong>Multi-cloud capability:</strong> Manage AWS, GCP, and Azure from a single configuration base.</p></li><li><p><strong>Drift detection and rollback:</strong> Stay in sync with real-world infrastructure.</p></li></ul><p>&#128073; <strong>So - have you used Terraform?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-terraform-works/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/how-terraform-works/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-terraform-works?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.systemdesigncodex.com/p/how-terraform-works?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Top Cache Eviction Strategies]]></title><description><![CDATA[Caching is a crucial technique for improving application performance and responsiveness.]]></description><link>https://newsletter.systemdesigncodex.com/p/top-cache-eviction-strategies</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/top-cache-eviction-strategies</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 28 Apr 2026 09:03:41 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!lA9a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Caching is a crucial technique for improving application performance and responsiveness. By storing frequently accessed data in memory, caching reduces database load and minimizes latency, leading to faster application responses.</p><p>However, cache memory is limited, and when it reaches capacity, some data must be removed to make space for new entries.</p><p>This process is known as cache eviction.</p><p>Choosing the right cache eviction strategy can significantly impact performance, memory efficiency, and hit rates. Let&#8217;s look at the most popular strategies.</p><h2><strong>1 - Time-to-Live (TTL)</strong></h2><h3><strong>How TTL Works</strong></h3><ul><li><p>Each cached item is assigned a fixed expiration time.</p></li><li><p>Once the time period expires, the item is automatically removed, regardless of how frequently it is accessed.</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_!lA9a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lA9a!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!lA9a!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!lA9a!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!lA9a!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lA9a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.png" width="1456" height="996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:181460,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://newsletter.systemdesigncodex.com/i/158262308?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.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_!lA9a!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!lA9a!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!lA9a!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!lA9a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72f80b8a-9b2b-4085-aad7-99839caffb56_1929x1319.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/OybcRzJWp6nB6FLBzWLE?origin=share">You can check the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Best Use Cases</strong></h3><ul><li><p><strong>Session Management:</strong> User login sessions can expire after a set time.</p></li><li><p><strong>Cache Invalidation for APIs:</strong> TTL ensures data freshness by automatically removing outdated responses.</p></li><li><p><strong>DNS Caching:</strong> DNS records use TTL to update host-to-IP mappings periodically.</p></li></ul><h3><strong>Pros</strong></h3><p>&#10004; Simple to implement&#8212;no need to track access frequency.<br><br>&#10004; Ensures automatic cache refresh for time-sensitive data.</p><h3><strong>Cons</strong></h3><p>&#10006; <strong>Premature eviction</strong>&#8212;Frequently accessed data may expire before it&#8217;s needed again.<br><br>&#10006; <strong>Wasted memory</strong>&#8212;Unused data stays in cache until TTL expires, even if it&#8217;s never accessed.</p><h3><strong>Example</strong></h3><pre><code><code># Setting TTL in Redis (Item expires in 30 seconds)
SET user:123 "John Doe"
EXPIRE user:123 30</code></code></pre><p>In Redis, the <code>EXPIRE</code> command ensures the key is removed after 30 seconds.</p><h2><strong>2 - Least-Recently Used (LRU)</strong></h2><h3><strong>How LRU Works</strong></h3><ul><li><p>When the cache is full, the least recently accessed item is evicted first.</p></li><li><p>LRU assumes that recently accessed data is more likely to be accessed again soon (temporal locality).</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_!cbF7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cbF7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!cbF7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!cbF7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!cbF7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cbF7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.png" width="1456" height="996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:213409,&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://newsletter.systemdesigncodex.com/i/158262308?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.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_!cbF7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!cbF7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!cbF7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!cbF7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6682ee3-365a-4bbe-8f89-e4837901dcdb_1929x1319.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"><a href="https://app.eraser.io/workspace/OybcRzJWp6nB6FLBzWLE?origin=share">You can check the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Best Use Cases</strong></h3><ul><li><p><strong>Web Browsers:</strong> Frequently visited web pages remain cached.</p></li><li><p><strong>Database Query Caching:</strong> Frequently executed queries are kept in cache.</p></li><li><p><strong>Operating Systems:</strong> Virtual memory paging systems use LRU to manage RAM efficiently.</p></li></ul><h3><strong>Pros</strong></h3><p>&#10004; <strong>Effective for workloads with temporal locality</strong>&#8212;recently used data remains available.<br><br>&#10004; <strong>Self-adjusting</strong>&#8212;Adapts dynamically to access patterns.</p><h3><strong>Cons</strong></h3><p>&#10006; <strong>High overhead</strong>&#8212;Requires maintaining a linked list or hash map to track usage order.<br><br>&#10006; <strong>Not ideal for cyclic workloads</strong>&#8212;Items accessed at regular intervals may get evicted.</p><h2><strong>3 - Least Frequently Used (LFU) &#8211; Prioritizing Popular Items</strong></h2><h3><strong>How LFU Works</strong></h3><ul><li><p>Each cached item is associated with a frequency counter.</p></li><li><p>When the cache is full, the least frequently accessed item is removed.</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_!poQE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!poQE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!poQE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!poQE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!poQE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!poQE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.png" width="1456" height="996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:192511,&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://newsletter.systemdesigncodex.com/i/158262308?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.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_!poQE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!poQE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!poQE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!poQE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bbe03cc-3c5f-452e-b278-5c7c21759d1a_1929x1319.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"><a href="https://app.eraser.io/workspace/OybcRzJWp6nB6FLBzWLE?origin=share">You can check the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Best Use Cases</strong></h3><ul><li><p><strong>Content Delivery Networks (CDNs):</strong> Frequently accessed content remains cached.</p></li><li><p><strong>E-commerce Product Listings:</strong> Popular products are cached for quick retrieval.</p></li><li><p><strong>Machine Learning Caches:</strong> Keeps frequently used datasets in memory.</p></li></ul><h3><strong>Pros</strong></h3><p>&#10004; Better long-term cache hit rates than LRU in stable workloads.<br><br>&#10004; Ensures popular items remain available, even if they haven&#8217;t been accessed recently.</p><h3><strong>Cons</strong></h3><p>&#10006; More complex to implement&#8212;requires additional metadata to track usage frequency.<br><br>&#10006; <strong>Cold Start Issue</strong>&#8212;Newly added items start with a low count, leading to premature eviction.</p><h2><strong>4 - Most Recently Used (MRU) &#8211; Evicting Fresh Data First</strong></h2><h3><strong>How MRU Works</strong></h3><ul><li><p>The most recently accessed item is evicted first.</p></li><li><p>MRU assumes that new data is less likely to be needed again soon.</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_!06cB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!06cB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!06cB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!06cB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!06cB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!06cB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.png" width="1456" height="996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:214743,&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://newsletter.systemdesigncodex.com/i/158262308?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.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_!06cB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!06cB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!06cB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!06cB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f4f52a7-2104-4fda-9400-071d3d9c075d_1929x1319.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"><a href="https://app.eraser.io/workspace/OybcRzJWp6nB6FLBzWLE?origin=share">You can check the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Best Use Cases</strong></h3><ul><li><p><strong>Streaming Services:</strong> The last-played song or video might not be needed again soon.</p></li><li><p><strong>Batch Processing Systems:</strong> Keeps older results in memory, discarding the newest.</p></li><li><p><strong>Database Caching for Bulk Queries:</strong> Avoids keeping temporary recent queries in cache.</p></li></ul><h3><strong>Pros</strong></h3><p>&#10004; Works well for workloads with minimal temporal locality.<br><br>&#10004; Efficient when older data is more valuable than recently accessed data.</p><h3><strong>Cons</strong></h3><p>&#10006; <strong>Counterintuitive behavior</strong>&#8212;recently accessed items get removed first.<br><br>&#10006; Less effective for general caching scenarios compared to LRU.</p><h3><strong>Example</strong></h3><ul><li><p>A video player cache may use MRU to evict the last-played video first, ensuring older unwatched videos stay cached.</p></li></ul><h2><strong>5 - Segmented LRU (SLRU) &#8211; A Hybrid Approach</strong></h2><h3><strong>How SLRU Works</strong></h3><ul><li><p>The cache is split into two sections:</p><ol><li><p><strong>Probationary Segment:</strong> Stores newly added items.</p></li><li><p><strong>Protected Segment:</strong> Stores frequently accessed items.</p></li></ol></li><li><p>Items promoted from probationary &#8594; protected remain cached longer.</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_!GrB0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GrB0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!GrB0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!GrB0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!GrB0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GrB0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.png" width="1456" height="996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:177561,&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://newsletter.systemdesigncodex.com/i/158262308?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.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_!GrB0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!GrB0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!GrB0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!GrB0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8976939f-cff1-42bf-b562-384cd7d13983_1929x1319.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"><a href="https://app.eraser.io/workspace/OybcRzJWp6nB6FLBzWLE?origin=share">You can check the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Best Use Cases</strong></h3><ul><li><p><strong>Database Caching:</strong> Ensures frequently used queries are prioritized.</p></li><li><p><strong>Hybrid Cache for Dynamic Workloads:</strong> Adapts better than pure LRU or LFU.</p></li><li><p><strong>Large-Scale Distributed Caches:</strong> Used in Memcached and Redis for efficient cache management.</p></li></ul><h3><strong>Pros</strong></h3><p>&#10004; Balances LRU and LFU benefits.<br><br>&#10004; Minimizes frequent eviction of useful data.</p><h3><strong>Cons</strong></h3><p>&#10006; Requires tuning of segment sizes for optimal performance.<br><br>&#10006; Higher memory overhead than simple LRU/LFU.</p><p>So - will you add any other strategy as well?</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/top-cache-eviction-strategies/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/top-cache-eviction-strategies/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/top-cache-eviction-strategies?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.systemdesigncodex.com/p/top-cache-eviction-strategies?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Top Resiliency Patterns for Developers]]></title><description><![CDATA[Quick Guide]]></description><link>https://newsletter.systemdesigncodex.com/p/top-resiliency-patterns-for-developers</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/top-resiliency-patterns-for-developers</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 21 Apr 2026 06:08:56 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!eBaM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Distributed systems are great at providing scalability and high availability to meet user demands.</p><p>But with increased complexity comes greater risk.</p><p>If you are building distributed systems, you must invest in proactive strategies to ensure resiliency. These strategies can be divided into two categories:</p><ul><li><p>Downstream Patterns</p></li><li><p>Upstream Patterns</p></li></ul><p>Let&#8217;s look at both.</p><h1><strong>Downstream Resiliency Patterns</strong></h1><p>Downstream patterns are used by the service caller. They are implemented by a service when it communicates with another service, ensuring that a failure in the downstream system doesn&#8217;t cause a domino effect.</p><h2><strong>1 - Timeouts</strong></h2><p>A timeout is a mechanism that prevents a service from waiting indefinitely for a response from a downstream service. By setting a maximum wait time, you avoid tying up resources that could be used for other requests.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eBaM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eBaM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!eBaM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!eBaM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!eBaM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eBaM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.png" width="1456" height="911" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:911,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:173044,&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;: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_!eBaM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!eBaM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!eBaM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!eBaM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b084659-16be-42d9-ba14-e9b0ef568813_2175x1361.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"><a href="https://app.eraser.io/workspace/8hO96SC5UPofVRnz1mtY?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h4><strong>Why It&#8217;s Important:</strong></h4><ul><li><p>Prevents resource exhaustion caused by requests stuck waiting indefinitely.</p></li><li><p>Improves overall system responsiveness by allowing failed requests to be handled quickly.</p></li></ul><h4><strong>Implementation Tips:</strong></h4><ul><li><p>Fine-tune timeouts based on the expected response times of downstream services. For example, a cache lookup might have a 50ms timeout, while a database query might have a 500ms timeout.</p></li><li><p>Combine timeouts with monitoring to identify latency patterns and adjust as needed.</p></li></ul><h2><strong>2 - Circuit Breaker</strong></h2><p>A circuit breaker monitors the success and failure rates of requests and temporarily disables calls to a service if failures exceed a predefined threshold. Like an electrical circuit breaker, it prevents further damage by &#8220;tripping&#8221; the connection.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!aimz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb06ab6c3-a6e1-471e-9cdd-aa3160e1e8f5_5094x4494.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!aimz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb06ab6c3-a6e1-471e-9cdd-aa3160e1e8f5_5094x4494.png 424w, https://substackcdn.com/image/fetch/$s_!aimz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb06ab6c3-a6e1-471e-9cdd-aa3160e1e8f5_5094x4494.png 848w, https://substackcdn.com/image/fetch/$s_!aimz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb06ab6c3-a6e1-471e-9cdd-aa3160e1e8f5_5094x4494.png 1272w, https://substackcdn.com/image/fetch/$s_!aimz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb06ab6c3-a6e1-471e-9cdd-aa3160e1e8f5_5094x4494.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!aimz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb06ab6c3-a6e1-471e-9cdd-aa3160e1e8f5_5094x4494.png" width="1456" height="1285" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b06ab6c3-a6e1-471e-9cdd-aa3160e1e8f5_5094x4494.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1285,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1471232,&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;: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_!aimz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb06ab6c3-a6e1-471e-9cdd-aa3160e1e8f5_5094x4494.png 424w, https://substackcdn.com/image/fetch/$s_!aimz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb06ab6c3-a6e1-471e-9cdd-aa3160e1e8f5_5094x4494.png 848w, https://substackcdn.com/image/fetch/$s_!aimz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb06ab6c3-a6e1-471e-9cdd-aa3160e1e8f5_5094x4494.png 1272w, https://substackcdn.com/image/fetch/$s_!aimz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb06ab6c3-a6e1-471e-9cdd-aa3160e1e8f5_5094x4494.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"><a href="https://app.eraser.io/workspace/8hO96SC5UPofVRnz1mtY?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h4><strong>Why It&#8217;s Important:</strong></h4><ul><li><p>Protects your system from overwhelming downstream services during failures.</p></li><li><p>Allows time for the downstream service to recover.</p></li></ul><h4><strong>Implementation Tips:</strong></h4><ul><li><p>Implement with standard libraries like Resilience4j to handle circuit breakers.</p></li><li><p>Define three states for the circuit:</p><ol><li><p><strong>Closed</strong>: Requests flow as usual.</p></li><li><p><strong>Open</strong>: Requests are blocked after reaching a failure threshold.</p></li><li><p><strong>Half-Open</strong>: A limited number of test requests are sent to check if the downstream service has recovered.</p></li></ol></li><li><p>Tune thresholds carefully, such as the number of failures or the time window for evaluating failures.</p></li></ul><h2><strong>3 - Retries with Exponential Backoff</strong></h2><p>Retries are essential when transient failures occur.</p><p>Exponential backoff adds a delay between retries, doubling the wait time after each attempt. This gives the downstream service more time to recover and avoids overwhelming it.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jQfE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff343deb2-c014-4da0-b17e-7d6e2598498b_2175x1710.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jQfE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff343deb2-c014-4da0-b17e-7d6e2598498b_2175x1710.png 424w, https://substackcdn.com/image/fetch/$s_!jQfE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff343deb2-c014-4da0-b17e-7d6e2598498b_2175x1710.png 848w, https://substackcdn.com/image/fetch/$s_!jQfE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff343deb2-c014-4da0-b17e-7d6e2598498b_2175x1710.png 1272w, https://substackcdn.com/image/fetch/$s_!jQfE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff343deb2-c014-4da0-b17e-7d6e2598498b_2175x1710.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jQfE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff343deb2-c014-4da0-b17e-7d6e2598498b_2175x1710.png" width="1456" height="1145" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f343deb2-c014-4da0-b17e-7d6e2598498b_2175x1710.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1145,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:257995,&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;: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_!jQfE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff343deb2-c014-4da0-b17e-7d6e2598498b_2175x1710.png 424w, https://substackcdn.com/image/fetch/$s_!jQfE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff343deb2-c014-4da0-b17e-7d6e2598498b_2175x1710.png 848w, https://substackcdn.com/image/fetch/$s_!jQfE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff343deb2-c014-4da0-b17e-7d6e2598498b_2175x1710.png 1272w, https://substackcdn.com/image/fetch/$s_!jQfE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff343deb2-c014-4da0-b17e-7d6e2598498b_2175x1710.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"><a href="https://app.eraser.io/workspace/8hO96SC5UPofVRnz1mtY?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h4><strong>Why It&#8217;s Important:</strong></h4><ul><li><p>Increases the likelihood of success when the failure is temporary.</p></li><li><p>Reduces the risk of overloading a struggling downstream service.</p></li></ul><h4><strong>Implementation Tips:</strong></h4><ul><li><p>Combine retries with a maximum retry limit to avoid infinite loops.</p></li><li><p>Use jitter (randomized delay) in conjunction with exponential backoff to prevent synchronized retries from multiple clients causing a &#8220;thundering herd&#8221; problem.</p></li><li><p>Example: First retry after 100ms, second after 200ms, third after 400ms, with a maximum of 5 retries.</p></li></ul><h1><strong>Upstream Resiliency Patterns</strong></h1><p>Upstream patterns are used by the service owner. They are implemented by service owners to safeguard the health of their service and ensure stability during high traffic or failures.</p><h2><strong>1 - Load Shedding</strong></h2><p>Load shedding involves rejecting a portion of incoming requests when a service is overloaded.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4fLm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9167830a-a921-4f98-925f-436733fae2c7_2175x1361.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4fLm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9167830a-a921-4f98-925f-436733fae2c7_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!4fLm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9167830a-a921-4f98-925f-436733fae2c7_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!4fLm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9167830a-a921-4f98-925f-436733fae2c7_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!4fLm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9167830a-a921-4f98-925f-436733fae2c7_2175x1361.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4fLm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9167830a-a921-4f98-925f-436733fae2c7_2175x1361.png" width="1456" height="911" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9167830a-a921-4f98-925f-436733fae2c7_2175x1361.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:911,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:184542,&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;: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_!4fLm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9167830a-a921-4f98-925f-436733fae2c7_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!4fLm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9167830a-a921-4f98-925f-436733fae2c7_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!4fLm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9167830a-a921-4f98-925f-436733fae2c7_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!4fLm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9167830a-a921-4f98-925f-436733fae2c7_2175x1361.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"><a href="https://app.eraser.io/workspace/8hO96SC5UPofVRnz1mtY?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h4><strong>Why It&#8217;s Important:</strong></h4><ul><li><p>Prevents complete system failure during peak loads.</p></li><li><p>Ensures critical users or requests are prioritized.</p></li></ul><h4><strong>Implementation Tips:</strong></h4><ul><li><p>Use techniques like token-bucket or leaky-bucket algorithms to control the rate of incoming requests.</p></li><li><p>Implement priority queues to ensure critical requests (e.g., payment transactions) are handled first.</p></li><li><p>Gradually degrade non-critical features or services under heavy load (e.g., disabling analytics during peak demand).</p></li></ul><h2><strong>2 - Rate Limiting</strong></h2><p>Rate limiting sets the maximum number of requests that a client can make within a specific time window. This prevents individual clients or malicious actors from overwhelming your service.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5MHc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ce5f0c-a68d-4b5d-a7e8-daab0f7d280a_2175x1361.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5MHc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ce5f0c-a68d-4b5d-a7e8-daab0f7d280a_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!5MHc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ce5f0c-a68d-4b5d-a7e8-daab0f7d280a_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!5MHc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ce5f0c-a68d-4b5d-a7e8-daab0f7d280a_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!5MHc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ce5f0c-a68d-4b5d-a7e8-daab0f7d280a_2175x1361.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5MHc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ce5f0c-a68d-4b5d-a7e8-daab0f7d280a_2175x1361.png" width="1456" height="911" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/26ce5f0c-a68d-4b5d-a7e8-daab0f7d280a_2175x1361.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:911,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:146394,&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;: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_!5MHc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ce5f0c-a68d-4b5d-a7e8-daab0f7d280a_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!5MHc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ce5f0c-a68d-4b5d-a7e8-daab0f7d280a_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!5MHc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ce5f0c-a68d-4b5d-a7e8-daab0f7d280a_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!5MHc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ce5f0c-a68d-4b5d-a7e8-daab0f7d280a_2175x1361.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"><a href="https://app.eraser.io/workspace/8hO96SC5UPofVRnz1mtY?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h4><strong>Why It&#8217;s Important:</strong></h4><ul><li><p>Protects the service from abuse, such as Distributed Denial of Service (DDoS) attacks.</p></li><li><p>Ensures fair resource usage across all clients.</p></li></ul><h4><strong>Implementation Tips:</strong></h4><ul><li><p>Implement rate-limiting algorithms like the fixed window, sliding window, or token bucket.</p></li><li><p>Use APIs or middleware solutions such as API Gateway, NGINX, or tools like Kong.</p></li><li><p>Provide informative error messages (e.g., HTTP 429 Too Many Requests) to guide clients on retry strategies.</p></li></ul><h2><strong>3 - Bulkheads</strong></h2><p>Bulkheading involves isolating different parts of the system to prevent failures in one component from cascading to others. This is analogous to compartments in a ship&#8212;if one is breached, the others remain unaffected.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dI27!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb81b2df7-c7c2-4017-83e9-209a50b57311_2175x1361.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dI27!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb81b2df7-c7c2-4017-83e9-209a50b57311_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!dI27!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb81b2df7-c7c2-4017-83e9-209a50b57311_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!dI27!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb81b2df7-c7c2-4017-83e9-209a50b57311_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!dI27!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb81b2df7-c7c2-4017-83e9-209a50b57311_2175x1361.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dI27!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb81b2df7-c7c2-4017-83e9-209a50b57311_2175x1361.png" width="1456" height="911" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b81b2df7-c7c2-4017-83e9-209a50b57311_2175x1361.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:911,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:150007,&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;: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_!dI27!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb81b2df7-c7c2-4017-83e9-209a50b57311_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!dI27!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb81b2df7-c7c2-4017-83e9-209a50b57311_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!dI27!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb81b2df7-c7c2-4017-83e9-209a50b57311_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!dI27!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb81b2df7-c7c2-4017-83e9-209a50b57311_2175x1361.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"><a href="https://app.eraser.io/workspace/8hO96SC5UPofVRnz1mtY?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h4><strong>Why It&#8217;s Important:</strong></h4><ul><li><p>Limits the blast radius of failures.</p></li><li><p>Improves fault isolation and prevents a single failure from affecting the entire system.</p></li></ul><h4><strong>Implementation Tips:</strong></h4><ul><li><p>Separate resource pools for different components (e.g., thread pools or connection pools for different services).</p></li><li><p>Isolate critical resources to prevent non-critical services from consuming them (e.g., separate database connections for high-priority and low-priority queries).</p></li><li><p>Use container orchestration tools like Kubernetes to allocate dedicated resources to specific services.</p></li></ul><h2><strong>4 - Health Checks with Load Balancers</strong></h2><p>Health checks monitor the status of service instances and enable a load balancer to redirect traffic away from unhealthy instances. This ensures that users are always routed to functioning parts of the 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_!2XzB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86789376-d0ab-49a5-915f-a2458009a1f3_2175x1361.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2XzB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86789376-d0ab-49a5-915f-a2458009a1f3_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!2XzB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86789376-d0ab-49a5-915f-a2458009a1f3_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!2XzB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86789376-d0ab-49a5-915f-a2458009a1f3_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!2XzB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86789376-d0ab-49a5-915f-a2458009a1f3_2175x1361.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2XzB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86789376-d0ab-49a5-915f-a2458009a1f3_2175x1361.png" width="1456" height="911" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/86789376-d0ab-49a5-915f-a2458009a1f3_2175x1361.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:911,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:264574,&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;: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_!2XzB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86789376-d0ab-49a5-915f-a2458009a1f3_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!2XzB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86789376-d0ab-49a5-915f-a2458009a1f3_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!2XzB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86789376-d0ab-49a5-915f-a2458009a1f3_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!2XzB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86789376-d0ab-49a5-915f-a2458009a1f3_2175x1361.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"><a href="https://app.eraser.io/workspace/8hO96SC5UPofVRnz1mtY?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h4><strong>Why It&#8217;s Important:</strong></h4><ul><li><p>Prevents traffic from being sent to failing or degraded instances.</p></li><li><p>Improves overall user experience by minimizing downtime.</p></li></ul><h4><strong>Implementation Tips:</strong></h4><ul><li><p>Use active health checks (periodic pings) or passive health checks (monitoring error rates).</p></li><li><p>Configure thresholds for health checks, such as the number of failed requests or response latency.</p></li><li><p>Implement rolling updates with health checks to ensure smooth deployment without downtime.</p></li></ul><p><strong>So - which resiliency patterns have you used in your project?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/top-resiliency-patterns-for-developers/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/top-resiliency-patterns-for-developers/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/top-resiliency-patterns-for-developers?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.systemdesigncodex.com/p/top-resiliency-patterns-for-developers?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[What is the BFF Pattern?]]></title><description><![CDATA[And when do you need it?]]></description><link>https://newsletter.systemdesigncodex.com/p/what-is-the-bff-pattern</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/what-is-the-bff-pattern</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 07 Apr 2026 08:41:56 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!rMIC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Sometimes in software development, all you need is a BFF.</p><p>In software development, the term BFF, which stands for Backends-for-Frontends, refers to a design pattern where dedicated API gateways are created for each device or interface type.</p><p>For example, you create a separate BFF for web browsers, mobile apps, or public/partner APIs.</p><p>Each BFF acts as a specialized layer between the client and the underlying services, tailoring the API to the specific needs of the client.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rMIC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rMIC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.png 424w, https://substackcdn.com/image/fetch/$s_!rMIC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.png 848w, https://substackcdn.com/image/fetch/$s_!rMIC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!rMIC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rMIC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.png" width="1456" height="909" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:909,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:194724,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;: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_!rMIC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.png 424w, https://substackcdn.com/image/fetch/$s_!rMIC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.png 848w, https://substackcdn.com/image/fetch/$s_!rMIC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!rMIC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef7849f7-bede-4d65-9adf-c01713e6d324_2107x1315.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/5SU8bM1gDCRzZFjh1tQi?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h2><strong>Key Characteristics of BFFs</strong></h2><ol><li><p><strong>Dedicated API Gateway</strong>: Each BFF serves as a dedicated API gateway for a specific device or interface type. It encapsulates the logic and requirements specific to that client type.</p></li><li><p><strong>Customized Functionality</strong>: BFFs can handle various functionalities beyond simple API routing. They can perform tasks such as:</p><ol><li><p>rate limiting,</p></li><li><p>authentication,</p></li><li><p>header sanitization</p></li><li><p>cache control</p></li></ol></li><li><p><strong>Decoupling from Lower-Level Services</strong>: By implementing BFFs, the logic specific to different client types is abstracted away from the lower-level services. This allows the services to focus on their core functionality while the BFFs handle client-specific requirements.</p></li></ol><h2><strong>Advantages of the BFF Pattern</strong></h2><p>Implementing the BFF pattern offers several advantages:</p><ol><li><p><strong>Resiliency</strong>: By having separate BFFs for different client types, the impact of a faulty deployment or issue in one BFF is isolated to that specific client. Other clients remain unaffected, improving overall system resiliency.</p></li><li><p><strong>Autonomy</strong>: Each BFF can be optimized according to the specific needs of the client it serves. For example, mobile clients may prefer larger responses to minimize network calls, while web clients may prioritize smaller payloads. BFFs provide the flexibility to cater to these varying requirements.</p></li><li><p><strong>Development Speed</strong>: The resiliency and autonomy provided by BFFs boost developer confidence and enable faster development velocity. Teams can work independently on different BFFs without the fear of impacting other clients.</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_!bSJv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d62579-3c9c-4d63-aa64-d9062aa6bd16_2107x1315.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bSJv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d62579-3c9c-4d63-aa64-d9062aa6bd16_2107x1315.png 424w, https://substackcdn.com/image/fetch/$s_!bSJv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d62579-3c9c-4d63-aa64-d9062aa6bd16_2107x1315.png 848w, https://substackcdn.com/image/fetch/$s_!bSJv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d62579-3c9c-4d63-aa64-d9062aa6bd16_2107x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!bSJv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d62579-3c9c-4d63-aa64-d9062aa6bd16_2107x1315.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bSJv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d62579-3c9c-4d63-aa64-d9062aa6bd16_2107x1315.png" width="1456" height="909" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e8d62579-3c9c-4d63-aa64-d9062aa6bd16_2107x1315.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:909,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:193193,&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;: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_!bSJv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d62579-3c9c-4d63-aa64-d9062aa6bd16_2107x1315.png 424w, https://substackcdn.com/image/fetch/$s_!bSJv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d62579-3c9c-4d63-aa64-d9062aa6bd16_2107x1315.png 848w, https://substackcdn.com/image/fetch/$s_!bSJv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d62579-3c9c-4d63-aa64-d9062aa6bd16_2107x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!bSJv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d62579-3c9c-4d63-aa64-d9062aa6bd16_2107x1315.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"><a href="https://app.eraser.io/workspace/5SU8bM1gDCRzZFjh1tQi?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h2><strong>Disadvantages of the BFF Pattern</strong></h2><p>While the BFF pattern offers benefits, it also has some drawbacks to consider:</p><ol><li><p><strong>Code Duplication</strong>: When multiple BFFs share common functionalities, such as authorization or business logic, there is a risk of code duplication across the BFFs. This can lead to maintenance challenges and inconsistencies.</p></li><li><p><strong>Complexity</strong>: As the BFFs become responsible for more glue-logic and orchestration of services, they can become more complex over time. Managing this complexity requires careful design and maintenance.</p></li><li><p><strong>Proliferation of BFFs</strong>: Developers may be tempted to create a new BFF for every slightly different scenario, leading to an excessive number of BFFs. This can result in increased complexity and maintenance overhead.</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_!1A8T!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44fe621-06c9-4848-9f5e-8eabed64ac74_2107x1315.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1A8T!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44fe621-06c9-4848-9f5e-8eabed64ac74_2107x1315.png 424w, https://substackcdn.com/image/fetch/$s_!1A8T!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44fe621-06c9-4848-9f5e-8eabed64ac74_2107x1315.png 848w, https://substackcdn.com/image/fetch/$s_!1A8T!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44fe621-06c9-4848-9f5e-8eabed64ac74_2107x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!1A8T!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44fe621-06c9-4848-9f5e-8eabed64ac74_2107x1315.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1A8T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44fe621-06c9-4848-9f5e-8eabed64ac74_2107x1315.png" width="1456" height="909" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b44fe621-06c9-4848-9f5e-8eabed64ac74_2107x1315.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:909,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:182715,&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;: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_!1A8T!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44fe621-06c9-4848-9f5e-8eabed64ac74_2107x1315.png 424w, https://substackcdn.com/image/fetch/$s_!1A8T!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44fe621-06c9-4848-9f5e-8eabed64ac74_2107x1315.png 848w, https://substackcdn.com/image/fetch/$s_!1A8T!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44fe621-06c9-4848-9f5e-8eabed64ac74_2107x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!1A8T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb44fe621-06c9-4848-9f5e-8eabed64ac74_2107x1315.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"><a href="https://app.eraser.io/workspace/5SU8bM1gDCRzZFjh1tQi?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h2><strong>Best Practices for Implementing BFFs</strong></h2><p>To effectively leverage the BFF pattern, consider the following best practices:</p><ol><li><p><strong>Clearly Define Client Requirements</strong>: Thoroughly understand the specific requirements of each client type and design the BFFs accordingly. Avoid creating unnecessary BFFs for minor variations.</p></li><li><p><strong>Minimize Code Duplication</strong>: Identify common functionalities across BFFs and consider extracting them into shared libraries or services to minimize code duplication.</p></li><li><p><strong>Maintain Clear Boundaries</strong>: Clearly define the responsibilities of each BFF and ensure they align with the overall system architecture. Avoid overloading BFFs with excessive functionality.</p></li><li><p><strong>Monitor and Optimize Performance</strong>: Regularly monitor the performance of BFFs and optimize them based on client requirements and usage patterns. Ensure efficient resource utilization and scalability.</p></li></ol><p><strong>So - have you used the BFF pattern?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/what-is-the-bff-pattern/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/what-is-the-bff-pattern/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/what-is-the-bff-pattern?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.systemdesigncodex.com/p/what-is-the-bff-pattern?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p><em><strong>See you later with another edition &#8212; Saurabh</strong></em></p>]]></content:encoded></item><item><title><![CDATA[How TCP Handshake Works]]></title><description><![CDATA[The 3 step process]]></description><link>https://newsletter.systemdesigncodex.com/p/how-tcp-handshake-works</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/how-tcp-handshake-works</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 31 Mar 2026 08:17:52 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!1nC8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A handshake that made the Internet possible.</p><p>I&#8217;m talking about the TCP 3-way handshake.</p><p>Every time you open a website, TCP makes sure this handshake happens and you get a reliable connection.</p><p>How does TCP pull it off?</p><p>Let&#8217;s look at each step:</p><h2><strong>1 - SYN (Synchronize)</strong></h2><ul><li><p>Think of it as one party extending their hand for a handshake.</p></li><li><p>The process starts with the client sending a TCP segment to the server with the SYN flag set.</p></li><li><p>Also, the client selects an initial sequence number (ISN) and includes it in the SYN segment. Let&#8217;s say the ISN is 1000.</p></li><li><p>This tells the server that the client wants to establish a connection.</p></li></ul><h2><strong>2 - SYN-ACK (Synchronize Acknowledge)</strong></h2><ul><li><p>This is like the second party taking the hand.</p></li><li><p>The server receives the SYN segment and responds by sending a SYN-ACK segment to the client.</p></li><li><p>Before sending, the server sets the SYN flag and the ACK flag in the segment</p></li><li><p>The ACK flag is meant to acknowledge the receipt of the client&#8217;s SYN segment by incrementing the ISN by 1 (i.e. 1001)</p></li><li><p>The server also selects its own ISN (let&#8217;s say 5000) and includes it in the SYN-ACK segment.</p></li></ul><h2><strong>3 - ACK (Acknowledge)</strong></h2><ul><li><p>This is where the two parties shake hands.</p></li><li><p>The client receives the SYN-ACK segment.</p></li><li><p>The client acknowledges the server&#8217;s response by sending another TCP segment with the ACK flag set.</p></li><li><p>The sequence number in the segment is set to the server&#8217;s ISN incremented by 1 (basically, 5001)</p></li></ul><p>After this, the connection is established.</p><p>The diagram below shows all the three steps:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1nC8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1nC8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.png 424w, https://substackcdn.com/image/fetch/$s_!1nC8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.png 848w, https://substackcdn.com/image/fetch/$s_!1nC8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.png 1272w, https://substackcdn.com/image/fetch/$s_!1nC8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1nC8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.png" width="1456" height="911" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:911,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:327144,&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;: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_!1nC8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.png 424w, https://substackcdn.com/image/fetch/$s_!1nC8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.png 848w, https://substackcdn.com/image/fetch/$s_!1nC8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.png 1272w, https://substackcdn.com/image/fetch/$s_!1nC8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d8fe891-e992-42b7-a735-6ee2aeb7902b_2107x1318.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"><a href="https://app.eraser.io/workspace/bmszSLu1meFO84FykuYU?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h2><strong>FAQs</strong></h2><p>A few additional FAQs about the entire TCP handshake business:</p><blockquote><p><strong>What&#8217;s the deal with SYN and ACK? What are these exactly?</strong></p></blockquote><p>In TCP, several control flags are used to manage different aspects of the communication process. These flags are bits in the TCP header.</p><p>Some common ones are SYN, ACK, FIN, RST, PSH, and so on.</p><blockquote><p><strong>Why sequence numbers (ISNs) are so important?</strong></p></blockquote><p>The numbers help the client and server keep track of the message order so that nothing gets missed.</p><p>Also, these numbers are randomized and help prevent malicious actors from hijacking the TCP session.</p><blockquote><p><strong>Is the Internet moving away from TCP?</strong></p></blockquote><p>HTTP/3 doesn&#8217;t use TCP but relies on QUIC (Quick UDP Internet Connections). So yes, we may see a gradual move away from TCP.</p><p>However, the majority of websites are still on HTTP/1.1 and HTTP/2. So nothing is going to happen tomorrow.</p><p><strong>So - what do you think about the TCP 3-way handshake?</strong></p><p><strong>Is it an overkill? Or a great mechanism for establishing connections?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-tcp-handshake-works/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/how-tcp-handshake-works/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-tcp-handshake-works?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.systemdesigncodex.com/p/how-tcp-handshake-works?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p><em><strong>See you later with another edition &#8212; Saurabh</strong></em></p>]]></content:encoded></item><item><title><![CDATA[Object Oriented Programming - The Key Terms]]></title><description><![CDATA[The essential concepts]]></description><link>https://newsletter.systemdesigncodex.com/p/object-oriented-programming-the-key</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/object-oriented-programming-the-key</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 24 Mar 2026 08:38:43 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!jVVE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Object-Oriented Programming (OOP) is one of the most widely used programming paradigms, shaping how modern applications are designed and built.</p><p>At its core, OOP is based on four fundamental principles: <strong>Abstraction, Encapsulation, Inheritance, </strong>and<strong> Polymorphism</strong>.</p><p>Let&#8217;s break down each concept with explanations, examples, and best practices.</p><h2><strong>1 - Abstraction</strong></h2><p>Abstraction is the process of hiding complex implementation details while exposing only the essential features of an object. It allows developers to work with high-level concepts without worrying about the underlying implementation.</p><h3><strong>How It Works</strong></h3><p>Imagine a <code>Car</code> class with a method called <code>stop()</code>. Users of this class don&#8217;t need to know how the car stops&#8212;they just need to call <code>stop()</code>, and the underlying implementation takes care of the details.</p><pre><code><code>abstract class Car {
    abstract void stop();  // Abstract method, no implementation
}

class Honda extends Car {
    @Override
    void stop() {
        System.out.println("Honda slowing down and stopping.");
    }
}

class Tesla extends Car {
    @Override
    void stop() {
        System.out.println("Tesla applies brakes and stops.");
    }
}</code></code></pre><p>Here, <code>Car</code> defines the <code>stop()</code> method but doesn&#8217;t provide an implementation. Honda and Tesla provide their specific implementations, hiding the details from the users of these classes.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jVVE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jVVE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!jVVE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!jVVE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!jVVE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jVVE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.png" width="1456" height="996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:150886,&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://newsletter.systemdesigncodex.com/i/157778380?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.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_!jVVE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!jVVE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!jVVE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!jVVE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c01cb23-17b3-49c5-9613-ddb139ee9e77_1929x1319.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"><a href="https://app.eraser.io/workspace/5DyBUTNWjQGxhgKJppGF?origin=share">You can check the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Why Abstraction Matters</strong></h3><ul><li><p>Simplifies complex systems by exposing only necessary parts.</p></li><li><p>Improves code maintainability by separating the interface from implementation.</p></li><li><p>Enhances security by hiding implementation logic from unauthorized access.</p></li></ul><h2><strong>2 - Encapsulation</strong></h2><p>Encapsulation is the concept of bundling data (fields) and methods that operate on the data into a single unit (class) while restricting direct access to the 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_!-Jca!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-Jca!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!-Jca!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!-Jca!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!-Jca!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-Jca!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.png" width="1456" height="996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:147791,&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://newsletter.systemdesigncodex.com/i/157778380?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.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_!-Jca!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!-Jca!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!-Jca!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!-Jca!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd855d979-d021-4412-93a6-6fc5f60b830a_1929x1319.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"><a href="https://app.eraser.io/workspace/5DyBUTNWjQGxhgKJppGF?origin=share">You can check the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>How It Works</strong></h3><p>Encapsulation is achieved using access modifiers (<code>private</code>, <code>protected</code>, <code>public</code>) to control access to variables and methods.</p><pre><code><code>class BankAccount {
    private double balance;  // Private variable, cannot be accessed directly

    public BankAccount(double initialBalance) {
        this.balance = initialBalance;
    }

    public void deposit(double amount) {
        if (amount &gt; 0) {
            balance += amount;
        }
    }

    public double getBalance() {
        return balance;  // Provides controlled access to balance
    }
}</code></code></pre><p>Here <code>balance</code> is private, so it cannot be accessed directly from outside. Also, <code>getBalance()</code> is public, allowing controlled access to the balance.</p><h3><strong>Why Encapsulation Matters</strong></h3><ul><li><p>Protects data integrity by preventing unauthorized modifications.</p></li><li><p>Reduces dependencies by keeping data and its operations in one place.</p></li><li><p>Enhances flexibility as changes to implementation don&#8217;t affect external code.</p></li></ul><h2><strong>3 - Inheritance</strong></h2><p>Inheritance allows a class (child) to inherit attributes and methods from another class (parent). This promotes code reuse and hierarchical relationships between classes.</p><h3><strong>How It Works</strong></h3><p>Consider a <code>Vehicle</code> class. Instead of rewriting common functionality for each type of vehicle, a <code>Car</code> and <code>Bike</code> can inherit from <code>Vehicle</code>.</p><pre><code><code>class Car {
    String brand = "Generic Brand";

    void honk() {
        System.out.println("Beep! Beep!");
    }
}

class Car extends Vehicle {
    int doors = 4;
}

public class Main {
    public static void main(String[] args) {
        Car myCar = new Car();
        System.out.println(myCar.brand);  // Inherited from Vehicle
        myCar.honk();  // Inherited method
        System.out.println("Number of doors: " + myCar.doors);
    }
}</code></code></pre><p>Here, <code>Car</code> <strong>inherits</strong> <code>brand</code> and <code>honk()</code> from <code>Vehicle</code>, <strong>reusing existing logic</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_!OGeI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OGeI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!OGeI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!OGeI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!OGeI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OGeI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.png" width="1456" height="996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:144849,&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://newsletter.systemdesigncodex.com/i/157778380?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.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_!OGeI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!OGeI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!OGeI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!OGeI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab0b984e-56e8-4530-b062-9ab5e030fef4_1929x1319.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"><a href="https://app.eraser.io/workspace/5DyBUTNWjQGxhgKJppGF?origin=share">You can check the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Why Inheritance Matters</strong></h3><ul><li><p>Reduces code duplication, making maintenance easier.</p></li><li><p>Creates hierarchical relationships (e.g., <code>Animal &#8594; Mammal &#8594; Dog</code>).</p></li><li><p>Improves extensibility, allowing new behaviors to be added to child classes.</p></li></ul><h2><strong>4 - Polymorphism</strong></h2><p>Polymorphism allows a single method to behave differently based on the object it is called on. This means one function can be applied to multiple object types.</p><p>There are two types of polymorphism:</p><ol><li><p><strong>Compile-time</strong></p></li><li><p><strong>Run-time</strong></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_!IjUh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IjUh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!IjUh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!IjUh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!IjUh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IjUh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.png" width="1456" height="996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:174964,&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://newsletter.systemdesigncodex.com/i/157778380?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.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_!IjUh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!IjUh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!IjUh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!IjUh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5baf36ec-ed40-4543-a479-4455a3cb52b1_1929x1319.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"><a href="https://app.eraser.io/workspace/5DyBUTNWjQGxhgKJppGF?origin=share">You can check the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>How It Works</strong></h3><p>Here&#8217;s an example of polymorphism:</p><pre><code><code>class MathOperations {
    int add(int a, int b) {
        return a + b;
    }

    double add(double a, double b) {
        return a + b;
    }
}

public class Main {
    public static void main(String[] args) {
        MathOperations math = new MathOperations();
        System.out.println(math.add(5, 10));  // Calls int version
        System.out.println(math.add(5.5, 2.2));  // Calls double version
    }
}</code></code></pre><p>Here, the <code>add()</code> method behaves differently based on the parameter type.</p><h3><strong>Why Polymorphism Matters</strong></h3><ul><li><p>Enhances flexibility by allowing objects of different types to be treated uniformly.</p></li><li><p>Encourages code extensibility without modifying existing code.</p></li><li><p>Supports the Open-Closed Principle (OCP)&#8212;extend behavior without modifying existing logic.</p></li></ul><p><strong>So - have you used object-oriented programming? And are there any other concepts you find important?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/object-oriented-programming-the-key/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/object-oriented-programming-the-key/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/object-oriented-programming-the-key?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.systemdesigncodex.com/p/object-oriented-programming-the-key?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Inside Look at Reddit's Metadata Store]]></title><description><![CDATA[How it works]]></description><link>https://newsletter.systemdesigncodex.com/p/inside-look-at-reddits-metadata-store</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/inside-look-at-reddits-metadata-store</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 17 Mar 2026 08:41:58 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!x-_u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Reddit is like the front page of the Internet.</p><p>It hosts billions of posts. And a lot many of these posts contain media content such as images, videos, gifs, and so on.</p><p>While the media content is often stored in object storage, the metadata needs to be stored elsewhere. For example, if you&#8217;ve got a video, you might need to store information such as the thumbnail URL, playback URLs, bitrates, and various resolutions.</p><p>Reddit had a big problem with this metadata.</p><p>While their systems had the information, it was scattered across multiple systems. Media data used for traditional image and video posts was stored with post data, whereas media data related to chats and other types of posts was stored in a different database.</p><p>This made it difficult for them to analyze and categorize the metadata. Auditing changes became tough. Even checking information about a specific image or video required them to query the S3 bucket.</p><p>To solve these challenges, the Reddit Engineering team decided to build a media metadata store.</p><h1><strong>Requirements of the Metadata Store</strong></h1><p>There were several requirements for the new metadata store:</p><ul><li><p>Move all existing media metadata from different systems into a unified storage. In other words, migrate existing data to the new database.</p></li><li><p>Support data retrieval to the tune of over 100K read requests per second with very low latency (less than 50 ms).</p></li><li><p>Support media creation and updates.</p></li></ul><p>After evaluating multiple choices, the Reddit Engineering Team went for AWS Aurora Postgres.</p><p>The diagram below shows a high-level architecture of their media metadata storage 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_!Y_8m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10aa87cf-553f-4348-81c0-d08996eb5db0_1764x1070.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Y_8m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10aa87cf-553f-4348-81c0-d08996eb5db0_1764x1070.png 424w, https://substackcdn.com/image/fetch/$s_!Y_8m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10aa87cf-553f-4348-81c0-d08996eb5db0_1764x1070.png 848w, https://substackcdn.com/image/fetch/$s_!Y_8m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10aa87cf-553f-4348-81c0-d08996eb5db0_1764x1070.png 1272w, https://substackcdn.com/image/fetch/$s_!Y_8m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10aa87cf-553f-4348-81c0-d08996eb5db0_1764x1070.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Y_8m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10aa87cf-553f-4348-81c0-d08996eb5db0_1764x1070.png" width="1456" height="883" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/10aa87cf-553f-4348-81c0-d08996eb5db0_1764x1070.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:883,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:164832,&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;: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_!Y_8m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10aa87cf-553f-4348-81c0-d08996eb5db0_1764x1070.png 424w, https://substackcdn.com/image/fetch/$s_!Y_8m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10aa87cf-553f-4348-81c0-d08996eb5db0_1764x1070.png 848w, https://substackcdn.com/image/fetch/$s_!Y_8m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10aa87cf-553f-4348-81c0-d08996eb5db0_1764x1070.png 1272w, https://substackcdn.com/image/fetch/$s_!Y_8m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10aa87cf-553f-4348-81c0-d08996eb5db0_1764x1070.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"><a href="https://app.eraser.io/workspace/faUxGiTi8HuBqi4JqN9X?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>The API service interfaces with the database to handle both reads and writes. To manage the connection pooling, they use pgBouncer as the proxy for connecting to Postgres.</p><p>Just so you know, pgBouncer is a lightweight connection pooler for Postgres.</p><h1><strong>Data Migration Process</strong></h1><p>While setting up a new Postgres database is easy, the real challenge lies in migrating terabytes of data from one database to another while serving 100K requests per second.</p><p>It&#8217;s like changing a car&#8217;s tires while you are driving it.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3Ffb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe52574c7-baa4-44d1-9dc7-8699923d95e5_600x398.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3Ffb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe52574c7-baa4-44d1-9dc7-8699923d95e5_600x398.jpeg 424w, https://substackcdn.com/image/fetch/$s_!3Ffb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe52574c7-baa4-44d1-9dc7-8699923d95e5_600x398.jpeg 848w, https://substackcdn.com/image/fetch/$s_!3Ffb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe52574c7-baa4-44d1-9dc7-8699923d95e5_600x398.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!3Ffb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe52574c7-baa4-44d1-9dc7-8699923d95e5_600x398.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3Ffb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe52574c7-baa4-44d1-9dc7-8699923d95e5_600x398.jpeg" width="600" height="398" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e52574c7-baa4-44d1-9dc7-8699923d95e5_600x398.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:398,&quot;width&quot;:600,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Changing A Tire While Still Driving - Life Palette&quot;,&quot;title&quot;:&quot;Changing A Tire While Still Driving - Life Palette&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="Changing A Tire While Still Driving - Life Palette" title="Changing A Tire While Still Driving - Life Palette" srcset="https://substackcdn.com/image/fetch/$s_!3Ffb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe52574c7-baa4-44d1-9dc7-8699923d95e5_600x398.jpeg 424w, https://substackcdn.com/image/fetch/$s_!3Ffb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe52574c7-baa4-44d1-9dc7-8699923d95e5_600x398.jpeg 848w, https://substackcdn.com/image/fetch/$s_!3Ffb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe52574c7-baa4-44d1-9dc7-8699923d95e5_600x398.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!3Ffb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe52574c7-baa4-44d1-9dc7-8699923d95e5_600x398.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>The consequences of the new database having the wrong media metadata could spell disaster for the website.</p><p>The migration was handled as follows:</p><ul><li><p>Enable dual writes into both the new and old databases from the clients of media metadata. This ensures that any new metadata is stored in the new database.</p></li><li><p>Backfill data from older databases to the metadata store.</p></li><li><p>Next, enable dual reads on media metadata from our service clients.</p></li><li><p>Compare the output of the reads and fix any data gaps.</p></li><li><p>Ramp up read traffic to the new database.</p></li></ul><p>Here&#8217;s what the dual writes and backfill part looks like.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ykbW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b98bf0f-68dd-4094-a3eb-d9a15b65c2d1_1469x909.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ykbW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b98bf0f-68dd-4094-a3eb-d9a15b65c2d1_1469x909.png 424w, https://substackcdn.com/image/fetch/$s_!ykbW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b98bf0f-68dd-4094-a3eb-d9a15b65c2d1_1469x909.png 848w, https://substackcdn.com/image/fetch/$s_!ykbW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b98bf0f-68dd-4094-a3eb-d9a15b65c2d1_1469x909.png 1272w, https://substackcdn.com/image/fetch/$s_!ykbW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b98bf0f-68dd-4094-a3eb-d9a15b65c2d1_1469x909.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ykbW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b98bf0f-68dd-4094-a3eb-d9a15b65c2d1_1469x909.png" width="1456" height="901" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b98bf0f-68dd-4094-a3eb-d9a15b65c2d1_1469x909.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:901,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:104046,&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;: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_!ykbW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b98bf0f-68dd-4094-a3eb-d9a15b65c2d1_1469x909.png 424w, https://substackcdn.com/image/fetch/$s_!ykbW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b98bf0f-68dd-4094-a3eb-d9a15b65c2d1_1469x909.png 848w, https://substackcdn.com/image/fetch/$s_!ykbW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b98bf0f-68dd-4094-a3eb-d9a15b65c2d1_1469x909.png 1272w, https://substackcdn.com/image/fetch/$s_!ykbW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b98bf0f-68dd-4094-a3eb-d9a15b65c2d1_1469x909.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"><a href="https://app.eraser.io/workspace/faUxGiTi8HuBqi4JqN9X?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h1><strong>Dealing with Issues</strong></h1><p>While the overall approach is fine from a happy path perspective, that&#8217;s not always the case in real software development.</p><p>Some issues that could come up are as follows:</p><ul><li><p>Data transformation bugs in the service layer.</p></li><li><p>Writes to the new metadata store could fail and the writes to the source database succeed resulting in inconsistent data.</p></li><li><p>The backfill process during migration can overwrite newer data from the service write.</p></li></ul><p>To handle these scenarios, the Reddit team built a more robust solution as shown 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_!x-_u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!x-_u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.png 424w, https://substackcdn.com/image/fetch/$s_!x-_u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.png 848w, https://substackcdn.com/image/fetch/$s_!x-_u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.png 1272w, https://substackcdn.com/image/fetch/$s_!x-_u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!x-_u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.png" width="1456" height="864" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:864,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:236203,&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;: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_!x-_u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.png 424w, https://substackcdn.com/image/fetch/$s_!x-_u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.png 848w, https://substackcdn.com/image/fetch/$s_!x-_u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.png 1272w, https://substackcdn.com/image/fetch/$s_!x-_u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3d2973c-35eb-4c16-855e-53ecb1d7ec11_2130x1264.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"><a href="https://app.eraser.io/workspace/faUxGiTi8HuBqi4JqN9X?origin=share">You can play around with the diagram in Eraser.io</a></figcaption></figure></div><p>Here is what&#8217;s going on:</p><ul><li><p>The client dual writes to the new database and the old database.</p></li><li><p>A Kafka consumer listens to the stream of data change events from the source database. This is done using a Change Data Capture (CDC) process.</p></li><li><p>The consumer performs data validation with the media metadata store to check inconsistencies.</p></li><li><p>In case of any inconsistency, the consumer reports the differences to another database so that engineers can take a look and fix the issues.</p></li></ul><h1><strong>What about Scaling?</strong></h1><p>The new media metadata store was heavily optimized for reads, helping Reddit achieve a <em>p50 latency of 2.6 ms</em> and <em>p99 latency of 17 ms</em> at 100K requests per second.</p><p>However, the data volume is also quite high and according to their estimates, the media metadata can reach 50 TB by 2030.</p><p>To handle this scalability challenge, Reddit has implemented partitioning in Postgres using an extension known as <code>pg_partman</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_!-Xpr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faec6e34a-9c09-45aa-a472-9ca78584d59f_1130x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-Xpr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faec6e34a-9c09-45aa-a472-9ca78584d59f_1130x350.png 424w, https://substackcdn.com/image/fetch/$s_!-Xpr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faec6e34a-9c09-45aa-a472-9ca78584d59f_1130x350.png 848w, https://substackcdn.com/image/fetch/$s_!-Xpr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faec6e34a-9c09-45aa-a472-9ca78584d59f_1130x350.png 1272w, https://substackcdn.com/image/fetch/$s_!-Xpr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faec6e34a-9c09-45aa-a472-9ca78584d59f_1130x350.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-Xpr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faec6e34a-9c09-45aa-a472-9ca78584d59f_1130x350.png" width="1130" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aec6e34a-9c09-45aa-a472-9ca78584d59f_1130x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:1130,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:77166,&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;: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_!-Xpr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faec6e34a-9c09-45aa-a472-9ca78584d59f_1130x350.png 424w, https://substackcdn.com/image/fetch/$s_!-Xpr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faec6e34a-9c09-45aa-a472-9ca78584d59f_1130x350.png 848w, https://substackcdn.com/image/fetch/$s_!-Xpr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faec6e34a-9c09-45aa-a472-9ca78584d59f_1130x350.png 1272w, https://substackcdn.com/image/fetch/$s_!-Xpr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faec6e34a-9c09-45aa-a472-9ca78584d59f_1130x350.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"><a href="https://www.reddit.com/r/RedditEng/comments/1avlywv/the_reddit_media_metadata_store/">Source: Reddit Engineering Blog</a></figcaption></figure></div><p>The above SQL statement is scheduled using the <code>pg_cron</code> scheduler to create new partitions when the number of spare partitions goes below a certain number.</p><p>They used range-based partitioning instead of hash-based partitioning for the partition key <code>post_id</code>.</p><p>This is because range-based partitioning on a monotonically increasing field such as <code>post_id</code> automatically ensures the partitions are created based on distinct time periods.</p><p>Since most read requests at Reddit target recent posts, it allows the Postgres engine to cache the indexes of the most recent partitions in its buffer pool. In other words, less Disk I/O and better 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_!NFeW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57e7817-fc8a-40fc-a51f-8c62b24ab22a_1844x1139.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NFeW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57e7817-fc8a-40fc-a51f-8c62b24ab22a_1844x1139.png 424w, https://substackcdn.com/image/fetch/$s_!NFeW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57e7817-fc8a-40fc-a51f-8c62b24ab22a_1844x1139.png 848w, https://substackcdn.com/image/fetch/$s_!NFeW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57e7817-fc8a-40fc-a51f-8c62b24ab22a_1844x1139.png 1272w, https://substackcdn.com/image/fetch/$s_!NFeW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57e7817-fc8a-40fc-a51f-8c62b24ab22a_1844x1139.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NFeW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57e7817-fc8a-40fc-a51f-8c62b24ab22a_1844x1139.png" width="1456" height="899" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c57e7817-fc8a-40fc-a51f-8c62b24ab22a_1844x1139.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:899,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:105330,&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;: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_!NFeW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57e7817-fc8a-40fc-a51f-8c62b24ab22a_1844x1139.png 424w, https://substackcdn.com/image/fetch/$s_!NFeW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57e7817-fc8a-40fc-a51f-8c62b24ab22a_1844x1139.png 848w, https://substackcdn.com/image/fetch/$s_!NFeW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57e7817-fc8a-40fc-a51f-8c62b24ab22a_1844x1139.png 1272w, https://substackcdn.com/image/fetch/$s_!NFeW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57e7817-fc8a-40fc-a51f-8c62b24ab22a_1844x1139.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"><a href="https://app.eraser.io/workspace/faUxGiTi8HuBqi4JqN9X?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>So - what do you think about Reddit&#8217;s solution to the metadata problem?</p><p>Would you have done something differently?</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/inside-look-at-reddits-metadata-store/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/inside-look-at-reddits-metadata-store/comments"><span>Leave a comment</span></a></p><p><strong>References:</strong></p><ul><li><p><a href="https://www.reddit.com/r/RedditEng/comments/1avlywv/the_reddit_media_metadata_store/">The Reddit Media Metadata Store</a></p></li><li><p><a href="https://github.com/pgbouncer/pgbouncer">pgBouncer</a></p></li></ul><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/inside-look-at-reddits-metadata-store?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.systemdesigncodex.com/p/inside-look-at-reddits-metadata-store?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p><em><strong>See you later with another edition &#8212; Saurabh</strong></em></p>]]></content:encoded></item><item><title><![CDATA[How Agoda Load Balanced Kafka]]></title><description><![CDATA[Deep Dive]]></description><link>https://newsletter.systemdesigncodex.com/p/how-agoda-load-balanced-kafka</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/how-agoda-load-balanced-kafka</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 10 Mar 2026 08:01:37 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!2f1n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Agoda uses Kafka to transfer hundreds of terabytes of data across various supply systems every day. It&#8217;s an indispensable part of their tech stack.</p><p>As you might know, Agoda&#8217;s goal is to aggregate and provide the best prices from various external suppliers (hotels, restaurants, cab providers, etc). To ensure that customers always get the most up-to-date and accurate pricing information, Agoda&#8217;s supply system needs to process a massive amount of price updates from the suppliers in real time.</p><blockquote><p>For example, a single supplier can provide 1.5 million price updates and offer details in just one minute. Any delays or failures in reflecting these updates can lead to incorrect pricing and booking failures.</p></blockquote><p>Here&#8217;s how the typical Kafka application setup within Agoda&#8217;s supply system looks like:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0lYF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9760a841-f86f-4f54-bd32-083d5d323f8d_2101x1321.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0lYF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9760a841-f86f-4f54-bd32-083d5d323f8d_2101x1321.png 424w, https://substackcdn.com/image/fetch/$s_!0lYF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9760a841-f86f-4f54-bd32-083d5d323f8d_2101x1321.png 848w, https://substackcdn.com/image/fetch/$s_!0lYF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9760a841-f86f-4f54-bd32-083d5d323f8d_2101x1321.png 1272w, https://substackcdn.com/image/fetch/$s_!0lYF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9760a841-f86f-4f54-bd32-083d5d323f8d_2101x1321.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0lYF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9760a841-f86f-4f54-bd32-083d5d323f8d_2101x1321.png" width="1456" height="915" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9760a841-f86f-4f54-bd32-083d5d323f8d_2101x1321.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:915,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:198926,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;: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_!0lYF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9760a841-f86f-4f54-bd32-083d5d323f8d_2101x1321.png 424w, https://substackcdn.com/image/fetch/$s_!0lYF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9760a841-f86f-4f54-bd32-083d5d323f8d_2101x1321.png 848w, https://substackcdn.com/image/fetch/$s_!0lYF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9760a841-f86f-4f54-bd32-083d5d323f8d_2101x1321.png 1272w, https://substackcdn.com/image/fetch/$s_!0lYF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9760a841-f86f-4f54-bd32-083d5d323f8d_2101x1321.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/arpZp4bcm33HPVRCSrAq?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>The key components are as follows:</p><ul><li><p><strong>Distributor: </strong>The component consumes price updates from various 3rd party systems (suppliers) and distributes processing jobs to the downstream processor service across multiple data centers.</p></li><li><p><strong>Processor:</strong> The processor service is responsible for transforming, processing, and delivering the updates to the downstream services and databases.</p></li><li><p><strong>Kafka:</strong> It acts as the messaging backbone between the distributor and processor components.</p></li></ul><p>One of the key features of Kafka that makes it suitable for such large-scale data processing is the use of partitions.</p><blockquote><blockquote><p>Partitions help Kafka achieve parallelism by distributing the workload across multiple partitions and consumers. In other words, it can process messages faster and more efficiently.</p></blockquote></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vUOg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d8a3bfa-d33d-4052-a38d-cc8d6e03ce87_2101x1315.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vUOg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d8a3bfa-d33d-4052-a38d-cc8d6e03ce87_2101x1315.png 424w, https://substackcdn.com/image/fetch/$s_!vUOg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d8a3bfa-d33d-4052-a38d-cc8d6e03ce87_2101x1315.png 848w, https://substackcdn.com/image/fetch/$s_!vUOg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d8a3bfa-d33d-4052-a38d-cc8d6e03ce87_2101x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!vUOg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d8a3bfa-d33d-4052-a38d-cc8d6e03ce87_2101x1315.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vUOg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d8a3bfa-d33d-4052-a38d-cc8d6e03ce87_2101x1315.png" width="1456" height="911" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7d8a3bfa-d33d-4052-a38d-cc8d6e03ce87_2101x1315.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:911,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:197666,&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;: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_!vUOg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d8a3bfa-d33d-4052-a38d-cc8d6e03ce87_2101x1315.png 424w, https://substackcdn.com/image/fetch/$s_!vUOg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d8a3bfa-d33d-4052-a38d-cc8d6e03ce87_2101x1315.png 848w, https://substackcdn.com/image/fetch/$s_!vUOg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d8a3bfa-d33d-4052-a38d-cc8d6e03ce87_2101x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!vUOg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d8a3bfa-d33d-4052-a38d-cc8d6e03ce87_2101x1315.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"><a href="https://app.eraser.io/workspace/arpZp4bcm33HPVRCSrAq?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>However, Agoda&#8217;s online travel booking platform had some challenges that were made more apparent by Kafka&#8217;s parallelism.</p><h1><strong>Partitioner and Assignor Strategy</strong></h1><p>The partitioner and assignor strategies in Kafka play a crucial role in determining how messages (price updates from suppliers) are distributed across partitions and consumers.</p><ul><li><p><strong>Partitioner:</strong> Determines how messages are distributed across partitions when they are produced. For example, round-robin strategy and sticky partitioning.</p></li><li><p><strong>Assignor: </strong>Determines how partitions are assigned to consumers within a consumer group. For example, range assigner and round robin assigner.</p></li></ul><p>See the diagram below for a round-robin partitioner and round-robin assignor strategy:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SYYu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf4b0543-ec96-462c-b9c0-800630ccf40c_2101x1321.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SYYu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf4b0543-ec96-462c-b9c0-800630ccf40c_2101x1321.png 424w, https://substackcdn.com/image/fetch/$s_!SYYu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf4b0543-ec96-462c-b9c0-800630ccf40c_2101x1321.png 848w, https://substackcdn.com/image/fetch/$s_!SYYu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf4b0543-ec96-462c-b9c0-800630ccf40c_2101x1321.png 1272w, https://substackcdn.com/image/fetch/$s_!SYYu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf4b0543-ec96-462c-b9c0-800630ccf40c_2101x1321.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SYYu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf4b0543-ec96-462c-b9c0-800630ccf40c_2101x1321.png" width="1456" height="915" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/df4b0543-ec96-462c-b9c0-800630ccf40c_2101x1321.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:915,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:288064,&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;: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_!SYYu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf4b0543-ec96-462c-b9c0-800630ccf40c_2101x1321.png 424w, https://substackcdn.com/image/fetch/$s_!SYYu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf4b0543-ec96-462c-b9c0-800630ccf40c_2101x1321.png 848w, https://substackcdn.com/image/fetch/$s_!SYYu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf4b0543-ec96-462c-b9c0-800630ccf40c_2101x1321.png 1272w, https://substackcdn.com/image/fetch/$s_!SYYu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf4b0543-ec96-462c-b9c0-800630ccf40c_2101x1321.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"><a href="https://app.eraser.io/workspace/arpZp4bcm33HPVRCSrAq?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>Traditionally, these strategies were designed to work under the assumptions of homogenous consumer processing capabilities and uniform message workloads.</p><p>However, in Agoda&#8217;s case, these assumptions didn&#8217;t hold true leading to load-balancing challenges related to Kafka.</p><h2><strong>Challenges</strong></h2><p>The two main challenges are as follows:</p><ul><li><p><strong>Heterogenous Hardware: </strong>Agoda uses a private cloud with Kubernetes which can lead to pods running on servers of different hardware generations. Benchmarks show significant performance differences between hardware generations.</p></li><li><p><strong>Uneven Workload: </strong>Messages may require different processing steps, leading to varying processing times. For example, processing certain types of messages may require calling 3rd party APIs and executing database queries, resulting in latency fluctuations.</p></li></ul><p>These challenges led to the over-provisioning problem.</p><h1><strong>The Over-provisioning Problem At Agoda</strong></h1><p>Agoda initially used the Kafka round-robin partitioner and assigner to distribute the same number of messages to each partition and pod.</p><p>However, this led to over-provisioning.</p><blockquote><p><strong>Over-provisioning involves allocating more resources than necessary to handle the expected peak workload efficiently.</strong></p></blockquote><p>In Agoda&#8217;s case, the reason was an inefficient distribution of the load across their Kafka consumers.</p><p>For example, consider an example where Agoda deploys Kafka consumers on heterogeneous hardware in their processor service. Suppose they have:</p><ul><li><p>2 faster workers with a processing rate of 20 messages/second each.</p></li><li><p>1 slower worker with a processing rate of 10 messages/second.</p></li></ul><p>In this setup, the total expected capacity would be 20 + 20 + 10 = 50 messages/second.</p><p>However, with a round-robin distribution, each worker would receive 1/3 of the overall messages regardless of processing speed. If the incoming traffic consistently hits 50 messages/second, here&#8217;s what would happen:</p><ul><li><p>The 2 faster workers can easily handle their share of ~ 16.7 messages per second each.</p></li><li><p>The slower worker cannot keep up with its allocated ~16.7 messages per second, causing the lag to build up over time.</p></li></ul><p>The diagram below shows this scenario:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2f1n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2f1n!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.png 424w, https://substackcdn.com/image/fetch/$s_!2f1n!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.png 848w, https://substackcdn.com/image/fetch/$s_!2f1n!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!2f1n!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2f1n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.png" width="1456" height="911" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:911,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:301464,&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;: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_!2f1n!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.png 424w, https://substackcdn.com/image/fetch/$s_!2f1n!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.png 848w, https://substackcdn.com/image/fetch/$s_!2f1n!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!2f1n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11c648fe-6f0b-4d3a-a406-1112f1c51393_2101x1315.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"><a href="https://app.eraser.io/workspace/arpZp4bcm33HPVRCSrAq?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>To avoid high latency, Agoda would have to add extra resources to this setup to maintain processing SLAs. In this example, to process 50 messages/second, they would need to scale out to 5 machines. In other words, they end up over-provisioning by 2 extra machines due to the suboptimal distribution logic that doesn&#8217;t account for heterogeneous hardware.</p><p>Also, the same scenario can occur when the workload for each message is not identical. Either way, it results in:</p><ul><li><p>Increased hardware costs</p></li><li><p>Wasted resources as some consumers sit idle while others are overburdened</p></li><li><p>More maintenance overhead</p></li></ul><h1><strong>The Solution Agoda Didn&#8217;t Adopt</strong></h1><p>The first obvious solution to overcome the over-provisioning challenge was static balancing. There were mainly two approaches in this regard:</p><ul><li><p>Deployment on identical pods</p></li><li><p>Weighted load balancing</p></li></ul><h2><strong>Deployment on Identical Pods</strong></h2><p>This solution involves controlling the types of hardware used in service deployments. However, it had some drawbacks:</p><ul><li><p>Maintaining a homogeneous hardware environment can be expensive, especially in a private cloud setup.</p></li><li><p>Upgrading all existing hardware simultaneously can be challenging.</p></li></ul><p>Due to these reasons, it was not adopted.</p><h2><strong>Weighted Load Balancing</strong></h2><p>In this approach, varying weights are assigned to different consumers based on processing capacity. Consumers with higher weights are routed more traffic.</p><p>This solution works well when:</p><ul><li><p>The capacity of consumers is predictable and remains static.</p></li><li><p>The workload of messages is uniform, making it easier to estimate machine capacity.</p></li></ul><p>However, there were some challenges in implementing this in a real production environment at Agoda:</p><ul><li><p>Messages often had non-uniform workloads, making capacity estimation difficult.</p></li><li><p>Dependencies like network and 3rd party connections were unstable, leading to fluctuating capacities.</p></li><li><p>Frequent addition of new features required extra maintenance to keep the weights updated.</p></li></ul><h1><strong>Agoda&#8217;s Dynamic Lag-Aware Solution</strong></h1><p>Instead of the static rebalancing approaches, Agoda adopted a dynamic, lag-aware approach to solve the Kafka load balancing challenges. They implemented two main strategies:</p><ul><li><p>Lag-aware Producer</p></li><li><p>Lag-aware Consumer</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_!k1dh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1d4bc-6464-4b7d-9068-cc4e05706896_2101x1321.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!k1dh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1d4bc-6464-4b7d-9068-cc4e05706896_2101x1321.png 424w, https://substackcdn.com/image/fetch/$s_!k1dh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1d4bc-6464-4b7d-9068-cc4e05706896_2101x1321.png 848w, https://substackcdn.com/image/fetch/$s_!k1dh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1d4bc-6464-4b7d-9068-cc4e05706896_2101x1321.png 1272w, https://substackcdn.com/image/fetch/$s_!k1dh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1d4bc-6464-4b7d-9068-cc4e05706896_2101x1321.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!k1dh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1d4bc-6464-4b7d-9068-cc4e05706896_2101x1321.png" width="1456" height="915" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72d1d4bc-6464-4b7d-9068-cc4e05706896_2101x1321.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:915,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:245337,&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;: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_!k1dh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1d4bc-6464-4b7d-9068-cc4e05706896_2101x1321.png 424w, https://substackcdn.com/image/fetch/$s_!k1dh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1d4bc-6464-4b7d-9068-cc4e05706896_2101x1321.png 848w, https://substackcdn.com/image/fetch/$s_!k1dh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1d4bc-6464-4b7d-9068-cc4e05706896_2101x1321.png 1272w, https://substackcdn.com/image/fetch/$s_!k1dh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1d4bc-6464-4b7d-9068-cc4e05706896_2101x1321.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"><a href="https://app.eraser.io/workspace/arpZp4bcm33HPVRCSrAq?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h2><strong>Lag-aware Producer</strong></h2><p>A lag-aware producer dynamically adjusts the partitioning of messages based on the current lag information of the target topic. Here&#8217;s how it works:</p><ul><li><p>The producer maintains an internal cache of partition lags to reduce the number of calls to Kafka brokers.</p></li><li><p>Using the lag data, the producer applies a custom algorithm to publish fewer messages to partitions with high lag and more messages to partitions with low lag.</p></li><li><p>When lags are balanced and stable, this approach guarantees an even distribution of messages.</p></li></ul><p>For example, let&#8217;s consider a scenario where Agoda&#8217;s supply system has an internal producer that publishes task messages to its processor. The system has 6 partitions with the following lags:</p><ul><li><p>Partition 1 &#8594; 100 messages</p></li><li><p>Partition 2 &#8594; 120 messages</p></li><li><p>Partition 3 &#8594; 90 messages</p></li><li><p>Partition 4 &#8594; 300 messages</p></li><li><p>Partition 5 &#8594; 110 messages</p></li><li><p>Partition 6 &#8594; 280 messages</p></li></ul><p>In this case, the lag-aware producer would publish fewer messages to partitions 4 and 6 due to their high lag while publishing more messages to the other partitions with lower lag.</p><p>The diagram below illustrates 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_!XpZy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84e7cf9-d986-41c1-9acf-52630a2b9900_2101x1321.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XpZy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84e7cf9-d986-41c1-9acf-52630a2b9900_2101x1321.png 424w, https://substackcdn.com/image/fetch/$s_!XpZy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84e7cf9-d986-41c1-9acf-52630a2b9900_2101x1321.png 848w, https://substackcdn.com/image/fetch/$s_!XpZy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84e7cf9-d986-41c1-9acf-52630a2b9900_2101x1321.png 1272w, https://substackcdn.com/image/fetch/$s_!XpZy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84e7cf9-d986-41c1-9acf-52630a2b9900_2101x1321.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XpZy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84e7cf9-d986-41c1-9acf-52630a2b9900_2101x1321.png" width="1456" height="915" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b84e7cf9-d986-41c1-9acf-52630a2b9900_2101x1321.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:915,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:214063,&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;: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_!XpZy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84e7cf9-d986-41c1-9acf-52630a2b9900_2101x1321.png 424w, https://substackcdn.com/image/fetch/$s_!XpZy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84e7cf9-d986-41c1-9acf-52630a2b9900_2101x1321.png 848w, https://substackcdn.com/image/fetch/$s_!XpZy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84e7cf9-d986-41c1-9acf-52630a2b9900_2101x1321.png 1272w, https://substackcdn.com/image/fetch/$s_!XpZy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84e7cf9-d986-41c1-9acf-52630a2b9900_2101x1321.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"><a href="https://app.eraser.io/workspace/arpZp4bcm33HPVRCSrAq?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h2><strong>Lag-aware Consumer</strong></h2><p>Lag-aware consumers are used when multiple consumer groups subscribe to the same topic. Here&#8217;s how they work:</p><ul><li><p>In a downstream service like the Processor, a consumer instance experiencing high lag can proactively unsubscribe from the topic to trigger a rebalance.</p></li><li><p>During the rebalance, a customized Assigner redistributes the partitions across all consumer instances based on their current lag and processing capacity.</p></li><li><p>Kafka 2.4&#8217;s incremental cooperative rebalance protocol minimizes the performance impact of rebalancing, allowing for more frequent adjustments.</p></li></ul><p>For example, consider a scenario where Agoda&#8217;s Processor service has 3 consumer instances consuming from 6 partitions:</p><ul><li><p>Worker 1 &#8594; Partitions 1 and 2</p></li><li><p>Worker 2 &#8594; Partitions 3 and 4</p></li><li><p>Worker 3 &#8594; Partitions 5 and 6</p></li></ul><p>If Worker 3 is running on slower hardware, it may experience higher lags in partitions 5 and 6. In this case, Worker 3 can proactively unsubscribe from the topic, triggering a rebalance. The custom Assigner then redistributes the partitions based on the current lag and processing capacity of each worker.</p><h1><strong>Algorithms for Lag-aware Producer</strong></h1><p>Coming back to the Lag-aware producer, Agoda used two main algorithms:</p><ul><li><p>Same-Queue Length Algorithm</p></li><li><p>Outlier Detection Algorithm</p></li></ul><h2><strong>1 - Same-Queue Length Algorithm</strong></h2><p>The Same-Queue Length Algorithm aims to achieve equal queue lengths across all partitions by adjusting the number of messages published to each partition based on the current lag.</p><p>For example, consider a scenario with 4 partitions having the following lags:</p><ul><li><p>Partition 1 &#8594; 100 messages</p></li><li><p>Partition 2 &#8594; 150 messages</p></li><li><p>Partition 3 &#8594; 120 messages</p></li><li><p>Partition 4 &#8594; 200 messages</p></li></ul><p>The target queue length would be 200 (the maximum lag). The algorithm would then publish messages as follows:</p><ul><li><p>Partition 1 &#8594; Publish 100 messages (200 - 100)</p></li><li><p>Partition 2 &#8594; Publish 50 messages (200-150)</p></li><li><p>Partition 3 &#8594; Publish 80 messages (200 - 120)</p></li><li><p>Partition 4 &#8594; Publish 0 messages (already at the target)</p></li></ul><p>See the diagram 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_!cKO_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2019140-dbef-4646-aea5-59743c9d5c16_2101x1323.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cKO_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2019140-dbef-4646-aea5-59743c9d5c16_2101x1323.png 424w, https://substackcdn.com/image/fetch/$s_!cKO_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2019140-dbef-4646-aea5-59743c9d5c16_2101x1323.png 848w, https://substackcdn.com/image/fetch/$s_!cKO_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2019140-dbef-4646-aea5-59743c9d5c16_2101x1323.png 1272w, https://substackcdn.com/image/fetch/$s_!cKO_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2019140-dbef-4646-aea5-59743c9d5c16_2101x1323.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cKO_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2019140-dbef-4646-aea5-59743c9d5c16_2101x1323.png" width="1456" height="917" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e2019140-dbef-4646-aea5-59743c9d5c16_2101x1323.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:917,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:192569,&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;: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_!cKO_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2019140-dbef-4646-aea5-59743c9d5c16_2101x1323.png 424w, https://substackcdn.com/image/fetch/$s_!cKO_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2019140-dbef-4646-aea5-59743c9d5c16_2101x1323.png 848w, https://substackcdn.com/image/fetch/$s_!cKO_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2019140-dbef-4646-aea5-59743c9d5c16_2101x1323.png 1272w, https://substackcdn.com/image/fetch/$s_!cKO_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2019140-dbef-4646-aea5-59743c9d5c16_2101x1323.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"><a href="https://app.eraser.io/workspace/arpZp4bcm33HPVRCSrAq?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h2><strong>2 - Outlier Detection Algorithm</strong></h2><p>The Outlier Detection Algorithm identifies partitions with abnormally high lag (outliers) and temporarily stops publishing messages to those partitions to allow them to catch up.</p><p>It uses statistical methods like Interquartile Range (IQR) or Standard Deviation (STD) to identify outlier partitions.</p><p>For example, consider a scenario with 6 partitions having the following lags:</p><ul><li><p>Partition 1 &#8594; 100 messages</p></li><li><p>Partition 2 &#8594; 120 messages</p></li><li><p>Partition 3 &#8594; 300 messages</p></li></ul><p>Using the IQR method, partition 3 is identified as an outlier (slow partition). The algorithm would then:</p><ul><li><p>Stop publishing messages to partition 3</p></li><li><p>Evenly distribute messages among partitions 1 and 2.</p></li><li><p>If partition 3 improves and is no longer an outlier, gradually resume publishing messages to them.</p></li></ul><p><strong>So - what do you think about Agoda&#8217;s load-balancing solution for Kafka? Would you have done something differently?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-agoda-load-balanced-kafka/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/how-agoda-load-balanced-kafka/comments"><span>Leave a comment</span></a></p><p><strong>Reference:</strong></p><p><a href="https://medium.com/agoda-engineering/how-we-solve-load-balancing-challenges-in-apache-kafka-8cd88fdad02b">How We Solve Load Balancing Challenges in Apache Kafka</a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-agoda-load-balanced-kafka?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.systemdesigncodex.com/p/how-agoda-load-balanced-kafka?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p><em><strong>See you later with another edition &#8212; Saurabh</strong></em></p>]]></content:encoded></item><item><title><![CDATA[What Happens to an SQL Query?]]></title><description><![CDATA[The Journey Through the DB]]></description><link>https://newsletter.systemdesigncodex.com/p/what-happens-to-an-sql-query</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/what-happens-to-an-sql-query</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Wed, 04 Mar 2026 03:14:28 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!NfGN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>What happens when you make an SQL query to the database?</strong></p><p>Let&#8217;s say this is the query:</p><blockquote><p><strong>SELECT name, age FROM users WHERE city = &#8216;New York&#8217;;</strong></p></blockquote><p>Here&#8217;s a diagram that shows the process visually:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NfGN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NfGN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.png 424w, https://substackcdn.com/image/fetch/$s_!NfGN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.png 848w, https://substackcdn.com/image/fetch/$s_!NfGN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.png 1272w, https://substackcdn.com/image/fetch/$s_!NfGN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NfGN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.png" width="1456" height="1995" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1995,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:430781,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;: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_!NfGN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.png 424w, https://substackcdn.com/image/fetch/$s_!NfGN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.png 848w, https://substackcdn.com/image/fetch/$s_!NfGN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.png 1272w, https://substackcdn.com/image/fetch/$s_!NfGN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a4e60df-517b-43df-bdb1-8dc56f523d3e_1808x2477.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/nJvB4h1oZDT325MthtMx?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>Let&#8217;s go through each step in more detail:</p><h2><strong>STEP 1</strong></h2><p>When you hit run, the query string first reaches the Transport Subsystem of the database.</p><p>As the name suggests, this subsystem manages the connection with the client.</p><p>It also performs initial authentication and authorization checks, and if satisfied, lets the query go to the next step.</p><h2><strong>STEP 2</strong></h2><p>The query now reaches the Query Processor, which has two main parts:</p><ul><li><p>Query Parser</p></li><li><p>Query Optimizer</p></li></ul><p>The Query Parser breaks down the SQL query into its parts (SELECT, FROM, WHERE, etc). It checks for any syntax errors and creates a parse tree.</p><p>Then, the Query Optimizer goes through the parse tree, checks for semantic errors (e.g. - if the &#8216;users&#8217; table exists or not), and determines the most efficient way to execute the query.</p><p>As output, the optimizer produces an execution plan.</p><h2><strong>STEP 3</strong></h2><p>Next, the execution plan makes its way to the Execution Engine.</p><p>The plan is made up of all the steps that are needed to execute the query.</p><p>The Execution Engine takes this plan and coordinates the execution of each step by calling the Storage Engine. It also collects the results from each step and returns a unified response to the upper layer.</p><h2><strong>STEP 4</strong></h2><p>The Execution Engine sends low-level read/write requests to the Storage Engine depending on the execution plan.</p><p>All of this is facilitated by the various employees of the Storage Engine.</p><p>For example,</p><ul><li><p>The transaction manager ensures that the query runs within a transaction for consistency.</p></li><li><p>The lock manager acquires necessary locks on the &#8220;users&#8221; table to prevent conflicts.</p></li><li><p>The buffer manager checks if the required data pages are already in memory. If not, it requests the data to be loaded from the disk into memory.</p></li><li><p>The recovery manager logs the operations for rollback or recovery.</p></li></ul><p>&#128073; <strong>So - what else would you add to this journey of an SQL query?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/what-happens-to-an-sql-query/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/what-happens-to-an-sql-query/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/what-happens-to-an-sql-query?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.systemdesigncodex.com/p/what-happens-to-an-sql-query?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p><em><strong>See you later with another edition &#8212; Saurabh</strong></em></p>]]></content:encoded></item><item><title><![CDATA[How to Prevent the DB from Becoming a Bottleneck]]></title><description><![CDATA[Tips and Strategies]]></description><link>https://newsletter.systemdesigncodex.com/p/how-to-prevent-the-db-from-becoming</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/how-to-prevent-the-db-from-becoming</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 24 Feb 2026 08:15:03 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Cl1U!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You&#8217;ve done everything right. Your code is clean, your functions are optimized, and you&#8217;ve used the latest frameworks. But your application is still slow.</p><p>Why?</p><p>Because your database is struggling to keep up.</p><p>This is a common problem in backend development&#8212;your code executes in milliseconds, but your database queries take seconds. If you don&#8217;t address this, you&#8217;ll end up with sluggish APIs, frustrated users, and a system that crumbles under load.</p><p>Let&#8217;s explore why databases slow down and how to fix them.</p><h2><strong>Why the Database Can Become a Bottleneck?</strong></h2><p>Databases are slower than code execution.</p><p>Your application code runs in memory, but your database reads and writes data from disks or over a network. Even with SSDs and optimized database engines, disk access and network calls are still much slower than in-memory operations.</p><p>But how do you know if your database is causing performance issues?</p><p>Look for these symptoms:</p><ul><li><p>Your API requests take a long time despite minimal application logic.</p></li><li><p>Your database CPU usage is always high.</p></li><li><p>Queries take longer as your data grows.</p></li><li><p>Your application struggles under high user traffic.</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_!Cl1U!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Cl1U!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.png 424w, https://substackcdn.com/image/fetch/$s_!Cl1U!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.png 848w, https://substackcdn.com/image/fetch/$s_!Cl1U!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.png 1272w, https://substackcdn.com/image/fetch/$s_!Cl1U!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Cl1U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.png" width="1456" height="949" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:949,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:302049,&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;: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_!Cl1U!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.png 424w, https://substackcdn.com/image/fetch/$s_!Cl1U!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.png 848w, https://substackcdn.com/image/fetch/$s_!Cl1U!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.png 1272w, https://substackcdn.com/image/fetch/$s_!Cl1U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35b35c57-6027-4ba4-b8bb-bc572dc6eebb_2101x1370.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"><a href="https://app.eraser.io/workspace/LkLxPbebfWJhCH7GSS7y?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h2><strong>Diagnosing the Problem</strong></h2><p>Before you start optimizing, you need to identify the actual bottlenecks. Here&#8217;s how:</p><h3><strong>Use Query Profiling</strong></h3><p>Every major database has a way to analyze slow queries:</p><ul><li><p><strong>MySQL &amp; PostgreSQL:</strong> Use <code>EXPLAIN ANALYZE</code> to check execution plans.</p></li><li><p><strong>MongoDB:</strong> Use <code>.explain()</code> to analyze queries.</p></li><li><p><strong>Slow Query Logs:</strong> Identify the queries that are taking the most time.</p></li></ul><p>For example:</p><pre><code><code>EXPLAIN ANALYZE SELECT * FROM orders WHERE status = 'pending';</code></code></pre><p>This will show how your database processes the query and where the delays are happening.</p><h3><strong>Look at Key Performance Metrics</strong></h3><p>Monitor the following database metrics:</p><ul><li><p><strong>Query execution time:</strong> Are some queries consistently slow?</p></li><li><p><strong>Read/write latency:</strong> Is your database struggling with high read or write operations?</p></li><li><p><strong>Locking issues:</strong> Are queries blocking each other?</p></li><li><p><strong>Connection pooling:</strong> Are too many connections being opened and closed?</p></li></ul><p>Once you&#8217;ve identified the slow queries, you can start optimizing them.</p><h3><strong>Database Locking &amp; Deadlocks</strong></h3><p>When multiple queries or transactions run concurrently, databases use locking mechanisms to ensure data consistency.</p><p>However, poor transaction management can lead to deadlocks, where two or more queries wait indefinitely for each other to release a lock, causing performance bottlenecks.</p><p>There are different types of locks:</p><ul><li><p><strong>Row-level locks</strong>: Lock individual rows, allowing higher concurrency. (Ideal for OLTP applications)</p></li><li><p><strong>Table-level locks</strong>: Lock the entire table, preventing modifications while a transaction is running. (Can cause slowdowns)</p></li><li><p><strong>Shared vs. Exclusive locks</strong>: Shared locks allow multiple reads, while exclusive locks block all access until completion.</p></li></ul><p>Some best practices to deal with deadlocks are as follows:</p><ul><li><p>Keep transactions short and efficient (commit early).</p></li><li><p>Access tables in a consistent order across transactions.</p></li><li><p>Use indexing to reduce unnecessary locks.</p></li><li><p>Monitor for deadlocks using <code>SHOW ENGINE INNODB STATUS;</code> (MySQL) or <code>pg_stat_activity</code> (PostgreSQL).</p></li></ul><h2><strong>Optimizing Your Queries</strong></h2><p>Optimizing queries is a quick win. Here are some common tips that can help:</p><h3><strong>1 - Add Indexes (The Right Way!)</strong></h3><p>Indexes speed up lookups by avoiding full table scans.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Vzaf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a440b08-7b6b-4914-a015-b5f7df7b40ef_1604x966.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Vzaf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a440b08-7b6b-4914-a015-b5f7df7b40ef_1604x966.png 424w, https://substackcdn.com/image/fetch/$s_!Vzaf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a440b08-7b6b-4914-a015-b5f7df7b40ef_1604x966.png 848w, https://substackcdn.com/image/fetch/$s_!Vzaf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a440b08-7b6b-4914-a015-b5f7df7b40ef_1604x966.png 1272w, https://substackcdn.com/image/fetch/$s_!Vzaf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a440b08-7b6b-4914-a015-b5f7df7b40ef_1604x966.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Vzaf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a440b08-7b6b-4914-a015-b5f7df7b40ef_1604x966.png" width="1456" height="877" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4a440b08-7b6b-4914-a015-b5f7df7b40ef_1604x966.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:877,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:186589,&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;: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_!Vzaf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a440b08-7b6b-4914-a015-b5f7df7b40ef_1604x966.png 424w, https://substackcdn.com/image/fetch/$s_!Vzaf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a440b08-7b6b-4914-a015-b5f7df7b40ef_1604x966.png 848w, https://substackcdn.com/image/fetch/$s_!Vzaf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a440b08-7b6b-4914-a015-b5f7df7b40ef_1604x966.png 1272w, https://substackcdn.com/image/fetch/$s_!Vzaf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a440b08-7b6b-4914-a015-b5f7df7b40ef_1604x966.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"><a href="https://app.eraser.io/workspace/LkLxPbebfWJhCH7GSS7y?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>For example, the query below would be considered bad without indexes in the email field.</p><pre><code><code>SELECT * FROM users WHERE email = 'user@example.com';</code></code></pre><p>A simple fix would be to create the index on email.</p><pre><code><code>CREATE INDEX idx_email ON users(email);</code></code></pre><p>With an index, the database can locate the data instantly instead of scanning every row. However, too many indexes slow down writes, so there is a trade-off involved. Make sure to only index the columns you frequently search on.</p><h3><strong>2 - Avoid SELECT *** (Be Specific)</strong></h3><p>Fetching all columns when you only need a few wastes resources. For example, the below query should not be used:</p><pre><code><code>SELECT * FROM orders WHERE status = 'pending';</code></code></pre><p>A better option is the query below:</p><pre><code><code>SELECT id, customer_id, total_price FROM orders WHERE status = 'pending';</code></code></pre><p>This reduces the amount of data transferred and speeds up queries.</p><h3><strong>3 - Use Joins &amp; Reduce Nested Queries</strong></h3><p>Avoid nested queries. For example:</p><pre><code><code>SELECT * FROM orders WHERE customer_id IN (SELECT id FROM customers WHERE city = 'New York');</code></code></pre><p>Using joins like the example below can be a much better strategy.</p><pre><code><code>SELECT orders.order_id 
FROM orders 
JOIN customers ON orders.customer_id = customers.id 
WHERE customers.city = 'New York';</code></code></pre><p>Joins are optimized by the database, whereas nested queries can cause multiple redundant lookups.</p><h2><strong>Scaling Beyond Queries: Architectural Optimizations</strong></h2><p>Some optimizations are also required on the architectural level to improve database performance. Here are some examples:</p><h3><strong>Schema Design</strong></h3><p>Database schema design directly impacts query speed, scalability, and storage efficiency. Poor schema decisions lead to slow queries, high storage costs, and scaling bottlenecks.</p><p>Here&#8217;s how to optimize schema design for better performance:</p><h4><strong>1 - Normalization vs. Denormalization: Trade-offs</strong></h4><ul><li><p>Normalization (3NF and above) reduces data redundancy by breaking tables into smaller, related entities.</p><ul><li><p><strong>Pros:</strong> Saves space and avoids update anomalies.</p></li><li><p><strong>Cons:</strong> Can slow down read-heavy queries due to excessive JOINs.</p></li></ul></li><li><p>Denormalization merges frequently used data to reduce JOINs, making reads faster at the cost of extra storage and potential update issues.</p><ul><li><p><strong>Pros:</strong> Great for analytics &amp; high-read workloads.</p></li><li><p><strong>Cons:</strong> Can lead to data inconsistency if not managed properly.</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_!Ln7_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a999744-9bd3-4680-b13e-10c338901a91_2361x1550.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ln7_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a999744-9bd3-4680-b13e-10c338901a91_2361x1550.png 424w, https://substackcdn.com/image/fetch/$s_!Ln7_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a999744-9bd3-4680-b13e-10c338901a91_2361x1550.png 848w, https://substackcdn.com/image/fetch/$s_!Ln7_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a999744-9bd3-4680-b13e-10c338901a91_2361x1550.png 1272w, https://substackcdn.com/image/fetch/$s_!Ln7_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a999744-9bd3-4680-b13e-10c338901a91_2361x1550.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ln7_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a999744-9bd3-4680-b13e-10c338901a91_2361x1550.png" width="1456" height="956" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0a999744-9bd3-4680-b13e-10c338901a91_2361x1550.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:956,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:286754,&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;: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_!Ln7_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a999744-9bd3-4680-b13e-10c338901a91_2361x1550.png 424w, https://substackcdn.com/image/fetch/$s_!Ln7_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a999744-9bd3-4680-b13e-10c338901a91_2361x1550.png 848w, https://substackcdn.com/image/fetch/$s_!Ln7_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a999744-9bd3-4680-b13e-10c338901a91_2361x1550.png 1272w, https://substackcdn.com/image/fetch/$s_!Ln7_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a999744-9bd3-4680-b13e-10c338901a91_2361x1550.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"><a href="https://app.eraser.io/workspace/LkLxPbebfWJhCH7GSS7y?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p><strong>Rule of Thumb:</strong> Normalize when you expect frequent writes, denormalize when reads dominate.</p><h4><strong>2 - Choosing the Right Data Types</strong></h4><ul><li><p>Use <code>BIGINT</code> instead of <code>UUID</code> for primary keys unless uniqueness across distributed systems is needed.</p></li><li><p>Use <code>BOOLEAN</code> for true/false values.</p></li><li><p>Use <code>TEXT</code>/<code>JSONB</code> sparingly. This is because indexable columns are faster for queries.</p></li></ul><h3><strong>Use Caching</strong></h3><p>Instead of hitting the database every time, store frequently accessed data in a cache (Redis, Memcached). This reduces database load significantly.</p><p>For example, cache the result of expensive queries.</p><pre><code><code>cache.set("user_123_orders", query_result, expire=300) # Expires in 5 minutes</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pj9Q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc7ae6ef-7856-40bd-9cf1-5a74644787b4_2175x1361.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pj9Q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc7ae6ef-7856-40bd-9cf1-5a74644787b4_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!pj9Q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc7ae6ef-7856-40bd-9cf1-5a74644787b4_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!pj9Q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc7ae6ef-7856-40bd-9cf1-5a74644787b4_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!pj9Q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc7ae6ef-7856-40bd-9cf1-5a74644787b4_2175x1361.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pj9Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc7ae6ef-7856-40bd-9cf1-5a74644787b4_2175x1361.png" width="1456" height="911" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cc7ae6ef-7856-40bd-9cf1-5a74644787b4_2175x1361.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:911,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:230837,&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;: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_!pj9Q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc7ae6ef-7856-40bd-9cf1-5a74644787b4_2175x1361.png 424w, https://substackcdn.com/image/fetch/$s_!pj9Q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc7ae6ef-7856-40bd-9cf1-5a74644787b4_2175x1361.png 848w, https://substackcdn.com/image/fetch/$s_!pj9Q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc7ae6ef-7856-40bd-9cf1-5a74644787b4_2175x1361.png 1272w, https://substackcdn.com/image/fetch/$s_!pj9Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc7ae6ef-7856-40bd-9cf1-5a74644787b4_2175x1361.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"><a href="https://app.eraser.io/workspace/LkLxPbebfWJhCH7GSS7y?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Optimize Database Connections</strong></h3><p>Opening and closing database connections is expensive. Use <strong>connection pooling</strong> to reuse existing connections instead of creating new ones for every request.</p><p>For example, use <code>pgbouncer</code> for PostgreSQL connection pooling.</p><h3><strong>Materialized Views for Precomputed Expensive Queries</strong></h3><p>A Materialized View is a precomputed query result stored as a physical table. Unlike a regular database view, which runs a query every time it&#8217;s accessed, a materialized view stores the result persistently, making expensive queries much faster.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JFk9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc22852f7-38dd-476f-b0b8-c5edc8ab65e3_1929x1277.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JFk9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc22852f7-38dd-476f-b0b8-c5edc8ab65e3_1929x1277.png 424w, https://substackcdn.com/image/fetch/$s_!JFk9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc22852f7-38dd-476f-b0b8-c5edc8ab65e3_1929x1277.png 848w, https://substackcdn.com/image/fetch/$s_!JFk9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc22852f7-38dd-476f-b0b8-c5edc8ab65e3_1929x1277.png 1272w, https://substackcdn.com/image/fetch/$s_!JFk9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc22852f7-38dd-476f-b0b8-c5edc8ab65e3_1929x1277.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JFk9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc22852f7-38dd-476f-b0b8-c5edc8ab65e3_1929x1277.png" width="1456" height="964" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c22852f7-38dd-476f-b0b8-c5edc8ab65e3_1929x1277.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:964,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:168878,&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;: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_!JFk9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc22852f7-38dd-476f-b0b8-c5edc8ab65e3_1929x1277.png 424w, https://substackcdn.com/image/fetch/$s_!JFk9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc22852f7-38dd-476f-b0b8-c5edc8ab65e3_1929x1277.png 848w, https://substackcdn.com/image/fetch/$s_!JFk9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc22852f7-38dd-476f-b0b8-c5edc8ab65e3_1929x1277.png 1272w, https://substackcdn.com/image/fetch/$s_!JFk9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc22852f7-38dd-476f-b0b8-c5edc8ab65e3_1929x1277.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"><a href="https://app.eraser.io/workspace/LkLxPbebfWJhCH7GSS7y?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>For example, suppose we frequently calculate total sales per day from a huge <code>orders</code> table:</p><pre><code><code>SELECT order_date, SUM(total_price) AS daily_sales
FROM orders
GROUP BY order_date;</code></code></pre><p>If the <code>orders</code> table is massive, this query slows down dashboards and reports. To handle this, you can create a materialized view. This way queries can read directly from the view instead of querying the <code>orders</code> table.</p><p>However, materialized views don&#8217;t usually auto-update when data changes. There needs to be a mechanism to update them. Also, this approach is not suitable for real-time data needs.</p><h3><strong>Sharding &amp; Partitioning for Large Datasets</strong></h3><p>When your database gets huge, split data across multiple servers (sharding) or distribute tables across partitions.</p><p>For example:</p><ul><li><p>Shard users based on country (<code>users_us</code>, <code>users_eu</code>)</p></li><li><p>Partition orders by date (<code>orders_2023</code>, <code>orders_2024</code>)</p></li></ul><p>This reduces the load on a single table and speeds up lookups.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!waRm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F592eba2e-20df-4cb4-ad8c-8299ea7ab9e0_2101x1370.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!waRm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F592eba2e-20df-4cb4-ad8c-8299ea7ab9e0_2101x1370.png 424w, https://substackcdn.com/image/fetch/$s_!waRm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F592eba2e-20df-4cb4-ad8c-8299ea7ab9e0_2101x1370.png 848w, https://substackcdn.com/image/fetch/$s_!waRm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F592eba2e-20df-4cb4-ad8c-8299ea7ab9e0_2101x1370.png 1272w, https://substackcdn.com/image/fetch/$s_!waRm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F592eba2e-20df-4cb4-ad8c-8299ea7ab9e0_2101x1370.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!waRm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F592eba2e-20df-4cb4-ad8c-8299ea7ab9e0_2101x1370.png" width="1456" height="949" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/592eba2e-20df-4cb4-ad8c-8299ea7ab9e0_2101x1370.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:949,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:200182,&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;: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_!waRm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F592eba2e-20df-4cb4-ad8c-8299ea7ab9e0_2101x1370.png 424w, https://substackcdn.com/image/fetch/$s_!waRm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F592eba2e-20df-4cb4-ad8c-8299ea7ab9e0_2101x1370.png 848w, https://substackcdn.com/image/fetch/$s_!waRm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F592eba2e-20df-4cb4-ad8c-8299ea7ab9e0_2101x1370.png 1272w, https://substackcdn.com/image/fetch/$s_!waRm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F592eba2e-20df-4cb4-ad8c-8299ea7ab9e0_2101x1370.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"><a href="https://app.eraser.io/workspace/LkLxPbebfWJhCH7GSS7y?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h3><strong>Use Read Replicas for Scaling Reads</strong></h3><p>If you have millions of reads per second, create read replicas to distribute the load.</p><p>For example:</p><ul><li><p><strong>Primary DB:</strong> Handles writes and critical reads.</p></li><li><p><strong>Read Replicas:</strong> Handle read queries.</p></li></ul><p>Many large-scale systems use this approach for redundancy as well as improved durability.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!F5lJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ade9f26-135b-4d13-83b1-b8ea7f3ad693_1929x1319.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!F5lJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ade9f26-135b-4d13-83b1-b8ea7f3ad693_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!F5lJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ade9f26-135b-4d13-83b1-b8ea7f3ad693_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!F5lJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ade9f26-135b-4d13-83b1-b8ea7f3ad693_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!F5lJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ade9f26-135b-4d13-83b1-b8ea7f3ad693_1929x1319.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!F5lJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ade9f26-135b-4d13-83b1-b8ea7f3ad693_1929x1319.png" width="1456" height="996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8ade9f26-135b-4d13-83b1-b8ea7f3ad693_1929x1319.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:199699,&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;: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_!F5lJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ade9f26-135b-4d13-83b1-b8ea7f3ad693_1929x1319.png 424w, https://substackcdn.com/image/fetch/$s_!F5lJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ade9f26-135b-4d13-83b1-b8ea7f3ad693_1929x1319.png 848w, https://substackcdn.com/image/fetch/$s_!F5lJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ade9f26-135b-4d13-83b1-b8ea7f3ad693_1929x1319.png 1272w, https://substackcdn.com/image/fetch/$s_!F5lJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ade9f26-135b-4d13-83b1-b8ea7f3ad693_1929x1319.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"><a href="https://app.eraser.io/workspace/LkLxPbebfWJhCH7GSS7y?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><h2><strong>Conclusion: Diagnose Before You Optimize</strong></h2><p>Here are some tips to keep in mind:</p><ul><li><p><strong>Don&#8217;t blindly optimize</strong>&#8212;use logs and profiling to find real bottlenecks.</p></li><li><p><strong>Start with query optimization</strong>&#8212;indexes, joins, and batching solve 80% of problems.</p></li><li><p><strong>Use caching and read replicas</strong>&#8212;offload repetitive queries.</p></li><li><p><strong>Think about scaling architecture</strong>&#8212;sharding, partitioning, and hybrid databases.</p></li></ul><p>A slow database doesn&#8217;t have to hold you back. With the right optimizations, you can make your system blazing fast and scalable.</p><p>&#128073; <strong>So - which other tip will you add to optimize the database access?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-to-prevent-the-db-from-becoming/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/how-to-prevent-the-db-from-becoming/comments"><span>Leave a comment</span></a></p><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/how-to-prevent-the-db-from-becoming?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.systemdesigncodex.com/p/how-to-prevent-the-db-from-becoming?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p><em><strong>See you later with another edition &#8212; Saurabh</strong></em></p>]]></content:encoded></item><item><title><![CDATA[Airbnb's Move from Monolith]]></title><description><![CDATA[The journey of migration]]></description><link>https://newsletter.systemdesigncodex.com/p/airbnbs-move-from-monolith</link><guid isPermaLink="false">https://newsletter.systemdesigncodex.com/p/airbnbs-move-from-monolith</guid><dc:creator><![CDATA[Saurabh Dashora]]></dc:creator><pubDate>Tue, 17 Feb 2026 07:56:10 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!ZNoT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Like most startups, Airbnb started with a monolithic application built using Ruby on Rails. Internally, it was called the <em>monorail</em> because everything went through this single application.</p><p>This monolith was responsible for both client and server-side functionality. The model, view, and controller layers were packed into a single repository.</p><p>A simple diagram for this architecture would appear 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_!ZNoT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZNoT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.png 424w, https://substackcdn.com/image/fetch/$s_!ZNoT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.png 848w, https://substackcdn.com/image/fetch/$s_!ZNoT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.png 1272w, https://substackcdn.com/image/fetch/$s_!ZNoT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZNoT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.png" width="1456" height="1044" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1044,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:164218,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;: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_!ZNoT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.png 424w, https://substackcdn.com/image/fetch/$s_!ZNoT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.png 848w, https://substackcdn.com/image/fetch/$s_!ZNoT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.png 1272w, https://substackcdn.com/image/fetch/$s_!ZNoT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feed9c53e-abbe-4c88-82c7-da34cb05ece1_1698x1218.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><figcaption class="image-caption"><a href="https://app.eraser.io/workspace/qww9HW81DEoiIj7zS5W3?origin=share">You can check out the diagram on Eraser.io</a></figcaption></figure></div><p>There were several advantages to this monolithic approach:</p><ul><li><p>Easy to get started initially.</p></li><li><p>Good for agile development</p></li><li><p>Manageable complexity levels</p></li></ul><p>Those were simpler times and such times usually don&#8217;t last. Airbnb grew fast, and its engineering team doubled and tripled. Suddenly, you had more and more developers adding new code and features to the monorail.</p><p>Just like too many cooks spoil the dish, the code base started to get tightly coupled, and data ownership became muddled. Any developer could make changes to any part of the application, making it difficult to track and coordinate the changes.</p><p>Airbnb decided to migrate from the monorail to a Service-Oriented Architecture. You could also see it as a move towards loosely coupled microservices.</p><h1><strong>The Rules of the Game</strong></h1><p>Of course, Airbnb was wise and came up with some key design principles for building services. Some of the rules are mentioned below:</p><ul><li><p>A service should own both the reads and writes to its data. This is similar to the database-per-service pattern where a particular piece of data is owned by one and only one service.</p></li><li><p>A service should address a specific concern</p></li><li><p>Services should avoid duplicating functionality</p></li><li><p>Data changes should happen via standard events to encourage loose coupling.</p></li><li><p>Each service must have proper alerting and observability settings</p></li></ul><h1><strong>The SOA Design</strong></h1><p>After a few years of migration stuff, Airbnb ended up with the below architecture:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jIt2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F432ddaae-77cd-45eb-b4d4-379093ced8e1_1698x1906.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jIt2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F432ddaae-77cd-45eb-b4d4-379093ced8e1_1698x1906.png 424w, https://substackcdn.com/image/fetch/$s_!jIt2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F432ddaae-77cd-45eb-b4d4-379093ced8e1_1698x1906.png 848w, https://substackcdn.com/image/fetch/$s_!jIt2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F432ddaae-77cd-45eb-b4d4-379093ced8e1_1698x1906.png 1272w, https://substackcdn.com/image/fetch/$s_!jIt2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F432ddaae-77cd-45eb-b4d4-379093ced8e1_1698x1906.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jIt2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F432ddaae-77cd-45eb-b4d4-379093ced8e1_1698x1906.png" width="1456" height="1634" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/432ddaae-77cd-45eb-b4d4-379093ced8e1_1698x1906.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1634,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:250672,&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;: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_!jIt2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F432ddaae-77cd-45eb-b4d4-379093ced8e1_1698x1906.png 424w, https://substackcdn.com/image/fetch/$s_!jIt2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F432ddaae-77cd-45eb-b4d4-379093ced8e1_1698x1906.png 848w, https://substackcdn.com/image/fetch/$s_!jIt2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F432ddaae-77cd-45eb-b4d4-379093ced8e1_1698x1906.png 1272w, https://substackcdn.com/image/fetch/$s_!jIt2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F432ddaae-77cd-45eb-b4d4-379093ced8e1_1698x1906.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"><a href="https://app.eraser.io/workspace/qww9HW81DEoiIj7zS5W3?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>Let&#8217;s unpack it a bit.</p><ul><li><p>The bottom layer is composed of <strong>data services</strong>. These services are the entry point for all interactions with the database and aren&#8217;t dependent on any other service.</p></li><li><p>The <strong>derived services</strong> read data from other services and apply basic business logic. They can also have specialized data storage to store any derived data.</p></li><li><p>The <strong>middle-tier services</strong> contain the key business logic that doesn&#8217;t fit at the data service level or the derived data service level.</p></li><li><p>At the very top are the <strong>presentation services</strong>. These services aggregate data from all other services and apply frontend-specific business logic before returning the data to the client.</p></li></ul><h1><strong>The Migration</strong></h1><p>The move from the <em>monorail</em> to shiny new services wasn&#8217;t an overnight process. Also, migrating reads and writes had their problems.</p><p>Let&#8217;s look at both scenarios and how Airbnb handled the migration.</p><h2><strong>Migrating the Reads</strong></h2><p>Airbnb used dual reads and response comparison for the old read path (through the <em>monorail) </em>and the new read path (the service).</p><p>See the diagram 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_!mVXY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F950084c7-1210-44b6-a3d7-faa7d1eaadd9_1698x1218.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mVXY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F950084c7-1210-44b6-a3d7-faa7d1eaadd9_1698x1218.png 424w, https://substackcdn.com/image/fetch/$s_!mVXY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F950084c7-1210-44b6-a3d7-faa7d1eaadd9_1698x1218.png 848w, https://substackcdn.com/image/fetch/$s_!mVXY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F950084c7-1210-44b6-a3d7-faa7d1eaadd9_1698x1218.png 1272w, https://substackcdn.com/image/fetch/$s_!mVXY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F950084c7-1210-44b6-a3d7-faa7d1eaadd9_1698x1218.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mVXY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F950084c7-1210-44b6-a3d7-faa7d1eaadd9_1698x1218.png" width="1456" height="1044" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/950084c7-1210-44b6-a3d7-faa7d1eaadd9_1698x1218.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1044,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:146004,&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;: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_!mVXY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F950084c7-1210-44b6-a3d7-faa7d1eaadd9_1698x1218.png 424w, https://substackcdn.com/image/fetch/$s_!mVXY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F950084c7-1210-44b6-a3d7-faa7d1eaadd9_1698x1218.png 848w, https://substackcdn.com/image/fetch/$s_!mVXY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F950084c7-1210-44b6-a3d7-faa7d1eaadd9_1698x1218.png 1272w, https://substackcdn.com/image/fetch/$s_!mVXY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F950084c7-1210-44b6-a3d7-faa7d1eaadd9_1698x1218.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"><a href="https://app.eraser.io/workspace/qww9HW81DEoiIj7zS5W3?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>Every read request went through both paths. The responses were sent to a comparison framework. Once the engineers were sure that things were as expected, the traffic to the service path was ramped up.</p><h2><strong>Migrating the Writes</strong></h2><p>Writes were trickier because one cannot dual-write to the same database. Therefore, the engineers used a shadow database.</p><p>See the diagram 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_!McET!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77e4531a-141b-4948-9751-512fe10dd27b_1698x1218.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!McET!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77e4531a-141b-4948-9751-512fe10dd27b_1698x1218.png 424w, https://substackcdn.com/image/fetch/$s_!McET!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77e4531a-141b-4948-9751-512fe10dd27b_1698x1218.png 848w, https://substackcdn.com/image/fetch/$s_!McET!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77e4531a-141b-4948-9751-512fe10dd27b_1698x1218.png 1272w, https://substackcdn.com/image/fetch/$s_!McET!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77e4531a-141b-4948-9751-512fe10dd27b_1698x1218.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!McET!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77e4531a-141b-4948-9751-512fe10dd27b_1698x1218.png" width="1456" height="1044" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/77e4531a-141b-4948-9751-512fe10dd27b_1698x1218.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1044,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:173306,&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;: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_!McET!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77e4531a-141b-4948-9751-512fe10dd27b_1698x1218.png 424w, https://substackcdn.com/image/fetch/$s_!McET!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77e4531a-141b-4948-9751-512fe10dd27b_1698x1218.png 848w, https://substackcdn.com/image/fetch/$s_!McET!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77e4531a-141b-4948-9751-512fe10dd27b_1698x1218.png 1272w, https://substackcdn.com/image/fetch/$s_!McET!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77e4531a-141b-4948-9751-512fe10dd27b_1698x1218.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"><a href="https://app.eraser.io/workspace/qww9HW81DEoiIj7zS5W3?origin=share">You can play around with the diagram on Eraser.io</a></figcaption></figure></div><p>The new service initially writes to the shadow database. After that, read requests are sent to the prod and shadow database, and the responses are sent to the comparison framework.</p><p>Only after the comparison came out clean, the writes were completely switched to the new service.</p><h1><strong>Lessons</strong></h1><p>Airbnb had several important lessons from this whole migration process. A few important ones for us are as follows</p><ul><li><p>Invest in common infrastructure pieces early on. Things like shadow databases, comparison frameworks, etc. can help during the migration.</p></li><li><p>Simplify the service dependencies</p></li><li><p>Moving to services is not just technical but also a cultural change for the organization.</p></li><li><p>The migration isn&#8217;t a fixed destination but a journey.</p></li></ul><p><strong>So - what do you think about Airbnb&#8217;s migration journey? Would you have done something differently?</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/airbnbs-move-from-monolith/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://newsletter.systemdesigncodex.com/p/airbnbs-move-from-monolith/comments"><span>Leave a comment</span></a></p><p><strong>References:</strong></p><ul><li><p><a href="https://www.infoq.com/news/2019/02/airbnb-monolith-migration-soa/">Airbnb&#8217;s Migration from Monolith to Services</a></p></li><li><p><a href="https://www.infoq.com/presentations/airbnb-scalability/">Airbnb at Scale</a></p></li></ul><div><hr></div><p><strong>That&#8217;s it for today! &#9728;&#65039;</strong></p><p>Enjoyed this issue of the newsletter?</p><p>Share with your friends and colleagues.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://newsletter.systemdesigncodex.com/p/airbnbs-move-from-monolith?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.systemdesigncodex.com/p/airbnbs-move-from-monolith?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p><em><strong>See you later with another edition &#8212; Saurabh</strong></em></p>]]></content:encoded></item></channel></rss>