<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Udbhav on Medium]]></title>
        <description><![CDATA[Stories by Udbhav on Medium]]></description>
        <link>https://medium.com/@ngudbhav?source=rss-2b548778803b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-kKyPq3myyfJdOrouTm0AQ.jpeg</url>
            <title>Stories by Udbhav on Medium</title>
            <link>https://medium.com/@ngudbhav?source=rss-2b548778803b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 16:29:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ngudbhav/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Graceful Shutdown — What, Why, When and How?]]></title>
            <link>https://ngudbhav.medium.com/graceful-shutdown-what-why-when-and-how-3549a4eb4670?source=rss-2b548778803b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3549a4eb4670</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Udbhav]]></dc:creator>
            <pubDate>Tue, 14 Jan 2025 09:09:25 GMT</pubDate>
            <atom:updated>2025-01-14T09:41:38.263Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3qICuBmAO0e6muBvY6EsIw.png" /><figcaption>Sidekiq Processor Graceful Shutdown</figcaption></figure><p>Imagine you have just patched a bug or developed a new feature and want to deploy your new code. You have started the deployment, either on your own or under the PM’s pressure. The code begins to deploy on your target systems. We know every software requires a restart to apply and load the new code into memory.</p><p>You breathe a sigh of relief, believing nothing can go wrong. But <a href="https://en.wikipedia.org/wiki/Murphy%27s_law">Murphy</a> sir, is here to live with us. Do you think she is satisfied? NO! 😒 She is not satisfied.</p><p>Just before your software restarts, a user is in the middle of a transaction, and the server restarts! The user has already entered their PIN/Password, and the money is deducted from their account but not credited to the recipient account.</p><p>Don’t Worry 😮‍💨! We have a powerful logic at hand 🤚!</p><p><strong>Graceful Shutdown. </strong>Before the software stops, it ceases to accept new requests or commands and begins to complete the work that has already been accepted. That’s it. That’s the definition of graceful shutdown. Prior to the software shutting down, all commands that were assigned are completed, and some (but not all) temporary files are deleted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MWeLMY4Xt67FlXWktza86g.png" /></figure><p>Yay! You have the graceful shutdown in place. Before the server restarts, the money that was deducted from the user’s account is credited either to the recipient&#39;s account or back to the user’s account, depending on your legacy code that only one person of your entire team or floor knows about. Good luck with that!</p><p>When you use fairly popular software, there is a good chance that graceful shutdown is already implemented in there, and it kicks in at the correct time. But what if you are asked to create your own? What if your crazy senior engineers have identified a problem (or cost optimisation opportunity 😛) in the popular software and they want you to create an in-house version of this? Don’t worry. If you are going to read this blog till the end, you will know exactly how you have to proceed!</p><p><strong>💎Ruby</strong></p><p>Let’s create a simple program that is supposed to sleep for 5s as and when it encounters the purest number known to mankind, <strong>69</strong> and otherwise, keep listening.</p><pre>def do_69<br>  sleep 5 # 5 seconds? You guys setting world records here!<br>end<br><br>while true<br>  puts &quot;Waiting for Oh Yeah!&quot;<br>  a = gets.chomp<br>  number = a.to_i<br>  if number == 69<br>    do_69<br>  elsif number == 42 || number == 108<br>    puts `Well, that&#39;s one way to ruin the mood, isn&#39;t it?`<br>    exit 0<br>  end<br>end</pre><p>Great. The use-case here is to continue and complete the process of the <strong>69 </strong>(😍) even if CTRL/CMD + C is encountered.</p><p>Introducing TRAP! A deadly weapon available even in a bash script that is used to catch signals. CTRL/CMD + C is a kill, or a SIGINT signal sent to the process by the OS to instruct that your time to shine is over. How do you implement such thing in Ruby?</p><pre>Signal.trap(&#39;INT&#39;) do<br>  puts &#39;Shutting down gracefully&#39;<br>  do_69<br>end</pre><p>The above code instructs your program to trap the kill (<strong>INT</strong>) signal and then sleep for another 5s before shutting down the program. We are using trap to tell the program to continuing doING_69 even after it has been shot dead. Only after its completion, can the program peacefully die!</p><p>There is a bug in this code. According to the logic, in a particular scenario, do_69 may be executed twice for a total of 10s. Think and try to solve the bug while I use one more language to implement trap.</p><p><strong>C++</strong></p><pre>#include &lt;iostream&gt;<br>#include &lt;signal.h&gt;<br>using namespace std;<br><br>void do_69() {<br>  sleep(5); // Well, that was fast! You sure it wasn&#39;t a race?<br>}<br><br>int main() <br>{<br>    cout &lt;&lt; &quot;Waiting for Oh Yeah!&quot; &lt;&lt; endl;<br>    while(true) {<br>      int number;<br>      cin &gt;&gt; number;<br>      if (number == 69) {<br>        do_69();<br>      } else if (number == 42 || number == 108) {<br>        cout &lt;&lt; &quot;Looks like you&#39;ve brought some extra wisdom to the table!&quot; &lt;&lt; endl;<br>        exit(0);<br>      }<br>    }<br>    return 0;<br>}</pre><p>That’s the barebone of our program. Now let’s add some signal trap logic to the above code</p><pre>signal(SIGINT, do_69);</pre><p>Guess what. The same bug is present in this code as well.</p><p><strong>Hint</strong>?</p><p>What if instead of directly processing every input, you store the input in a data structure and then process the input in a separate thread? The optimised way would be to spawn a thread at the start and then use the thread every time you have to do_69. Maintain a busy and idle state for the thread and sleep the program in trap until the thread returns to the idle state for you to completely exit the program.</p><p>Comment below if you would like to cover the code for the above Sermon. May be something I can cover in the next blog.</p><p>Until then, go figure out the bug that caused a transaction crash for several users because the software you were using got hit with a Dependabot update. Of course, you merged, approved, and deployed it without a second thought — because PRs are always safe, right? Classic &quot;what could possibly go wrong&quot; moment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3549a4eb4670" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Meet meets Browser Extension — How Our Solution Saved $500K]]></title>
            <link>https://tech.scaler.com/google-meet-meets-browser-extension-how-our-solution-saved-500k-d5f8519890aa?source=rss-2b548778803b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5f8519890aa</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[saving-money]]></category>
            <category><![CDATA[cost]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Udbhav]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 06:09:31 GMT</pubDate>
            <atom:updated>2023-06-13T06:09:31.596Z</atom:updated>
            <content:encoded><![CDATA[<h3>Google Meet meets Browser Extension — How Our Solution Saved $500K</h3><figure><img alt="A laptop with a video call on the screen and a pile of cash flying out of it" src="https://cdn-images-1.medium.com/max/1024/1*a94UbmdetEIbWOlaUQ7smg.jpeg" /></figure><p>As an organisation’s scale increases, it is easy to get the cost of services, like infra and SaaS tools, get out of hand. A core tenet of engineering is to frequently revisit these costs, and understand how they can be optimised. Optimising operations and reducing costs 💰 are crucial for long-term success 🚀 in today’s dynamic and competitive business landscape.</p><p>We recently worked on multiple measures to reduce Scaler’s infra and software costs significantly. In this blog, we share the story of one such initiative where we implemented a solution that resulted in a staggering $500K 🤑 in savings annually.</p><h3>Online Call — A Background Story</h3><p>Our teams use a popular video meetings solution (say X) for online calls 💻 with the customers/leads. X provides us with a plethora of features that are handy not only for the team but also for the auditors!</p><p>That’s right ✅. All the calls are recorded, analysed and audited for the safety and security of the target audience. The auditors require access to the recordings and the call details. The details include meetings’ start/end time, duration, and call participants 💁.</p><h3>🤑 $500K is a huge amount! Why, on Earth, did we require this much money?</h3><p>Our team comprises about 500–700 individuals each requiring their license to use X without any hiccups. We also need good storage for all the video recordings. These recordings consist of audio, video, screen sharing and chat messages.</p><p>The license and storage add up to a total cost of $500K per year. The storage cost is only going to increase year over year and so is the license cost. This means scaling CPL (Cost Per License) cost with the scale 📈.</p><h3>What were the options?</h3><p>We had an interesting problem at hand. But how do we solve it? We had multiple solutions available to us. Can Scaler Classroom — our in-house solution to conduct classes, be used to host all the meetings? Can Google Meet serve as a viable option for us? Can the entire organisation be migrated to Microsoft Teams instead?</p><ol><li><strong>Scaler Classroom:</strong> Scaler Classroom (Meetings) could help us with all the features, we need. We had the option to force automatic recording of all the meetings. Being an in-house platform, we had as much data to fulfil our greed. The caveats, though?<br> — Everyone needs to have a Scaler account before Meetings can be accessed.<br> — Meetings is full of features needed for a holistic learning experience, and as a result, relatively costly. Do we want to add cost by moving our internal calls as well, to Meetings?</li><li><strong>Google Meet:</strong> Google Meet is a beautiful platform and stable enough for day-to-day calls 💯. We already have Google Suite accounts for the entire organisation. Recordings are good quality with an option for transcription. The biggest advantage is — Everyone has a Google account! Plus, no additional cost is required. We are practically bringing down the cost to <strong>ZERO.</strong> But this solution also comes with its own set of pain points.<br> — Automatic call recording or transcription is not allowed <strong>at all</strong>. We have to manually start a recording to store it directly in our Drive.<br> — There is no API support to determine the call’s duration. Of course, we can refer to the calendar to find out the scheduled duration but the actual duration of the meeting is not available.</li><li><strong>Microsoft Teams:</strong> The Teams is a good solution with a good UI. The calls are stable and of good quality 👏. We even have the option to automatically enable call recordings. The recordings are stored in the OneDrive account of the organiser of the meeting. We also have good API support to get the data of the meeting on our internal portals. The problems?<br> — Using Teams would require migrating the entire organisation to Microsoft Workspace. Migration alone is a difficult process. It would require configuring all the internal tools to Microsoft SSO. Not to mention the training costs and added time ultimately increasing the existing costs to an even scarier mark 🙀.<br> — If we were to only migrate the required team to Microsoft 365, we would incur an additional $15 per user, per month.</li></ol><h3>🙌 What is the Solution?</h3><p>After evaluating the pros and cons of different platforms, we decided to go with Google Meet as our primary tool for online calls. However, we still had to overcome some challenges such as automatic recording and duration tracking. To solve these issues, we began exploring solutions.</p><p>We know that recording is possible by creating a meeting bot and then recording the entire stream, much like how the Tl;dv works. This requires setting up an infrastructure. We also need to scale the infrastructure with the scale of concurrent meetings happening at the same time.</p><p>What if we could use Google’s recording architecture and infrastructure? We only need a way to automatically record the meeting since no such feature is available.</p><h3>💸 Browser Extension</h3><p>Back to the basics, we could start the recording by injecting a JS code to every meet window. One possible way to achieve this was to use a browser extension. We could target only Google Chrome and Microsoft Edge (Chromium) browsers for the MVP.</p><p>Once being able to control Google Meet, we could tweak Meet the way we want. We enabled recording whenever the meeting started (offline consent was taken from the host beforehand). We also synced the meeting start/end time from the browser to the Scaler servers.</p><p>Once a recording was completed, Google stores the meeting recording in the organiser’s drive under the “Meet Recordings” folder. We used Google APIs to access the recording and use the link to the recording to feed our database.</p><h3>Conclusion</h3><p>This is how we saved $500K annually by switching from X to Google Meet and creating our custom solution 🎉. We hope this story inspires you to think creatively and optimise your operations for long-term success.</p><p>Let us know if:</p><ol><li>You want us to open-source the solution.</li><li>You want us to deep dive into the solution with the help of a <strong>Masterclass.</strong></li><li>You want us to write another article explaining the detail of the solution including the code</li></ol><p>Follow our blog for more such stories!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5f8519890aa" width="1" height="1" alt=""><hr><p><a href="https://tech.scaler.com/google-meet-meets-browser-extension-how-our-solution-saved-500k-d5f8519890aa">Google Meet meets Browser Extension — How Our Solution Saved $500K</a> was originally published in <a href="https://tech.scaler.com/">ScalerTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>