<?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[Hitesh Writes]]></title><description><![CDATA[Software developer with a habit of abstracting difficult problem into simple solution and forgetting to give disclaimer about the details missed.]]></description><link>https://hiteshyadav.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!RO9V!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb01e1c4-369d-4aa5-bbcc-758c738590b2_640x640.png</url><title>Hitesh Writes</title><link>https://hiteshyadav.substack.com</link></image><generator>Substack</generator><lastBuildDate>Sun, 28 Jun 2026 15:01:51 GMT</lastBuildDate><atom:link href="https://hiteshyadav.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Hitesh Yadav]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[hiteshyadav@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[hiteshyadav@substack.com]]></itunes:email><itunes:name><![CDATA[Hitesh Yadav]]></itunes:name></itunes:owner><itunes:author><![CDATA[Hitesh Yadav]]></itunes:author><googleplay:owner><![CDATA[hiteshyadav@substack.com]]></googleplay:owner><googleplay:email><![CDATA[hiteshyadav@substack.com]]></googleplay:email><googleplay:author><![CDATA[Hitesh Yadav]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Big Data Processing - Basics : Part 1]]></title><description><![CDATA[A small series for understanding and optimizing Spark and other data processing engines.]]></description><link>https://hiteshyadav.substack.com/p/big-data-processing-basics-part-1</link><guid isPermaLink="false">https://hiteshyadav.substack.com/p/big-data-processing-basics-part-1</guid><dc:creator><![CDATA[Hitesh Yadav]]></dc:creator><pubDate>Wed, 23 Oct 2024 15:41:03 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!-qxe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Over the course of last few years, I&#8217;ve had the opportunity to work on optimizing multiple batch jobs across multiple platforms and projects. This series shares a mental model that should come in handy for understanding, writting and optimizing batch jobs.</p><h2>Abstracting the basics</h2><p><em>The series over generalizes and significantly undermines complexity of the actual implementation of the underlying systems. And is expected to just point out the more commonly seen issues in typical implementation.</em></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://hiteshyadav.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 Hitesh Writes! 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>It helps to understand what goes under the hood in batch systems before we jump to optimize them. The most common ones you&#8217;ll see would be</p><ol><li><p>Coordinator and Workers</p></li><li><p>Tasks</p></li><li><p>Shuffling</p></li><li><p>Processing</p></li><li><p>Reading and Writing</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_!-qxe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-qxe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.png 424w, https://substackcdn.com/image/fetch/$s_!-qxe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.png 848w, https://substackcdn.com/image/fetch/$s_!-qxe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.png 1272w, https://substackcdn.com/image/fetch/$s_!-qxe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-qxe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.png" width="1042" height="580" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:580,&quot;width&quot;:1042,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:64554,&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_!-qxe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.png 424w, https://substackcdn.com/image/fetch/$s_!-qxe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.png 848w, https://substackcdn.com/image/fetch/$s_!-qxe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.png 1272w, https://substackcdn.com/image/fetch/$s_!-qxe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7bd806b3-9d5e-44a9-b0c4-b950484b1f8e_1042x580.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>The above diagram tries to put a picture to some of the components we will be discussing. </p><h3>Coordinator and Worker</h3><p>Almost all jobs have a coordinator  ( aka manager, driver, <s>master</s>, etc) and worker nodes. </p><p>The responsibility of <strong>coordinator</strong> is as the name suggests:</p><ol><li><p>Pick up what needs to be executed.</p></li><li><p>Create a plan that divides the huge job into stages, creating subtasks to be executed for each of these stages.</p></li><li><p>Manage stage completion and task progress check-pointing.</p></li></ol><p>The responsibility of <strong>workers</strong> is :</p><ol><li><p>Pick up a task from the coordinator.</p></li><li><p>Execute the task.</p></li><li><p>Return the result / or commit it to a temp storage.</p></li></ol><h3>Tasks</h3><p>Most batch systems 100s of GBs, TBs of data if not PBs. At this scale, we have already left the realm of individual machines and entered the realm of &#8220;horizontally scaling&#8221;. A huge task of processing 100s of TBs worth of data into partitioned files. These partitions are then used to fetch the results of a query that can be divided into 100K or more smaller tasks. A typical task would only process a partition or part of partition and return the result. It would help if we look at a task as a simple metadata that looks like</p><pre><code><code>task {
  task_id,
  query,
  read {
    partition: a
    from: x
    to: y 
  }
}</code></code></pre><p>So when a worker receives a task it just processes a part of the request for the query provided and returns its result back to the coordinator. </p><h3>Shuffling</h3><p>Ok! I lied about the part where a task only reads from x to y. Depending on what the query is requesting the task might not have the complete data required to provide the results. For instance, a query to write all the values related to a key onto disk in a single file cannot be completed without reading all the petabytes of data.</p><p>So how do we solve the problem when a query that cannot be served by just processing parts of the problem? In such cases, the coordinator requests workers to rearrange the data aka <strong>shuffle </strong>the data by key. This results in data being written in chunks that facilitate creation of continuous tasks (as mentioned before). </p><h3>Processing</h3><p>When a worker receives a task it performs some set of operations requested by coordinator. A task only performs a subset of work so you will see workers see pick up multiple tasks at the same time and doing what is needed a part of these tasks. </p><p>It is always very important to understand what processing is happening as part of the task to debug / speed your job execution as we will see in some later posts of this series.</p><h3>Reading and Writing</h3><p>It is important to mention at this stage that almost all of these batch processing systems heavily rely on Distributed File Systems(DFS) ( such as HDFS, GFS, and S3) properties to store and process temporary states.</p><p>The fault tolerance and scalability of DFS significantly improves the performance at a per task level. The read and write performance is also significantly improved based on the choice of data file format you choose to store and read data from. Text files are much slower than column-oriented data formats such as parquet and Arrow. </p><h2>What&#8217;s next? </h2><p>In the follow up posts, I will share some of the key bottlenecks with which we were able to improve job performance and reduce infrastructure costs by as much as 50% in some cases. Additionally, new levels of complexity and details will surface as we start digging deeper into problems and their solutions.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://hiteshyadav.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 Hitesh Writes! 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[Hack my way for best spot in cafes]]></title><description><![CDATA[Using IOT to know if I will get my favorite spot in cafe]]></description><link>https://hiteshyadav.substack.com/p/hack-my-way-for-best-spot-in-cafes</link><guid isPermaLink="false">https://hiteshyadav.substack.com/p/hack-my-way-for-best-spot-in-cafes</guid><dc:creator><![CDATA[Hitesh Yadav]]></dc:creator><pubDate>Thu, 01 Feb 2024 08:59:37 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>While the notion of the <strong>best table</strong> in a cafe is open to debate, it&#8217;s likely that if you frequent specific places near your office or home, you have a <strong>preferred table</strong>. I&#8217;m someone who has a &#8220;spot&#8221; or table that I personally prefer. I can pretty much always be found in one of my preferred cafe at one of my preferred table. This post isn&#8217;t about coffee or my table it&#8217;s rather about how I ensure that I always know what&#8217;s the status of my table at different cafes.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!x3Kh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb34010a3-83d0-4b2f-8b49-1cf7b1b970fa_225x225.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!x3Kh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb34010a3-83d0-4b2f-8b49-1cf7b1b970fa_225x225.png 424w, https://substackcdn.com/image/fetch/$s_!x3Kh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb34010a3-83d0-4b2f-8b49-1cf7b1b970fa_225x225.png 848w, https://substackcdn.com/image/fetch/$s_!x3Kh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb34010a3-83d0-4b2f-8b49-1cf7b1b970fa_225x225.png 1272w, https://substackcdn.com/image/fetch/$s_!x3Kh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb34010a3-83d0-4b2f-8b49-1cf7b1b970fa_225x225.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!x3Kh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb34010a3-83d0-4b2f-8b49-1cf7b1b970fa_225x225.png" width="225" height="225" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b34010a3-83d0-4b2f-8b49-1cf7b1b970fa_225x225.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:225,&quot;width&quot;:225,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;My Spot Stickers for Sale | Redbubble&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="My Spot Stickers for Sale | Redbubble" title="My Spot Stickers for Sale | Redbubble" srcset="https://substackcdn.com/image/fetch/$s_!x3Kh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb34010a3-83d0-4b2f-8b49-1cf7b1b970fa_225x225.png 424w, https://substackcdn.com/image/fetch/$s_!x3Kh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb34010a3-83d0-4b2f-8b49-1cf7b1b970fa_225x225.png 848w, https://substackcdn.com/image/fetch/$s_!x3Kh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb34010a3-83d0-4b2f-8b49-1cf7b1b970fa_225x225.png 1272w, https://substackcdn.com/image/fetch/$s_!x3Kh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb34010a3-83d0-4b2f-8b49-1cf7b1b970fa_225x225.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p>Some time back I found myself reaching the cafe and my table being occupied. The reader should know at this point that I&#8217;m turning into one of those old man who gets massively disappointed over small changes like not getting their fav table. So, I decided to take the matters into my own hand and over engineered a solution for my problem.</p><h2>Problem Statement</h2><p>We want to identify the crowd in an around a particular place with minimal cost involved. No calling and confirming from cafes is not an option (we want over-engineered solution pay attention please). We will measure our solution on 3 parameters:</p><ol><li><p>Cost.</p></li><li><p>Near real-time metrics.</p></li><li><p>Coolness.</p></li></ol><h2>Solution</h2><p>My first thoughts were to just access to the camera&#8217;s setup but that would require creating some unethical backdoor. I have been fiddling around with these cheap ESP32 processors costs around Rs 500 or so. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bFzU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c974c6-ded4-446b-9de1-7c49df3b16b3_1026x1027.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bFzU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c974c6-ded4-446b-9de1-7c49df3b16b3_1026x1027.jpeg 424w, https://substackcdn.com/image/fetch/$s_!bFzU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c974c6-ded4-446b-9de1-7c49df3b16b3_1026x1027.jpeg 848w, https://substackcdn.com/image/fetch/$s_!bFzU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c974c6-ded4-446b-9de1-7c49df3b16b3_1026x1027.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!bFzU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c974c6-ded4-446b-9de1-7c49df3b16b3_1026x1027.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bFzU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c974c6-ded4-446b-9de1-7c49df3b16b3_1026x1027.jpeg" width="384" height="384.37426900584796" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72c974c6-ded4-446b-9de1-7c49df3b16b3_1026x1027.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1027,&quot;width&quot;:1026,&quot;resizeWidth&quot;:384,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Amazon.in: Buy DOIT DEVIT V1 ESP32-WROOM-32 Development Board ESP32 ESP-32S  WiFi Bluetooth Dev Module CP2102 for Arduino Online at Low Prices in India  | DIYmall Reviews &amp; Ratings&quot;,&quot;title&quot;:&quot;Amazon.in: Buy DOIT DEVIT V1 ESP32-WROOM-32 Development Board ESP32 ESP-32S  WiFi Bluetooth Dev Module CP2102 for Arduino Online at Low Prices in India  | DIYmall Reviews &amp; Ratings&quot;,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Amazon.in: Buy DOIT DEVIT V1 ESP32-WROOM-32 Development Board ESP32 ESP-32S  WiFi Bluetooth Dev Module CP2102 for Arduino Online at Low Prices in India  | DIYmall Reviews &amp; Ratings" title="Amazon.in: Buy DOIT DEVIT V1 ESP32-WROOM-32 Development Board ESP32 ESP-32S  WiFi Bluetooth Dev Module CP2102 for Arduino Online at Low Prices in India  | DIYmall Reviews &amp; Ratings" srcset="https://substackcdn.com/image/fetch/$s_!bFzU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c974c6-ded4-446b-9de1-7c49df3b16b3_1026x1027.jpeg 424w, https://substackcdn.com/image/fetch/$s_!bFzU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c974c6-ded4-446b-9de1-7c49df3b16b3_1026x1027.jpeg 848w, https://substackcdn.com/image/fetch/$s_!bFzU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c974c6-ded4-446b-9de1-7c49df3b16b3_1026x1027.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!bFzU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c974c6-ded4-446b-9de1-7c49df3b16b3_1026x1027.jpeg 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>These bad bois have a dual core processor, wifi, bluetooth and what not. So, I decided to use them along with a simple rechargeable battery from nearest Ikea. </p><h3>How do I use them?</h3><p>So typically all phones and a ton of other devices use bluetooth and Bluetooth Low Energy (BLE) for all sort of cool stuff. If you haven&#8217;t you must read about the <a href="https://mfi.apple.com/en/home">Apple&#8217;s FindMy</a> network. What I have done is I&#8217;ve written bunch of <a href="https://micropython.org/">micropython</a> scripts that scan the area for devices and send an update to my server at home.</p><p>The server at home just simply run a FastAPI server and captures the number of devices in and around the device. Each device has it&#8217;s own identification which tells me which cafe is seeing how many people around my table. My precious table:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!i3lv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!i3lv!,w_424,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif 424w, https://substackcdn.com/image/fetch/$s_!i3lv!,w_848,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif 848w, https://substackcdn.com/image/fetch/$s_!i3lv!,w_1272,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif 1272w, https://substackcdn.com/image/fetch/$s_!i3lv!,w_1456,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!i3lv!,w_1456,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif" width="480" height="320" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:320,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;My precious : r/BabyYoda&quot;,&quot;title&quot;:&quot;My precious : r/BabyYoda&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="My precious : r/BabyYoda" title="My precious : r/BabyYoda" srcset="https://substackcdn.com/image/fetch/$s_!i3lv!,w_424,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif 424w, https://substackcdn.com/image/fetch/$s_!i3lv!,w_848,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif 848w, https://substackcdn.com/image/fetch/$s_!i3lv!,w_1272,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif 1272w, https://substackcdn.com/image/fetch/$s_!i3lv!,w_1456,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef35866-8a8c-40e8-9a8b-88960910298d_480x320.gif 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>So when I need to go out for a coffee I just query the API and it tells me which cafe table has minimal people around my table and I get to that one. </p><h3>Corner cases</h3><p>Since these devices are quite exposed I need to do some extra leg effort for solving bunch of things:</p><ol><li><p>Battery consumption: I&#8217;m lazy I don&#8217;t want to change the battery's every so often so the device goes into deep sleep when it has pushed the data and sleeps for 5 mins. The device goes into deep sleep at night times (uses time sync from another API).</p></li><li><p>Home server safety: My server is DDoS protected and has TLS to avoid anyone figuring out how they can mess up with my system.</p></li><li><p>Internet: I&#8217;m heavily at the mercy of the cafes&#8217; wifi I&#8217;m currently in the process of working out a solution that does not need the cafes&#8217; wifi but that is experimental at best.</p></li><li><p>Losses: So far I&#8217;ve not lost or gotten my device stolen. But even if it does get stolen it&#8217;s a cheap device.</p></li></ol><p></p><h3>What&#8217;s next?</h3><p>I&#8217;m thinking of extending the solution to some more interesting use-cases. I&#8217;d be happy to hear folks thought on what sort of over-engineered solutions you are working on. </p>]]></content:encoded></item><item><title><![CDATA[When application code is not available and logs lie!]]></title><description><![CDATA[Debugging issues in an proprietary software with unreliable application logs.]]></description><link>https://hiteshyadav.substack.com/p/when-application-code-is-not-available</link><guid isPermaLink="false">https://hiteshyadav.substack.com/p/when-application-code-is-not-available</guid><dc:creator><![CDATA[Hitesh Yadav]]></dc:creator><pubDate>Tue, 23 Jan 2024 13:24:41 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/8e84696d-6de7-4cac-81ae-cde75ee0412f_600x262.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1>Preface</h1><p>&#8220;Proprietary&#8221; ( sounds like - pruh&#183;prai&#183;uh&#183;tree) is a tough to spell word with an interesting pronunciation. Skipping the tedious explanation of how I&#8217;ll inevitably flunk the dictation despite my repeated attempts let&#8217;s get straight to the issue at hand. We find ourselves in an interesting setup for this one:</p><ol><li><p>We have a client claiming very high latency from our service.</p></li><li><p>We have a backend service claiming very low latency.</p></li></ol><p>needless to say the initial few calls with the client went 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_!zlGx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f1af765-e509-4792-88c3-fb2a05d9e567_434x244.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zlGx!,w_424,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f1af765-e509-4792-88c3-fb2a05d9e567_434x244.gif 424w, https://substackcdn.com/image/fetch/$s_!zlGx!,w_848,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f1af765-e509-4792-88c3-fb2a05d9e567_434x244.gif 848w, https://substackcdn.com/image/fetch/$s_!zlGx!,w_1272,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f1af765-e509-4792-88c3-fb2a05d9e567_434x244.gif 1272w, https://substackcdn.com/image/fetch/$s_!zlGx!,w_1456,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f1af765-e509-4792-88c3-fb2a05d9e567_434x244.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zlGx!,w_1456,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f1af765-e509-4792-88c3-fb2a05d9e567_434x244.gif" width="434" height="244" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5f1af765-e509-4792-88c3-fb2a05d9e567_434x244.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:244,&quot;width&quot;:434,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;i dont care thats not my problem GIF&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="i dont care thats not my problem GIF" title="i dont care thats not my problem GIF" srcset="https://substackcdn.com/image/fetch/$s_!zlGx!,w_424,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f1af765-e509-4792-88c3-fb2a05d9e567_434x244.gif 424w, https://substackcdn.com/image/fetch/$s_!zlGx!,w_848,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f1af765-e509-4792-88c3-fb2a05d9e567_434x244.gif 848w, https://substackcdn.com/image/fetch/$s_!zlGx!,w_1272,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f1af765-e509-4792-88c3-fb2a05d9e567_434x244.gif 1272w, https://substackcdn.com/image/fetch/$s_!zlGx!,w_1456,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f1af765-e509-4792-88c3-fb2a05d9e567_434x244.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="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>because we thought it was their network and they thought it was ours.</p><p>So, we ran a bunch of tests find some minor configuration issues on the application end and okayed the system to be used by the client. And to our surprise the client kept seeing the same issue. At this point, I&#8217;m more curious than frustrated as to what is happening, since there has been no improvement whatsoever.</p><h1>Problem</h1><p>Upon picking up high latency request we traced it across the logs in our system and this is what we saw from it:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!657x!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64021fa-e1ae-4982-9602-3627c0e90b0f_1275x250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!657x!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64021fa-e1ae-4982-9602-3627c0e90b0f_1275x250.png 424w, https://substackcdn.com/image/fetch/$s_!657x!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64021fa-e1ae-4982-9602-3627c0e90b0f_1275x250.png 848w, https://substackcdn.com/image/fetch/$s_!657x!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64021fa-e1ae-4982-9602-3627c0e90b0f_1275x250.png 1272w, https://substackcdn.com/image/fetch/$s_!657x!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64021fa-e1ae-4982-9602-3627c0e90b0f_1275x250.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!657x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64021fa-e1ae-4982-9602-3627c0e90b0f_1275x250.png" width="1275" height="250" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c64021fa-e1ae-4982-9602-3627c0e90b0f_1275x250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:250,&quot;width&quot;:1275,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:28798,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!657x!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64021fa-e1ae-4982-9602-3627c0e90b0f_1275x250.png 424w, https://substackcdn.com/image/fetch/$s_!657x!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64021fa-e1ae-4982-9602-3627c0e90b0f_1275x250.png 848w, https://substackcdn.com/image/fetch/$s_!657x!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64021fa-e1ae-4982-9602-3627c0e90b0f_1275x250.png 1272w, https://substackcdn.com/image/fetch/$s_!657x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64021fa-e1ae-4982-9602-3627c0e90b0f_1275x250.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>So when we looked at the gateway logs (the proprietary software) we can clearly see the request reached the gateway with a 2 second delay and like all other developers we agreed it was an network issue. Because why not? I can see I did not see the request on my system before that point (nice word play huh ! ). Anyway after doing tons of optimization we saw no improvements. So we sat with a laptop next to the server plugged it in and ran the tests and we still see 2 - 3 SECOND latency. This tells us :</p><ol><li><p>Network is not the problem.</p></li><li><p>Either I have a bad machine.</p></li><li><p>Or my logs are not reliable.</p></li></ol><p>We ruled out point 2 because we tested on multiple machines and the probability of us getting that lucky to have all the bad servers is quite low (knowing my luck we cannot however completely rule that out :D). And now the meaty problem for this post. How does one debug an application who&#8217;s code you don&#8217;t own and whose logs are not reliable? </p><p>We reached out to the proprietary software support and after multiple discussion they refused to acknowledge that this is a problem in the software. We are now stuck and we still need to find the issue. </p><h1>Debugging without code and logs</h1><p>So we are at a point where the application owners are not able to come up with any suggestions on what might be causing this. I decided to now deep dive on the issue. While I don&#8217;t have access to the applications internal or any authoritative logs I do have access to server. What can we do with server access in a proprietary software? Well unless the application is designed keeping security in mind you can pretty much figure out everything the application is doing. In my case, I used 2 tools to identify what is happening:</p><ol><li><p><a href="https://man7.org/linux/man-pages/man1/strace.1.html">strace</a><br>This allowed me to see what system calls the application is making to the kernel and where is it spending time from an linux&#8217;s perspective. Strace is very useful in identifying what is happening in pretty much all applications.</p></li><li><p><a href="https://www.tcpdump.org/manpages/tcpdump.1.html">tcpdump</a><br>This allowed me to see (not completely correct my traffic was over TLS) what is happening on the connection stream.</p></li></ol><h1>How to&#8217;s</h1><p>This post is useless if I don&#8217;t give back a quick way to use both strace and tcpdump. Within the next 2 mins: </p><h2>strace</h2><p>For linux OS you can use the following command to identify all high latency requests and what they are doing in terms of time spent and data written in these calls.</p><pre><code>strace -f -s 100 -p PID 2&gt;&amp;1 | awk 'gsub(/[&lt;&gt;]/,"",$NF); if($NF+0 &gt; 0.8) print $0 " " $NF}'</code></pre><p>What does it do: </p><pre><code>-p &#8594; uses the parent process id.
-f &#8594; tracks all the child process for PID
-s &#8594; decides what size of data to be read in the call params.
2&gt;&amp;1 &#8594; redirects stderror to stdout for linux (default output of strace is stderr)

awk &#8594; parses the output of strace to only show syscalls where 0.8 secs or more was spent.</code></pre><p>On seeing the results of this command we were able to see a lot of time being spent on calls to a SQL DB.</p><h2>tcpdump</h2><p>For seeing what&#8217;s happening in your system on a per connection basis you can use :</p><pre><code>tcpdump -i INTERFACE -w -s 0 -w output.pcap</code></pre><p>What does it do:</p><pre><code>It captures all the traffic on INTERFACE and writes it to output.pcap</code></pre><p>You&#8217;ll need Wireshark to see or use the generated PCAP file. In my case, it clearly showed a bunch of DB calls to the MySQL server. These DB calls when they saw high latency were creating a back-pressure and causing all calls to have a higher latency (my guess is the proprietary code has some synchronized block blocking all threads but that is for another day or blog post).</p><p>I highly recommend the short read on using by Julia Evans : <a href="https://jvns.ca/blog/2018/06/19/what-i-use-wireshark-for/">How I use Wireshark</a> by now you have any ways invested 5 mins in learning why not invest another 5mins and have some more depth into the tool.</p><h1>Closing thoughts</h1><p>Since we didn&#8217;t own the Gateway code there was only so much we could do. The application team acknowledged the issue and decided to provide a patch for the same. I think the big takeaway was how much speed the two tools provided in deep diving on the issue even when application team denied any issues. My recommendation would be to definitely give them a shot.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Oj2Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 424w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 848w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 1272w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif" width="498" height="298" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:298,&quot;width&quot;:498,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1495839,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;: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_!Oj2Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 424w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 848w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 1272w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://hiteshyadav.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 Hitesh Writes! 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[The 100x slow bug; 10 line fix]]></title><description><![CDATA[The story of how we caused our system to be slower by 100x and how we didn't catch it for 4 years.]]></description><link>https://hiteshyadav.substack.com/p/the-100x-slow-bug-10-line-fix</link><guid isPermaLink="false">https://hiteshyadav.substack.com/p/the-100x-slow-bug-10-line-fix</guid><dc:creator><![CDATA[Hitesh Yadav]]></dc:creator><pubDate>Wed, 07 Jun 2023 14:37:39 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!ko1b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Background</h2><p>The story of our system starts some years back when we were writing a service to process invoices and run some validations on them. At the time of writing the service, invoices were fairly small. To process an invoice, the workflow was fairly simple:</p><ol><li><p>Download the invoice header.</p></li><li><p>Get all transactions of an invoice (line items).</p></li><li><p>Aggregate and match the total amounts.</p></li></ol><p>For this, we would make a call to a different service that would return the transactions and their details.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://hiteshyadav.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 Hitesh&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ko1b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ko1b!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.png 424w, https://substackcdn.com/image/fetch/$s_!ko1b!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.png 848w, https://substackcdn.com/image/fetch/$s_!ko1b!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.png 1272w, https://substackcdn.com/image/fetch/$s_!ko1b!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ko1b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.png" width="512" height="512" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:512,&quot;width&quot;:512,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:141690,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ko1b!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.png 424w, https://substackcdn.com/image/fetch/$s_!ko1b!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.png 848w, https://substackcdn.com/image/fetch/$s_!ko1b!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.png 1272w, https://substackcdn.com/image/fetch/$s_!ko1b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F767071dd-63f4-423b-bb54-9f741c2c9e93_512x512.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><h2>The crippling slowness</h2><p>Over the years, we started seeing bigger invoices coming into our system. Soon, invoices would have millions of line items. Naturally, this slowed down the speed at which invoices were being processed. So, it was ignored as a side-effect of larger invoices coming in for validation.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PUg6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb784f90a-188e-4118-9c2d-3dd4d3b0ddea_640x640.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PUg6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb784f90a-188e-4118-9c2d-3dd4d3b0ddea_640x640.gif 424w, https://substackcdn.com/image/fetch/$s_!PUg6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb784f90a-188e-4118-9c2d-3dd4d3b0ddea_640x640.gif 848w, https://substackcdn.com/image/fetch/$s_!PUg6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb784f90a-188e-4118-9c2d-3dd4d3b0ddea_640x640.gif 1272w, https://substackcdn.com/image/fetch/$s_!PUg6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb784f90a-188e-4118-9c2d-3dd4d3b0ddea_640x640.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PUg6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb784f90a-188e-4118-9c2d-3dd4d3b0ddea_640x640.gif" width="392" height="392" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b784f90a-188e-4118-9c2d-3dd4d3b0ddea_640x640.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:640,&quot;width&quot;:640,&quot;resizeWidth&quot;:392,&quot;bytes&quot;:799897,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PUg6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb784f90a-188e-4118-9c2d-3dd4d3b0ddea_640x640.gif 424w, https://substackcdn.com/image/fetch/$s_!PUg6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb784f90a-188e-4118-9c2d-3dd4d3b0ddea_640x640.gif 848w, https://substackcdn.com/image/fetch/$s_!PUg6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb784f90a-188e-4118-9c2d-3dd4d3b0ddea_640x640.gif 1272w, https://substackcdn.com/image/fetch/$s_!PUg6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb784f90a-188e-4118-9c2d-3dd4d3b0ddea_640x640.gif 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="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>Soon, the problem grew bigger. It now took around 6-12-24 hours for invoices to process. Since the problem grew slowly, it did not cause an alarm. Rather, it got accepted as a norm. And now, we had teams building system architecture and solutions to account for the long-running validations.</p><h2>Identification</h2><p>As part of one of our resource utilization reviews, it was identified that the particular validation service was neither compute-intensive nor memory-heavy. When asked to justify this, the team said that they process huge invoices (1Gb to 10Gb) and write them to disk, which is slow. This is why they need more hosts to scale their systems to process more invoices.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YP49!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F343430fb-2feb-4ae7-8366-c1f755ecb341_380x291.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YP49!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F343430fb-2feb-4ae7-8366-c1f755ecb341_380x291.gif 424w, https://substackcdn.com/image/fetch/$s_!YP49!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F343430fb-2feb-4ae7-8366-c1f755ecb341_380x291.gif 848w, https://substackcdn.com/image/fetch/$s_!YP49!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F343430fb-2feb-4ae7-8366-c1f755ecb341_380x291.gif 1272w, https://substackcdn.com/image/fetch/$s_!YP49!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F343430fb-2feb-4ae7-8366-c1f755ecb341_380x291.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YP49!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F343430fb-2feb-4ae7-8366-c1f755ecb341_380x291.gif" width="380" height="291" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/343430fb-2feb-4ae7-8366-c1f755ecb341_380x291.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:291,&quot;width&quot;:380,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1693686,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YP49!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F343430fb-2feb-4ae7-8366-c1f755ecb341_380x291.gif 424w, https://substackcdn.com/image/fetch/$s_!YP49!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F343430fb-2feb-4ae7-8366-c1f755ecb341_380x291.gif 848w, https://substackcdn.com/image/fetch/$s_!YP49!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F343430fb-2feb-4ae7-8366-c1f755ecb341_380x291.gif 1272w, https://substackcdn.com/image/fetch/$s_!YP49!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F343430fb-2feb-4ae7-8366-c1f755ecb341_380x291.gif 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>A large invoice can be 1 gigabyte to 10 gigabytes in file size. This should have been the first hint for the team to go back to the drawing board and find the real issue. Modern disks do not take a day to write to in 202x. This was somehow overlooked and accepted as a reason for the slowness of the service by the team. During the review, however, this did not fly because of the 202x (2020-2030s because the future looks dark) logic.</p><h2>The blunder</h2><p>Yeah, so for years, we accepted the slowness of the system and changed the architecture around the slow validation process. However, during one review, we were unable to identify a single resource that was causing the host to be slow. So, we took a deep dive into the code. And lo and behold, we identified a bug in our code. I'm sharing the pseudo-code below so that readers can identify the issue in the code. </p><pre><code>class TransactionLogger {
    // Client to call external service for getting transaction details 
    private TransactionAuthorityService tasSAO;
    
    public List&lt;Transaction&gt; getTransactions(List&lt;String&gt; transactionIds) {
        List&lt;Transaction&gt; transactionDetails = new DiskList();
        for(String transactionId : transactionIds) {
           transactions.append(tasSAO.getTransactionDetails(transactionId);
        }
        return transactionDetails;
    }

}</code></pre><p>Now, at first sight, there is nothing wrong with this code. We are doing what we are expected to do: get transactions and store them to disk.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!W1GK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032c24a-85d3-471e-aefb-b4264ab7a85e_310x240.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!W1GK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032c24a-85d3-471e-aefb-b4264ab7a85e_310x240.gif 424w, https://substackcdn.com/image/fetch/$s_!W1GK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032c24a-85d3-471e-aefb-b4264ab7a85e_310x240.gif 848w, https://substackcdn.com/image/fetch/$s_!W1GK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032c24a-85d3-471e-aefb-b4264ab7a85e_310x240.gif 1272w, https://substackcdn.com/image/fetch/$s_!W1GK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032c24a-85d3-471e-aefb-b4264ab7a85e_310x240.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!W1GK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032c24a-85d3-471e-aefb-b4264ab7a85e_310x240.gif" width="320" height="247.74193548387098" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c032c24a-85d3-471e-aefb-b4264ab7a85e_310x240.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:240,&quot;width&quot;:310,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:855849,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!W1GK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032c24a-85d3-471e-aefb-b4264ab7a85e_310x240.gif 424w, https://substackcdn.com/image/fetch/$s_!W1GK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032c24a-85d3-471e-aefb-b4264ab7a85e_310x240.gif 848w, https://substackcdn.com/image/fetch/$s_!W1GK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032c24a-85d3-471e-aefb-b4264ab7a85e_310x240.gif 1272w, https://substackcdn.com/image/fetch/$s_!W1GK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032c24a-85d3-471e-aefb-b4264ab7a85e_310x240.gif 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><p>The issue is that this code is sequential. The disk is not the bottleneck; it is the damn RPC call, which waits for every call to return before making the next one.</p><h2>The 10 line fix to 5 year old architectural problem</h2><p>The fix for the problem is rather simple. We add parallel calls to fetch the data from dependency service. </p><pre><code>class TransactionLogger {
    // Client to call external service for getting transaction details 
    private TransactionAuthorityService tasSAO;
    private ExecutorService executorService;
    
    public List&lt;Transaction&gt; getTransactions(List&lt;String&gt; transactionIds) {
                List&lt;Transaction&gt; transactionDetails = new DiskList&lt;&gt;();
        
        // Create transactions in parallel
        List&lt;Future&lt;Transaction&gt;&gt; transactionFutures = new ArrayList&lt;&gt;();
        for(String transactionId : transactionIds) {
            List&lt;Transaction&gt; future = executorService.submit(() -&gt;   tasSAO.getTransactionDetails(transactionId));
            transactionFutures.add(future);
        }

        // Fetch all transactions
        for(Future&lt;Transaction&gt; future: transactionFutures) {
            transactionDetails.add(future.get());
        }
        return transactionDetails;
    }

}</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_!yiQK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6972532b-12e7-4da4-9138-354a6253213e_450x253.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yiQK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6972532b-12e7-4da4-9138-354a6253213e_450x253.gif 424w, https://substackcdn.com/image/fetch/$s_!yiQK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6972532b-12e7-4da4-9138-354a6253213e_450x253.gif 848w, https://substackcdn.com/image/fetch/$s_!yiQK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6972532b-12e7-4da4-9138-354a6253213e_450x253.gif 1272w, https://substackcdn.com/image/fetch/$s_!yiQK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6972532b-12e7-4da4-9138-354a6253213e_450x253.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yiQK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6972532b-12e7-4da4-9138-354a6253213e_450x253.gif" width="450" height="253" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6972532b-12e7-4da4-9138-354a6253213e_450x253.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:253,&quot;width&quot;:450,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:768365,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!yiQK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6972532b-12e7-4da4-9138-354a6253213e_450x253.gif 424w, https://substackcdn.com/image/fetch/$s_!yiQK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6972532b-12e7-4da4-9138-354a6253213e_450x253.gif 848w, https://substackcdn.com/image/fetch/$s_!yiQK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6972532b-12e7-4da4-9138-354a6253213e_450x253.gif 1272w, https://substackcdn.com/image/fetch/$s_!yiQK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6972532b-12e7-4da4-9138-354a6253213e_450x253.gif 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p><strong>Disclaimer</strong>: The above code is not production-ready. You need to: </p><ol><li><p>Add batching to control the size of running futures at any time. </p></li><li><p>Add rate limiters to your downstream service so you don't brown them out. </p></li><li><p>There are better ways to write this code, but I just wanted to keep it simple for the readers.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xYOZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3ff8bc-78af-49a1-b0d1-a1aaf1e17b63_568x640.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xYOZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3ff8bc-78af-49a1-b0d1-a1aaf1e17b63_568x640.gif 424w, https://substackcdn.com/image/fetch/$s_!xYOZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3ff8bc-78af-49a1-b0d1-a1aaf1e17b63_568x640.gif 848w, https://substackcdn.com/image/fetch/$s_!xYOZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3ff8bc-78af-49a1-b0d1-a1aaf1e17b63_568x640.gif 1272w, https://substackcdn.com/image/fetch/$s_!xYOZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3ff8bc-78af-49a1-b0d1-a1aaf1e17b63_568x640.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xYOZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3ff8bc-78af-49a1-b0d1-a1aaf1e17b63_568x640.gif" width="396" height="446.19718309859155" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1c3ff8bc-78af-49a1-b0d1-a1aaf1e17b63_568x640.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:640,&quot;width&quot;:568,&quot;resizeWidth&quot;:396,&quot;bytes&quot;:1182692,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xYOZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3ff8bc-78af-49a1-b0d1-a1aaf1e17b63_568x640.gif 424w, https://substackcdn.com/image/fetch/$s_!xYOZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3ff8bc-78af-49a1-b0d1-a1aaf1e17b63_568x640.gif 848w, https://substackcdn.com/image/fetch/$s_!xYOZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3ff8bc-78af-49a1-b0d1-a1aaf1e17b63_568x640.gif 1272w, https://substackcdn.com/image/fetch/$s_!xYOZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3ff8bc-78af-49a1-b0d1-a1aaf1e17b63_568x640.gif 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p></li></ol><p></p><h2>The takeaway</h2><p>As developers, we need to know the breaking point of our services and what resources we are constrained on before we resort to horizontal scaling for every problem.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Oj2Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 424w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 848w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 1272w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif" width="498" height="298" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:298,&quot;width&quot;:498,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1495839,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 424w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 848w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 1272w, https://substackcdn.com/image/fetch/$s_!Oj2Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff55b7f85-1005-4566-abed-df0a3e78a208_498x298.gif 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://hiteshyadav.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 Hitesh&#8217;s Substack! 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>