<?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[Deadlock Diaries]]></title><description><![CDATA[Untangling complexity in distributed systems]]></description><link>https://gautamshubham.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!9VhQ!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1aea701d-70c7-4583-9667-1d80b933e0dd_1024x1024.png</url><title>Deadlock Diaries</title><link>https://gautamshubham.substack.com</link></image><generator>Substack</generator><lastBuildDate>Fri, 03 Apr 2026 22:49:34 GMT</lastBuildDate><atom:link href="https://gautamshubham.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Shubham Gautam]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[gautamshubham@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[gautamshubham@substack.com]]></itunes:email><itunes:name><![CDATA[Shubham Gautam]]></itunes:name></itunes:owner><itunes:author><![CDATA[Shubham Gautam]]></itunes:author><googleplay:owner><![CDATA[gautamshubham@substack.com]]></googleplay:owner><googleplay:email><![CDATA[gautamshubham@substack.com]]></googleplay:email><googleplay:author><![CDATA[Shubham Gautam]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Scaling Nested Optimization: A Systems Horror Story]]></title><description><![CDATA[When your optimization loop needs its own optimization loop, the elegant math becomes a systems nightmare.]]></description><link>https://gautamshubham.substack.com/p/scaling-nested-optimization-a-systems</link><guid isPermaLink="false">https://gautamshubham.substack.com/p/scaling-nested-optimization-a-systems</guid><dc:creator><![CDATA[Shubham Gautam]]></dc:creator><pubDate>Fri, 09 Jan 2026 17:53:07 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!9VhQ!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1aea701d-70c7-4583-9667-1d80b933e0dd_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div><hr></div><p>Think of training a giant AI model as trying to find the lowest point in a vast, foggy valley. You send out explorers (workers) to feel the slope (calculate gradients) and collectively march downhill. That&#8217;s distributed training.</p><p>Now, imagine you could also optimize the explorers themselves &#8212; tune their stride length (learning rate), change their shoes (optimizer), or even reshape the valley (model architecture) on the fly.</p><p>This meta-optimization &#8212; an optimization loop <em>around</em> your main training loop &#8212; is called <strong>nested</strong> or <strong>high-order optimization</strong>. It&#8217;s the engine behind hyperparameter tuning, meta-learning, and adversarial training.</p><p>But here&#8217;s the catch: scaling this brilliant idea beyond a single machine isn&#8217;t just harder &#8212; it&#8217;s a <em>different beast entirely</em>.</p><div><hr></div><h2><strong>The Three Headaches Nobody Talks About</strong></h2><h3><strong>1. The Staleness Cascade</strong></h3><p>In a standard training loop, if one GPU is slow, its gradient is a bit stale, but the average usually works out.</p><p>In a nested loop? Disaster.</p><p>The &#8220;inner loop&#8221; (say, 100 steps of training a model) is itself a complex computation whose result becomes the input to the &#8220;outer loop&#8221; (one step of updating hyperparameters).</p><p>Workers finish their inner loops at different times. If the outer loop updates using the result from the fastest worker, it&#8217;s now working with a state that is <em>completely unaware</em> of the learning still happening on slower workers.</p><p>This isn&#8217;t a slightly stale gradient. It&#8217;s a fundamentally different, misleading answer. The outer loop makes a bad decision, which sends all workers down the wrong path.</p><p><strong>It&#8217;s a game of broken telephone where the message changes mid-whisper.</strong></p><h3><strong>2. Parameter Server Gridlock</strong></h3><p>A standard Parameter Server is like an air traffic controller for model weights. It keeps the official copy, and workers sync with it.</p><p>In nested optimization, the &#8220;state&#8221; isn&#8217;t just the model. It&#8217;s:</p><ul><li><p>The main model parameters</p></li><li><p>The outer-loop parameters (hyperparameters)</p></li><li><p>The inner-loop optimization state (momentum buffers)</p></li><li><p>The <em>historical trajectory</em> of the inner loop (needed for meta-gradients)</p></li></ul><p>A vanilla PS wasn&#8217;t designed for this. The coordination logic becomes a bottleneck, and workers spend most of their time waiting to lock and update this complex, shared state.</p><p><strong>The simple PS pattern turns into a gridlocked intersection.</strong></p><h3><strong>3. Communication Avalanche</strong></h3><p>The inner loop might take 100 steps. In a naive distributed setup, <em>each of those 100 steps</em> could require a synchronization across the network.</p><p>This creates a flood of tiny messages. Network latency, not computation, becomes the dominant cost. You add GPUs to go faster, but the communication overhead grows so much that you actually <em>slow down</em>.</p><div><hr></div><h2><strong>The Solution: Strategic Laziness</strong></h2><p>I built <strong>Chronos</strong>, a framework designed to tame this chaos. The key insight:</p><blockquote><p><em>Perfect synchronization at every step is not only impossible &#8212; it&#8217;s unnecessary for convergence.</em></p></blockquote><p>We introduced controlled, intelligent approximations:</p><p><strong>For Staleness: Versioned Bounded Asynchrony</strong></p><p>We treat outer-loop parameters like a versioned database. An inner loop &#8220;checks out&#8221; a version and works on it. We strictly bound how many versions can be in flight. Slow workers don&#8217;t poison the system &#8212; their slightly older results are incorporated later, acting like a form of regularization noise.</p><p><strong>For the PS: Hybrid State Management</strong></p><p>We split the state. High-frequency, large-volume data (model parameters) uses peer-to-peer All-Reduce. The complex, low-frequency meta-state (hyperparameters, trajectories) lives on a lightweight coordinator. This removes the gridlock.</p><p><strong>For Communication: Significance-Triggered Protocol</strong></p><p>This was our biggest win. Instead of syncing at every inner step, workers compute locally. They only communicate when their local change exceeds a dynamic threshold &#8212; when the update is <em>actually meaningful</em>.</p><p>This turns constant chatter into occasional, meaningful bulletins.</p><div><hr></div><h2><strong>The Results</strong></h2><p><strong>MetricImprovementNetwork traffic</strong>-40%<strong>Wall-clock time</strong>-28%<strong>Final accuracy</strong>No degradation (sometimes better!)</p><p>The introduced noise from bounded asynchrony sometimes even helped generalization.</p><div><hr></div><h2><strong>The Bigger Picture</strong></h2><p>As AI moves towards more adaptive, self-tuning models, the underlying systems must evolve with it.</p><p>The next breakthrough in model capability might not come from a new algorithm alone, but from the <strong>systems engineering</strong> that lets that algorithm run efficiently across a thousand machines.</p><p>The challenge shifts from &#8220;can we compute this?&#8221; to &#8220;can we <em>orchestrate</em> this computation at scale?&#8221;</p><div><hr></div><h2><strong>Try It Yourself</strong></h2><p>Chronos is open-source on GitHub:</p><p>&#128073; <strong><a href="https://github.com/ichbingautam/chronos">github.com/ichbingautam/chronos</a></strong></p><p>Star it, fork it, or use it in your research. The codebase implements everything described here &#8212; versioned bounded asynchrony, significance-triggered communication, and the HOPE continuum memory system.</p><div><hr></div><p><em>What&#8217;s your experience with distributed meta-learning? Hit reply &#8212; I read every response.</em></p>]]></content:encoded></item><item><title><![CDATA[🚀 "Taming the Heap: A Go Developer’s Guide to Memory Optimization" is now live on Backend Chronicles!]]></title><description><![CDATA[Practical Techniques to Reduce Allocations and Improve Performance]]></description><link>https://gautamshubham.substack.com/p/taming-the-heap-a-go-developers-guide</link><guid isPermaLink="false">https://gautamshubham.substack.com/p/taming-the-heap-a-go-developers-guide</guid><dc:creator><![CDATA[Shubham Gautam]]></dc:creator><pubDate>Mon, 26 May 2025 06:19:11 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!9VhQ!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1aea701d-70c7-4583-9667-1d80b933e0dd_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Most Go developers focus on CPU-bound performance. But in real-world backend systems, <strong>heap allocations</strong> can quietly become your biggest bottleneck.</p><p>This week in <em>Backend Chronicles</em>, we&#8217;re exploring one of the most overlooked aspects of Go performance &#8212; <strong>memory optimization</strong>. Inspired by <a href="https://gautam-shubham.medium.com/taming-the-heap-a-go-developers-guide-to-memory-optimization-fe022953ff33">Taming the Heap: A Go Developer&#8217;s Guide to Memory Optimization</a>, this post walks you through techniques to <strong>understand, measure, and reduce heap usage</strong> in your Go applications.</p><h3>&#129504; Why Memory Optimization Matters</h3><ul><li><p>Excessive allocations slow down garbage collection.</p></li><li><p>Reduced heap usage improves throughput and latency.</p></li><li><p>Optimized memory = fewer pauses, better performance under load.</p></li></ul><div><hr></div><h3>&#128269; Profiling the Heap</h3><p>Use Go's <code>pprof</code> and <code>go tool pprof</code> to:</p><ul><li><p>Visualize memory usage (<code>alloc_space</code> and <code>alloc_objects</code>)</p></li><li><p>Identify high-allocation functions</p></li><li><p>Understand memory lifetime and escape analysis</p></li></ul><div><hr></div><h3>&#128736;&#65039; Optimization Strategies</h3><ol><li><p><strong>Reuse Objects</strong><br>Use <code>sync.Pool</code> to reuse frequently allocated structs or buffers.</p></li><li><p><strong>Avoid Unnecessary Slices &amp; Maps</strong><br>Pre-allocate slices when the final size is known. Avoid creating large maps inside tight loops.</p></li><li><p><strong>Minimize Pointer Usage</strong><br>Pointers increase GC overhead and may lead to heap allocations due to escape analysis.</p></li><li><p><strong>Escape Analysis Awareness</strong><br>Use <code>go build -gcflags='-m'</code> to check if variables escape to the heap unexpectedly.</p></li><li><p><strong>Zero Allocation Patterns</strong><br>Refactor frequently called code paths to reduce or eliminate allocations (e.g., via value receivers or struct reuse).</p></li></ol><div><hr></div><h3>&#10024; Real-World Example</h3><blockquote><p>A change from returning a <code>[]byte</code> to using a buffer pool reduced allocations by <strong>50%</strong> and improved latency <strong>by 20%</strong>.</p></blockquote><div><hr></div><h3>Final Thoughts</h3><p>Memory tuning is <strong>not premature optimization</strong>&#8212;it&#8217;s <strong>intentional design</strong>. If you're building scalable services in Go, understanding the heap is non-negotiable.</p><p>&#128201; Less memory. &#128293; More speed. &#9989; Happier services.</p><div><hr></div><p>&#128073; <strong>Read the full article</strong>:<br><a href="https://gautam-shubham.medium.com/taming-the-heap-a-go-developers-guide-to-memory-optimization-fe022953ff33">Taming the Heap: A Go Developer&#8217;s Guide to Memory Optimization</a></p><div><hr></div><p><strong>Enjoy this breakdown?</strong><br><em>Backend Chronicles</em> covers actionable tips for real-world backend engineering: performance tuning, scaling strategies, and more.</p>]]></content:encoded></item><item><title><![CDATA[Stop Guessing, Start Measuring: A Practical Guide to Benchmarking Go Applications]]></title><description><![CDATA[Real-World Performance Tuning for Backend Engineers]]></description><link>https://gautamshubham.substack.com/p/stop-guessing-start-measuring-a-practical</link><guid isPermaLink="false">https://gautamshubham.substack.com/p/stop-guessing-start-measuring-a-practical</guid><dc:creator><![CDATA[Shubham Gautam]]></dc:creator><pubDate>Mon, 26 May 2025 06:11:13 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!reEm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you've ever found yourself saying, "I think this code is slow&#8230;" This post is for you.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!reEm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!reEm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!reEm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!reEm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!reEm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!reEm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1482336,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://gautamshubham.substack.com/i/164459911?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!reEm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!reEm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!reEm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!reEm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1825be60-7b42-4d21-9026-74e893dbd122_1536x1024.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>In production-grade systems, <strong>guesswork is the enemy</strong> of performance. Yet many developers still rely on intuition instead of data to optimize code.</p><p>In this week&#8217;s edition of <em>Backend Chronicles</em>, we dive into a no-fluff, practical guide to benchmarking Go applications. Based on <a href="https://gautam-shubham.medium.com/stop-guessing-start-measuring-a-practical-guide-to-go-application-benchmarking-performance-fdffd69d1d3f">Stop Guessing, Start Measuring: A Practical Guide to Go Application Benchmarking &amp; Performance</a>, here are some key takeaways:</p><h3>&#128269; Why Benchmarking Matters</h3><ul><li><p>Optimizing without benchmarks is like tuning an engine blindfolded.</p></li><li><p>Premature optimization often targets the wrong bottlenecks.</p></li></ul><h3>&#128736;&#65039; Tools of the Trade</h3><ul><li><p>Go&#8217;s built-in <code>testing.B</code> </p></li><li><p><code>benchstat</code> for comparing benchmark runs</p></li><li><p><code>pprof</code> for profiling real-world performance</p></li></ul><h3>&#128207; Measuring What Matters</h3><ul><li><p>Benchmark functions need realistic inputs and a tight scope.</p></li><li><p>Always run benchmarks on the same machine, in similar conditions.</p></li><li><p>Small code changes can make or break latency budgets.</p></li></ul><h3>&#9989; Actionable Steps</h3><ol><li><p>Write microbenchmarks for the critical path.</p></li><li><p>Profile hot paths using <code>go test -bench</code> and <code>pprof</code>.</p></li><li><p>Compare and repeat with <code>benchstat</code>.</p></li></ol><p>&#128073; <strong>Read the full article</strong>:<br><a href="https://gautam-shubham.medium.com/stop-guessing-start-measuring-a-practical-guide-to-go-application-benchmarking-performance-fdffd69d1d3f">Stop Guessing, Start Measuring: A Practical Guide to Go Application Benchmarking &amp; Performance</a></p><div><hr></div><p><strong>TL;DR</strong>: If you're building scalable, high-performance backend systems in Go, benchmarking isn&#8217;t optional &#8212; it&#8217;s foundational.</p><p>&#129504; <em>Start measuring. Stop guessing. Build better systems.</em></p><div><hr></div><p><strong>Like this breakdown?</strong><br>Subscribe to <em>Backend Chronicles</em> for real-world backend engineering insights&#8212;weekly breakdowns on performance, scalability, architecture, and more.</p><p></p>]]></content:encoded></item><item><title><![CDATA[Join my new subscriber chat]]></title><description><![CDATA[A private space for us to converse and connect]]></description><link>https://gautamshubham.substack.com/p/join-my-new-subscriber-chat</link><guid isPermaLink="false">https://gautamshubham.substack.com/p/join-my-new-subscriber-chat</guid><dc:creator><![CDATA[Shubham Gautam]]></dc:creator><pubDate>Sun, 25 May 2025 11:30:34 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!KYZT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Today I&#8217;m announcing a brand new addition to my Substack publication: Better Engineering  subscriber chat.</p><p>This is a conversation space exclusively for subscribers&#8212;kind of like a group chat or live hangout. I&#8217;ll post questions and updates that come my way, and you can jump into the discussion.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://open.substack.com/pub/gautamshubham/chat&quot;,&quot;text&quot;:&quot;Join chat&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://open.substack.com/pub/gautamshubham/chat"><span>Join chat</span></a></p><div><hr></div><h2>How to get started</h2><ol><li><p><strong>Get the Substack app by clicking <a href="https://substack.com/app/app-store-redirect">this link</a> or the button below.</strong> New chat threads won&#8217;t be sent sent via email, so turn on push notifications so you don&#8217;t miss conversation as it happens. You can also access chat <a href="https://open.substack.com/pub/gautamshubham/chat">on the web</a>.</p></li></ol><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://substack.com/app/app-store-redirect&quot;,&quot;text&quot;:&quot;Get app&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://substack.com/app/app-store-redirect"><span>Get app</span></a></p><ol start="2"><li><p><strong>Open the app and tap the Chat icon.</strong> It looks like two bubbles in the bottom bar, and you&#8217;ll see a row for my chat inside.</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_!KYZT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KYZT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg 424w, https://substackcdn.com/image/fetch/$s_!KYZT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg 848w, https://substackcdn.com/image/fetch/$s_!KYZT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!KYZT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KYZT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg" width="1456" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:728,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:241528,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://kylewarrentest.substack.com/i/114198534?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KYZT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg 424w, https://substackcdn.com/image/fetch/$s_!KYZT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg 848w, https://substackcdn.com/image/fetch/$s_!KYZT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!KYZT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0f63c9a-2296-4c96-a2f9-52648999bb00_2000x1000.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ol start="3"><li><p><strong>That&#8217;s it!</strong> Jump into my thread to say hi, and if you have any issues, check out <a href="https://support.substack.com/hc/en-us/sections/360007461791-Frequently-Asked-Questions">Substack&#8217;s FAQ</a>.</p></li></ol>]]></content:encoded></item><item><title><![CDATA[Unleash Your Application’s Power: A Deep Dive into Go Concurrency]]></title><description><![CDATA[Hey folks &#128075;Golang&#8217;s concurrency model is one of its standout features&#8212;but it&#8217;s also one of the most misunderstood.I just published a deep dive into Go's concurrency model: how it works, where it shines, and how you can use it to write more efficient and scalable applications.&#128073; Read the full article:Unleash Your Application's Power &#8211; A Deep Dive into Go Concurrency]]></description><link>https://gautamshubham.substack.com/p/unleash-your-applications-power-a</link><guid isPermaLink="false">https://gautamshubham.substack.com/p/unleash-your-applications-power-a</guid><dc:creator><![CDATA[Shubham Gautam]]></dc:creator><pubDate>Sun, 25 May 2025 06:48:11 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!9VhQ!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1aea701d-70c7-4583-9667-1d80b933e0dd_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey folks &#128075;</p><p>Golang&#8217;s concurrency model is one of its standout features&#8212;but it&#8217;s also one of the most misunderstood.</p><p>I just published a deep dive into <strong>Go's concurrency model</strong>: how it works, where it shines, and how you can use it to write more efficient and scalable applications.</p><p>&#128073; <strong>Read the full article</strong>:<br><a href="https://gautam-shubham.medium.com/unleash-your-applications-power-a-deep-dive-into-go-concurrency-318c7d1367fb">Unleash Your Application's Power &#8211; A Deep Dive into Go Concurrency</a></p><div><hr></div><h3>&#128269; What You&#8217;ll Learn</h3><p>&#9989; What makes Go&#8217;s concurrency model different from threads and async<br>&#9989; A detailed walkthrough of goroutines, channels, and <code>select</code> statements<br>&#9989; Real-world concurrency patterns (worker pools, fan-in/fan-out, timeouts)<br>&#9989; Common pitfalls: memory leaks, deadlocks, race conditions<br>&#9989; When <em>not</em> to use concurrency &#8212; and why clarity &gt; cleverness</p><div><hr></div><h3>&#9881;&#65039; Why It Matters</h3><p>Modern backend applications are expected to do <strong>more work with fewer resources</strong>. Go&#8217;s lightweight goroutines and powerful sync primitives help you get there&#8212;but only if you know how to use them effectively.</p><p>If you're building:</p><ul><li><p>APIs that handle large volumes of concurrent requests</p></li><li><p>Services with time-sensitive background tasks</p></li><li><p>Data pipelines or event-driven systems</p></li><li><p>Anything performance-critical...</p></li></ul><p>&#8230; This post will help you <strong>make concurrency a strength</strong>, not a source of bugs.</p><div><hr></div><h3>&#128161; Bonus</h3><p>The post includes runnable code samples, practical use cases, and performance tips drawn from real-world backend systems I've worked on.</p><div><hr></div><h3>&#128279; Read Now</h3><p>&#128640; <a href="https://gautam-shubham.medium.com/unleash-your-applications-power-a-deep-dive-into-go-concurrency-318c7d1367fb">Unleash Your Application's Power &#8211; A Deep Dive into Go Concurrency</a></p><div><hr></div><p>Whether you&#8217;re just getting into Go or already building production services with it, I&#8217;d love to hear your thoughts, feedback, and experiences with Go's concurrency model.</p><p>More backend deep-dives and real-world system design insights coming soon.</p><p>Thanks for reading &#128591;<br>&#8212;<br><strong>Gautam Shubham</strong><br><em>Backend Engineer | Go Enthusiast | Medium Writer</em></p>]]></content:encoded></item><item><title><![CDATA[Untangling PostgreSQL Locks: How to Fix Hidden Performance Bottlenecks]]></title><description><![CDATA[Hey folks &#128075; If you've ever run into slow queries, blocked transactions, or that dreaded deadlock detected error in PostgreSQL &#8212; you're not alone.I just published a blog post that dives deep into one of the most overlooked causes of database performance issues: row-level locking and contention.&#128073; Read the full article:Untangling PostgreSQL Locks &#8211; Your Guide to Conquering Database Contention]]></description><link>https://gautamshubham.substack.com/p/untangling-postgresql-locks-how-to</link><guid isPermaLink="false">https://gautamshubham.substack.com/p/untangling-postgresql-locks-how-to</guid><dc:creator><![CDATA[Shubham Gautam]]></dc:creator><pubDate>Sun, 25 May 2025 06:40:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!9VhQ!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1aea701d-70c7-4583-9667-1d80b933e0dd_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey folks &#128075;</p><p>If you've ever run into <strong>slow queries, blocked transactions</strong>, or that dreaded <code>deadlock detected</code> error in PostgreSQL &#8212; you're not alone.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://gautamshubham.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Better Engineering! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>I just published a blog post that dives deep into one of the <strong>most overlooked causes of database performance issues</strong>: <strong>row-level locking and contention</strong>.</p><p>&#128073; <strong>Read the full article</strong>:<br><a href="https://gautam-shubham.medium.com/untangling-postgresql-locks-your-guide-to-conquering-database-contention-a24983eac913">Untangling PostgreSQL Locks &#8211; Your Guide to Conquering Database Contention</a></p><div><hr></div><h3>&#128269; What You&#8217;ll Learn</h3><p>&#9989; How PostgreSQL handles row-level locks behind the scenes<br>&#9989; Different lock modes (<code>FOR UPDATE</code>, <code>FOR SHARE</code>, etc.) and when to use them<br>&#9989; Real-world examples of deadlocks and blocked transactions<br>&#9989; Query inspection tools like <code>pg_locks</code> and <code>pg_stat_activity</code><br>&#9989; Strategies to prevent and resolve contention, including indexing tips and timeout settings</p><div><hr></div><h3>&#128736; Use Cases</h3><p>If you're working with:</p><ul><li><p>High-concurrency APIs or microservices</p></li><li><p>Background workers writing to the same tables</p></li><li><p>Batch jobs or cron processes touching shared rows</p></li><li><p>OLTP systems with high write volumes</p></li></ul><p>&#8230;then this guide will help you <strong>detect, debug, and fix locking issues</strong> before they hurt your performance.</p><div><hr></div><h3>&#128200; Why This Matters</h3><p>Lock contention is one of those problems that creeps in slowly and suddenly becomes a <strong>fire in production</strong>. Understanding how PostgreSQL locks work is critical if you're scaling your backend or optimizing database performance.</p><div><hr></div><h3>&#128279; Read Now</h3><p>&#128073; <a href="https://gautam-shubham.medium.com/untangling-postgresql-locks-your-guide-to-conquering-database-contention-a24983eac913">Untangling PostgreSQL Locks &#8211; Your Guide to Conquering Database Contention</a></p><p>Would love to hear how you handle lock contention in your systems &#8212; reply or drop a comment with your approach.</p><p>Thanks for reading &#128591;<br>More deep dives on scaling, observability, and backend engineering coming soon.</p><p>&#8212;<br><strong>Shubham Gautam</strong><br><em>Backend Engineer | System Design Enthusiast </em></p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://gautamshubham.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Better Engineering! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Master Concurrent Queues with SKIP LOCKED: The Secret to High-Performance PostgreSQL Systems]]></title><description><![CDATA[Hi everyone &#128075;. If you've ever struggled with queue contention in high-concurrency systems or are curious how to optimize task processing in PostgreSQL, my latest blog post might interest you.&#128073; Read the full post here: Master Concurrent Queues with SKIP LOCKED &#8211; Boost Your System&#8217;s Performance]]></description><link>https://gautamshubham.substack.com/p/master-concurrent-queues-with-skip</link><guid isPermaLink="false">https://gautamshubham.substack.com/p/master-concurrent-queues-with-skip</guid><dc:creator><![CDATA[Shubham Gautam]]></dc:creator><pubDate>Sun, 25 May 2025 05:50:59 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!9VhQ!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1aea701d-70c7-4583-9667-1d80b933e0dd_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hi everyone &#128075;</p><p>Today I&#8217;m excited to share a deep-dive blog post I recently published on Medium, where I explore a powerful technique for improving performance in high-concurrency systems: <strong>PostgreSQL&#8217;s </strong><code>SKIP LOCKED</code>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://gautamshubham.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Better Engineering! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>&#128073; <strong>Read the full article here</strong>:<br><a href="https://medium.com/@gautam-shubham/master-concurrent-queues-with-skip-locked-boost-your-systems-performance-46de4bfb0511">Master Concurrent Queues with SKIP LOCKED &#8211; Boost Your System&#8217;s Performance</a></p><div><hr></div><h3>&#128680; Why this matters</h3><p>Task queues are a foundational pattern in modern backend systems, especially microservice-based architectures. Whether you're managing job processors, background workers, or retry mechanisms, efficient concurrency is always a challenge.</p><p>The problem?<br>Using na&#239;ve locking mechanisms often leads to:</p><ul><li><p><strong>Deadlocks</strong></p></li><li><p><strong>Idle workers</strong></p></li><li><p><strong>Throughput bottlenecks</strong></p></li></ul><p>That&#8217;s where <code>SKIP LOCKED</code> comes in.</p><div><hr></div><h3>&#129504; What you&#8217;ll learn from the blog:</h3><p>&#9989; The real-world problem of multiple consumers polling from the same task queue.<br>&#9989; How PostgreSQL&#8217;s default row locking (<code>SELECT ... FOR UPDATE</code>) can cause contention.<br>&#9989; The magic of <code>FOR UPDATE SKIP LOCKED</code> &#8212; and how it <strong>avoids blocking</strong> by skipping locked rows.<br>&#9989; Step-by-step examples and SQL queries to implement this in your system.<br>&#9989; Benchmarks and performance observations from production-inspired scenarios.</p><div><hr></div><h3>&#9881;&#65039; Practical Use Cases</h3><p>If you're building or maintaining any of the following, this post is for you:</p><ul><li><p>Background job systems (e.g., Sidekiq, Celery, Resque clones)</p></li><li><p>Microservice worker queues</p></li><li><p>Cron-based batch processing pipelines</p></li><li><p>Distributed task schedulers</p></li><li><p>Systems with retry/failure queues</p></li></ul><div><hr></div><h3>&#129514; Bonus: Performance Wins</h3><p>This isn&#8217;t just theory. I show how using <code>SKIP LOCKED</code> allows multiple workers to <strong>safely and concurrently process jobs</strong> without stepping on each other, improving throughput and reducing lock wait times.</p><p>You&#8217;ll walk away with:</p><ul><li><p>A better understanding of PostgreSQL internals</p></li><li><p>Real code you can adapt for production</p></li><li><p>A strategy to eliminate bottlenecks in your queue-based systems</p></li></ul><div><hr></div><h3>&#128279; Read It Now</h3><p>&#128214; <a href="https://medium.com/@gautam-shubham/master-concurrent-queues-with-skip-locked-boost-your-systems-performance-46de4bfb0511">Master Concurrent Queues with SKIP LOCKED &#8211; Boost Your System&#8217;s Performance</a></p><div><hr></div><p>&#128172; I'd love to hear your thoughts, feedback, or how you've handled concurrency in your systems. Feel free to reply or leave a comment.</p><p>Stay tuned&#8212;I&#8217;ll soon share more deep dives into scaling, observability, and system design based on my real-world backend engineering experiences.</p><p>Until next time &#128075;<br><strong>&#8211;  Shubham Gautam</strong></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://gautamshubham.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Better Engineering! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item></channel></rss>