<?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[NewrozTech - Medium]]></title>
        <description><![CDATA[Secure, Scalable Application Starts Here - Medium]]></description>
        <link>https://medium.com/newroztech?source=rss----e24389fb1346---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>NewrozTech - Medium</title>
            <link>https://medium.com/newroztech?source=rss----e24389fb1346---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 13 Nov 2026 16:49:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/newroztech" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Functions and Methods in Go]]></title>
            <link>https://medium.com/newroztech/functions-and-methods-in-go-e2bd45840e2?source=rss----e24389fb1346---4</link>
            <guid isPermaLink="false">https://medium.com/p/e2bd45840e2</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[functions-in-go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[begginer]]></category>
            <category><![CDATA[methods-in-go]]></category>
            <dc:creator><![CDATA[Sabbir Ahmed]]></dc:creator>
            <pubDate>Mon, 31 Oct 2022 09:18:13 GMT</pubDate>
            <atom:updated>2022-10-28T13:15:28.366Z</atom:updated>
            <content:encoded><![CDATA[<p>To begin with Go, we have to understand Go functions and methods. And how they differ from other languages. This article is the first of the function series.</p><figure><img alt="function and methods in go by: sabbir &lt;me@sabbir.dev&gt;" src="https://cdn-images-1.medium.com/max/1024/1*2ms0NQaM_lIXimka7hyTug.png" /><figcaption>OC: Made with Vectornator</figcaption></figure><h3>Functions vs Methods</h3><p>Single line answer would be -</p><ul><li>Functions are set of instructions</li><li>Methods are functions that are associated with objects</li></ul><p>Let’s understand what they mean! For example, we have user objects in JSON with the following parameters -</p><pre>{<br>  &quot;id&quot;: &quot;some-user-id&quot;,<br>  &quot;email&quot;: &quot;me@sabbir.dev&quot;,<br>  &quot;is_verified&quot;: false<br>}</pre><p>Now we have to determine if the user has verified his email or not by checking the value of is_verified . We can do this both via a function or a method . let’s code…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/796b4c5e20573decac0dd6b2183678ae/href">https://medium.com/media/796b4c5e20573decac0dd6b2183678ae/href</a></iframe><p>At line 32 we declared a function with an explicit parameter type User and returns bool type. The function is straight forward and will work with any struct that has a parameter named is_verified of type bool .</p><p>And at line 38 we declared a method that is associated with User type. It takes no parameter as it already have the object definition. And returns bool . In Go lingo we call it value receiver method, we also have a pointer receiver method to look at —</p><h4>Pointer Receiver vs Value Receiver</h4><p><strong><em>TL;DR:</em></strong> 99% of the time in production we will be using a pointer receiver</p><p>So, we have a grasp on value receiver methods, let’s assume we are tasked to write a method that will verify user email and set is_verified to true</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dcb8f0d1c90e2e2045df8c8339d1abe5/href">https://medium.com/media/dcb8f0d1c90e2e2045df8c8339d1abe5/href</a></iframe><p>If we run the code the output should look like below —</p><pre>Value Receiver Method:  false<br>Pointer Receiver Method:  true</pre><p>Now, we have a value receiver function at line 33 and the output from value receiver function is not what we intended to be. Because every value receiver function copies the struct and creates a new instance of the struct for the functions use only. Any alteration of value is encapsulated within the function. So when we call u.is_verified after calling the value receiver function the value of the struct remains unchanged. Yes, we can return a value from the function and update it in the main function. But the code becomes too verbose and unmaintanable. Here comes pointer receiver methods to rescue, they take pointer of a struct and change the value globally, as it should be.</p><p>So, we should choose pointer receivers 1if we want to change the value of a struct within the method, and 2to avoid excessive memory usage by copy each time the method is called. Although for a struct small like ours, wouldn’t matter. For the sake of giving examples I have used both value receiverand pointer receiverfor the struct Userbut in real world, we should use either one of the methods, never both.</p><p>Please Note that, all struct fields, functions, and methods names are in lower case. This avoids external modules to import them, just like private functions in java, c++, c# etc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2bd45840e2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/newroztech/functions-and-methods-in-go-e2bd45840e2">Functions and Methods in Go</a> was originally published in <a href="https://medium.com/newroztech">NewrozTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tip for Go Services at Scale]]></title>
            <link>https://medium.com/newroztech/tip-for-go-services-at-scale-e53caa059d57?source=rss----e24389fb1346---4</link>
            <guid isPermaLink="false">https://medium.com/p/e53caa059d57</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[rest]]></category>
            <dc:creator><![CDATA[Sabbir Ahmed]]></dc:creator>
            <pubDate>Mon, 31 Oct 2022 09:15:58 GMT</pubDate>
            <atom:updated>2022-10-16T06:01:43.879Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RRYHNGtMgdXDZmFQEUQ9EA.png" /><figcaption>Image by <a href="https://www.freepik.com/free-photo/mountain-fire_20363694.htm#query=hot&amp;position=35&amp;from_view=search&amp;track=sph">Rochak Shukla</a> on Freepik And Gopher from <a href="https://www.dlf.pt/ddetail/ixmihhh_gopher-aws-golang-hd-png-download/">dlf.pt</a></figcaption></figure><p>At <a href="https://bd.linkedin.com/company/newroztech">NewrozTech</a>, we try to simulate the production environment by doing various tests with our service. One of the fundamental things is load testing primarily with Ddosify and finally with Jmeter. In this article, I will share my experience with a simple go tweak that made a huge difference.</p><p>Generally, we don’t use channels for sequential tasks like reading and writing a single row in the database. If we take an insert operation in the DB, our code will look more like the following,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28027ecdc4db7d5944b8be3f4744d7ed/href">https://medium.com/media/28027ecdc4db7d5944b8be3f4744d7ed/href</a></iframe><p>which is completely fine and performed very well under 8K req/s load with our business logic. All the requests were processed within 5–15ms with our commodity hardware. But when we increased the load to 10K req/s, the service struggled to process all the requests. On average, 15% of our requests fail due to connection timeout issues.</p><p>Just by refactoring the above snippet to a buffered channel with capacity 1,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1546468c263da695e24c4542e2e23543/href">https://medium.com/media/1546468c263da695e24c4542e2e23543/href</a></iframe><p>we were able to serve 9.3% more requests per sec. We have used 3 types of load available on Ddosify, linear, incremental, and waved . Though both of the methods delivered their lowest performance with waved load type, we observed overall improvement with the concurrent pattern.</p><p>The full diff between the two different methods is —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1355467697c786cad5ceaaf22130205e/href">https://medium.com/media/1355467697c786cad5ceaaf22130205e/href</a></iframe><p>From the diff, we can also see that not only do we have fewer errors the server response time in total has also decreased except in waved load type. The Bad Requests are random and intentional to predict client-side issues. But we can also see the similarities in the 400 error count.</p><p>We started with 5K TPS, our target to achieve 10K TPS in our intranet. We were able to achieve the goal after a while here’s a demo —</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FQ-cxJ8yOHQg&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQ-cxJ8yOHQg&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FQ-cxJ8yOHQg%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b6e7bdac17f8f4b059057d4bb8a3ab7/href">https://medium.com/media/8b6e7bdac17f8f4b059057d4bb8a3ab7/href</a></iframe><p>I love how gracefully Go releases the resources and how little resources it consumes to serve thousands of concurrent requests. The final container size of the application was only 13mb, it took only &lt;500mb memory to serve 10K requests, and it released all the resources almost instantly after the tests finished!</p><p>Happy hacking…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e53caa059d57" width="1" height="1" alt=""><hr><p><a href="https://medium.com/newroztech/tip-for-go-services-at-scale-e53caa059d57">Tip for Go Services at Scale</a> was originally published in <a href="https://medium.com/newroztech">NewrozTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>