<?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 Saravanakumar Arunachalam on Medium]]></title>
        <description><![CDATA[Stories by Saravanakumar Arunachalam on Medium]]></description>
        <link>https://medium.com/@saravanastar?source=rss-f1a83961ef09------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*IFeTcl35EZGV3LTF</url>
            <title>Stories by Saravanakumar Arunachalam on Medium</title>
            <link>https://medium.com/@saravanastar?source=rss-f1a83961ef09------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:03:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saravanastar/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[AI Agents Explained: Their Role in Modern AI Systems — Learning Notes (Part II)]]></title>
            <link>https://saravanastar.medium.com/ai-agents-explained-their-role-in-modern-ai-systems-learning-notes-part-ii-a26430a5e9ff?source=rss-f1a83961ef09------2</link>
            <guid isPermaLink="false">https://medium.com/p/a26430a5e9ff</guid>
            <category><![CDATA[tech-notes]]></category>
            <category><![CDATA[leveraging-ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Saravanakumar Arunachalam]]></dc:creator>
            <pubDate>Wed, 19 Feb 2025 00:02:07 GMT</pubDate>
            <atom:updated>2025-02-19T00:19:33.417Z</atom:updated>
            <content:encoded><![CDATA[<h3>AI Agents Explained: Their Role in Modern AI Systems — Learning Notes (Part II)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dN6MIpNVBwxvxO8qPR-IHA.jpeg" /></figure><h3>What is an Agent?</h3><p>An <strong>agent </strong>is an AI-driven system that interacts with its environment to achieve a user-defined objective. It combines reasoning, planning, and executing actions, often leveraging external tools. The backbone of an agent is a <strong>Large Language Model (LLM)</strong>, which enables it to process and respond to natural language inputs effectively.</p><h3>How Does an Agent Work?</h3><p>An agent serves as a <strong>coordinator</strong> for executing specialized tasks within a predefined environment equipped with various tools. The <strong>LLM acts as the core component</strong>, interpreting natural language inputs, maintaining state, and determining the next course of action. If a task requires external data or computation, the agent invokes its equipped tools, processes the results, and continues maintaining the state with the LLM.</p><h3>The Agent Workflow:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*buWl0zjJXGAnc4WTnyqXXg.png" /></figure><p>1. <strong>Understand</strong>: The agent receives a user query and processes it using an LLM.</p><p>2. <strong>Decide</strong>: If the task requires external tools (e.g., fetching real-time data), the agent determines which tools to use.</p><p>3. <strong>Execute</strong>: The agent invokes the necessary tool(s), retrieves the results, and integrates them into the conversation.</p><p>4. <strong>Respond</strong>: The agent returns a meaningful response while maintaining context for future interactions.</p><h3>Why Do We Need Agents?</h3><p>LLMs primarily function as generative models, meaning they generate text based on input prompts. However, they do not inherently <strong>react</strong> to real-world events or provide up-to-date information. This is where <strong>agents and tools </strong>come into play.</p><p>For example, if a user asks about today’s weather, an LLM alone would rely on its training data, which may be outdated. An agent, on the other hand, can invoke a weather API to fetch real-time data and provide an accurate response.</p><h3>Understanding Large Language Models (LLMs)</h3><p>An <strong>LLM</strong> is an AI model that excels at understanding and generating human language. These models are trained on vast datasets, learning patterns, structures, and nuances in language. Most LLMs today are based on <strong>Transformer architecture</strong>, which has revolutionized natural language processing since Google introduced <strong>BERT</strong> in 2018.</p><p><strong>Types of Transformer Models:</strong></p><p>1. <strong>Encoders</strong>: Convert input text into a dense representation (embedding).</p><p>2. <strong>Decoders</strong>: Generate text token by token.</p><p>3. <strong>Seq2Seq (Encoder-Decoder):</strong> Combine both for tasks like translation and summarization (e.g., T5, BART).</p><h3>The Role of Prompting</h3><p><strong>Prompting</strong> is a crucial component of LLM interactions, determining how the model predicts and generates responses. When a user interacts with an LLM, they provide a <strong>prompt</strong>, which often includes prior conversation history to maintain context.</p><p><strong>Example of Message History in a Prompt:</strong></p><pre>message_history = [{<br>&quot;role&quot;: &quot;system&quot;,<br>&quot;content&quot;: &quot;You are a stock market analyst and will help me pick stocks.&quot;<br>},<br>{<br>&quot;role&quot;: &quot;user&quot;,<br>&quot;content&quot;: &quot;Please help me pick a stock.&quot;<br>}]</pre><p>This structured conversation ensures that the LLM understands its role and provides relevant responses.</p><p><strong>Special Tokens in LLMs</strong></p><p>LLMs use <strong>special tokens</strong> to structure and interpret input data. Above the array converted to the string with a delimiter specialized for each LLM. I would call it a message protocol — API format to talk to the LLM. These translations it is taken care of by a library called transformers. Find the below list delimiters we use</p><p>- <strong>End of Sequence (EOS)</strong>: Signals where the response should stop.</p><p>- <strong>Beginning of Sequence (BOS)</strong>: Marks the start of input.</p><p>- <strong>Padding Token</strong>: Ensures consistent input length.</p><p>- <strong>Masking Token</strong>: Used in models like BERT to predict missing words.</p><p>- <strong>Separation Token</strong>: Differentiates instructions, user queries, and system responses.</p><p>- <strong>Special Instruction Tokens</strong>: Define task boundaries for instruction-based models.</p><h3>What Are AI Tools?</h3><p>AI tools are specialized functions integrated with an LLM to extend its capabilities. These tools perform tasks beyond the LLM’s native abilities, such as fetching real-time data or performing mathematical computations.</p><p><strong>Common AI Tools and Their Functions:</strong></p><p><strong>Web Search: </strong>Retrieves current data from the internet.</p><p><strong>Image Generation:</strong> Creates images based on text input.</p><p><strong>Retrieval: </strong>Fetches relevant documents from a database.</p><p><strong>API Interface: </strong>Interacts with external APIs (e.g., GitHub, YouTube).</p><p>For example, if an LLM needs to perform <strong>arithmetic calculations</strong>, an integrated <strong>calculator tool</strong> will yield more accurate results than relying on the LLM’s text-based predictions.</p><h3>Conclusion</h3><p>AI agents bridge the gap between LLMs and real-world interactivity. While LLMs generate human-like text, agents empower them to interact with their environment, retrieve real-time information, and execute specialized tasks. By integrating external tools, AI agents extend the capabilities of LLMs, making them more practical and responsive in real-world applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a26430a5e9ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Golang with a Java Background: A Developer’s Journey — Part III]]></title>
            <link>https://saravanastar.medium.com/learning-golang-with-a-java-background-a-developers-journey-part-iii-d4a44a9e333b?source=rss-f1a83961ef09------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4a44a9e333b</guid>
            <category><![CDATA[gochain]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[goroutines]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[threads]]></category>
            <dc:creator><![CDATA[Saravanakumar Arunachalam]]></dc:creator>
            <pubDate>Thu, 13 Feb 2025 03:54:22 GMT</pubDate>
            <atom:updated>2025-02-13T03:54:22.499Z</atom:updated>
            <content:encoded><![CDATA[<h3>Learning Golang with a Java Background: A Developer’s Journey — Part III</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Ps7woSWSxJaRhhfRg0Vew.jpeg" /></figure><p>We have already published two parts of this series. If you are new to Golang and have a Java background, check out the previous parts to start from scratch:</p><ul><li><a href="https://medium.com/@saravanastar/learning-golang-with-a-java-background-a-developers-journey-part-i-3615aff8c983">Part I</a></li><li><a href="https://medium.com/@saravanastar/learning-golang-with-a-java-background-a-developers-journey-part-ii-efbd9fbce470">Part II</a></li></ul><p>In this article, we will explore three core concepts of Golang: <strong>Pointers, Goroutines, Channels and Context</strong>. These concepts are fundamental to writing efficient and concurrent programs in Go.</p><h3>Pointers</h3><h3>Java:</h3><p>In Java, pointers are handled implicitly by the JVM. Java does not expose memory addresses directly but provides methods like hashCode() to retrieve an identifier for an object. Java primarily follows <strong>pass-by-reference</strong> when working with objects.</p><h4>Example:</h4><pre>public class Main {<br>    public static void main(String[] args) {<br>        MyClass myClassObject = new MyClass();<br>        myClassObject.value = 5;<br>        System.out.println(myClassObject.value); // prints 5<br>        update(myClassObject);<br>        System.out.println(myClassObject.value); // prints 6<br>    }<br><br>    public static void update(MyClass myClassObject) {<br>        myClassObject.value = 6;<br>    }<br>}<br><br>class MyClass {<br>    int value;<br>}</pre><p>In the above example, the object reference is passed to the update method, and modifications are reflected in the caller method.</p><h3>Golang:</h3><p>Unlike Java, Golang requires explicit pointer handling using the &amp; operator. Go follows <strong>pass-by-value</strong> by default, meaning that when an object is passed to a function, a copy of it is created. If you want to modify the original object, you need to pass a pointer.</p><h4>Example (Without Pointers — No Change):</h4><pre>type MyObject struct {<br>    Value int<br>}<br><br>func main() {<br>    object := MyObject{Value: 5}<br>    fmt.Println(object.Value) // prints 5<br>    update(object)<br>    fmt.Println(object.Value) // prints 5<br>}<br><br>func update(object MyObject) {<br>    object.Value = 6<br>}</pre><h4>Example (With Pointers — Value Gets Updated):</h4><pre>type MyObject struct {<br>    Value int<br>}<br><br>func main() {<br>    object := MyObject{Value: 5}<br>    fmt.Println(object.Value) // prints 5<br>    update(&amp;object)<br>    fmt.Println(object.Value) // prints 6<br>}<br><br>func update(object *MyObject) {<br>    object.Value = 6<br>}</pre><h3>Goroutines and Channels</h3><p>Java developers familiar with <strong>Threads, Callables, and Runnables</strong> will find Goroutines and Channels to be Go’s equivalents.</p><h3>Java:</h3><p>In Java, we use CompletableFuture for asynchronous programming. If the result is not required immediately, we can use runAsync(), otherwise, we use supplyAsync().</p><h4>Example:</h4><pre>import java.util.concurrent.*;<br><br>public class MyClass {<br>  public static void main(String args[]) throws Exception {<br>    CompletableFuture&lt;Integer&gt; future = CompletableFuture.supplyAsync(() -&gt; {<br>        System.out.println(&quot;Executing the supplyAsync&quot;);<br>        return 1;<br>    });<br>    System.out.println(&quot;Completed: &quot; + future.get());<br>  }<br>}</pre><h3>Golang:</h3><p>Go does not have a Future concept but instead uses <strong>channels</strong> to synchronize goroutines.</p><h4>Example (Using Channels):</h4><pre>package main<br><br>import (<br>    &quot;fmt&quot;<br>    &quot;time&quot;<br>)<br><br>func main() {<br>    ch := make(chan bool)<br>    go func(ch chan bool) {<br>        fmt.Println(&quot;Processing the thread&quot;)<br>        time.Sleep(2 * time.Second)<br>        fmt.Println(&quot;2-second wait is complete&quot;)<br>        ch &lt;- true // pass down results to the channel<br>    }(ch)<br>    <br>    fmt.Printf(&quot;Processed Successfully: %v&quot;, &lt;-ch) // &lt;- ch wait until the result published in the channel<br>}</pre><p>Channels in Go help synchronize goroutines and pass data between them. Another way to manage concurrency is using sync.WaitGroup.</p><h3>Context in Golang</h3><p>Unlike Java, Go provides a built-in <strong>context</strong> package for managing request-scoped values, cancellation signals, and timeouts across API boundaries and goroutines.</p><h3>Core Functions in context Package:</h3><ul><li>context.WithCancel(parent Context): Allows manual cancellation of operations.</li><li>context.WithTimeout(parent Context, timeout time.Duration): Cancels operations after a timeout.</li><li>context.WithValue(parent Context, key, val interface{}): Passes request-scoped values.</li></ul><h4>Example (Cancellation):</h4><pre>package main<br><br>import (<br>    &quot;context&quot;<br>    &quot;fmt&quot;<br>    &quot;time&quot;<br>)<br><br>func worker(ctx context.Context) {<br>    for {<br>        select {<br>        case &lt;-ctx.Done():<br>            fmt.Println(&quot;Worker canceled:&quot;, ctx.Err()) // Execute this Line<br>            return<br>        default:<br>            fmt.Println(&quot;Working...&quot;)<br>            time.Sleep(500 * time.Millisecond)<br>        }<br>    }<br>}<br><br>func main() {<br>    ctx, cancel := context.WithCancel(context.Background())<br>    go worker(ctx)<br>    time.Sleep(2 * time.Second)<br>    cancel()<br>    time.Sleep(1 * time.Second)<br>}</pre><h4>Example (Timeout):</h4><pre>package main<br><br>import (<br>    &quot;context&quot;<br>    &quot;fmt&quot;<br>    &quot;time&quot;<br>)<br><br>func worker(ctx context.Context) {<br>    select {<br>    case &lt;-time.After(2 * time.Second):<br>        fmt.Println(&quot;Work done!&quot;)<br>    case &lt;-ctx.Done():<br>        fmt.Println(&quot;Worker canceled:&quot;, ctx.Err()) // Execute this as timeout is 1 second<br>    }<br>}<br><br>func main() {<br>    ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)<br>    defer cancel()<br>    go worker(ctx)<br>    time.Sleep(2 * time.Second)<br>}</pre><h4>Example (Request Scoped Values):</h4><pre>package main<br><br>import (<br>    &quot;context&quot;<br>    &quot;fmt&quot;<br>)<br><br>func main() {<br>    ctx := context.WithValue(context.Background(), &quot;userID&quot;, 123)<br>    userID := ctx.Value(&quot;userID&quot;).(int)<br>    fmt.Println(&quot;User ID:&quot;, userID)<br>}</pre><h3>When to Use Context</h3><ul><li><strong>HTTP Requests</strong>: Handle timeouts or cancellations.</li><li><strong>Database Calls</strong>: Enforce query timeouts.</li><li><strong>Goroutines</strong>: Manage concurrent processes efficiently.</li><li><strong>Microservices</strong>: Pass request metadata across services.</li></ul><p>This marks the end of our comparison between Java and Golang. While we’ve covered key differences in pointers, concurrency, and context handling, the best way to solidify these concepts is through hands-on practice. Try implementing small projects in Golang to experience its unique features firsthand!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4a44a9e333b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding LLM and RAG: My Notes — Part I]]></title>
            <link>https://saravanastar.medium.com/understanding-llm-and-rag-my-notes-part-i-356936efee52?source=rss-f1a83961ef09------2</link>
            <guid isPermaLink="false">https://medium.com/p/356936efee52</guid>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[augmented-intelligence]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Saravanakumar Arunachalam]]></dc:creator>
            <pubDate>Thu, 13 Feb 2025 01:30:36 GMT</pubDate>
            <atom:updated>2025-02-13T01:30:36.069Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding LLM and RAG: My Notes — Part I</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aL95vSLyMxL3hEGwWt1SJQ.jpeg" /></figure><p>Artificial Intelligence (AI) refers to the process of training machines to learn and exhibit intelligence based on data provided to algorithms. AI is broadly classified into two types: <strong>Predictive AI</strong> and <strong>Generative AI</strong>.</p><h3>Types of Artificial Intelligence</h3><h3>Predictive AI</h3><p>Predictive AI is used to analyze existing data and make predictions about future events. It helps in identifying patterns and estimating probabilities. For example:</p><ul><li>Image recognition: Identifying objects in images.</li><li>Stock market analysis: Predicting stock price movements based on historical data.</li></ul><h3>Generative AI</h3><p>Generative AI is used to create new content, such as images, videos, and text. It learns patterns from existing data and generates novel outputs. Examples include:</p><ul><li>AI-generated artwork and videos.</li><li>Writing essays, poems, and code.</li><li>Creating synthetic voices and music.</li></ul><h3>Machine Learning and Deep Learning</h3><p>Machine Learning (ML) and Deep Learning (DL) are subsets of AI that focus on gaining intelligence through data-driven training. A simple analogy is human learning through schools and colleges to acquire knowledge.</p><h3>Machine Learning Methods</h3><p>Machine learning can be categorized into different types:</p><ul><li><strong>Supervised Learning</strong>: Similar to a school setting where a teacher provides labeled examples for training.</li><li><strong>Semi-Supervised Learning</strong>: Comparable to homeschooling, where both labeled and unlabeled data are used for learning.</li><li><strong>Unsupervised Learning</strong>: Learning without direct supervision, similar to self-learning without attending formal education.</li></ul><h3>Deep Learning</h3><p>Deep learning is a specialized form of ML that uses neural networks to train models with multiple layers of interconnected nodes. These layers are called <strong>hidden layers</strong>, and each connection (vertex) has a <strong>weight</strong> assigned to it. By adjusting the weights and using activation functions, the system optimizes its predictions. These trained weights and activation function values are then applied to test data to generate insights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQ_8YIb7zBT9JFKNEUbWBw.jpeg" /></figure><h3>Large Language Models (LLMs)</h3><p>Large Language Models (LLMs) are a type of generative AI trained on massive amounts of text data with numerous parameters. Examples of popular LLMs include:</p><ul><li><strong>LLaMA</strong> (by Meta)</li><li><strong>GPT (OpenAI)</strong></li><li><strong>Claude</strong> (Anthropic)</li><li><strong>Gemini</strong> (Google DeepMind)</li></ul><h3>Retrieval-Augmented Generation (RAG)</h3><h3>Why RAG is Needed</h3><p>LLMs are generally trained on publicly available or general knowledge data. However, enterprises often require AI to provide answers specific to their organization. Training a custom LLM from scratch is resource-intensive, requiring enormous computing power and memory. <strong>Retrieval-Augmented Generation (RAG)</strong> solves this problem by:</p><ul><li>Storing organization-specific data in a <strong>vector database</strong>.</li><li>Retrieving relevant information from the database and providing it as context to the LLM.</li><li>Improving the accuracy and relevance of AI-generated responses.</li></ul><h3>Vector Databases</h3><p>A <strong>vector database</strong> is a specialized type of database optimized for <strong>semantic search</strong>. Instead of storing traditional tabular data, it stores data as vectors to enable similarity searches using mathematical algorithms.</p><h3>Common Similarity Search Algorithms</h3><ul><li><strong>Cosine Similarity</strong>: Measures the cosine of the angle between two vectors to determine their similarity.</li><li><strong>Euclidean Distance</strong>: Computes the straight-line distance between two points in vector space.</li></ul><h3>Popular Vector Databases</h3><ul><li><strong>Weaviate</strong></li><li><strong>Milvus</strong></li></ul><p>These databases enhance AI applications by enabling efficient retrieval of relevant data, making them essential for enterprise AI solutions.</p><p>In the next part, we will work on a <strong>mini-project</strong> where we integrate LLM with a vector database to create a functional AI application. Stay tuned for hands-on implementation!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=356936efee52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Golang with a Java Background: A Developer’s Journey — Part II]]></title>
            <link>https://saravanastar.medium.com/learning-golang-with-a-java-background-a-developers-journey-part-ii-efbd9fbce470?source=rss-f1a83961ef09------2</link>
            <guid isPermaLink="false">https://medium.com/p/efbd9fbce470</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[learning-and-development]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[collection]]></category>
            <dc:creator><![CDATA[Saravanakumar Arunachalam]]></dc:creator>
            <pubDate>Fri, 24 Jan 2025 04:10:33 GMT</pubDate>
            <atom:updated>2025-01-24T04:27:58.734Z</atom:updated>
            <content:encoded><![CDATA[<h3>Learning Golang with a Java Background: A Developer’s Journey — Part II</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ngB07wYbAEY0cH1RVbxjQ.png" /><figcaption>GOLAVA</figcaption></figure><p>Welcome back to the second installment of our journey exploring the transition from Java to Golang! If you haven’t yet read <a href="https://saravanastar.medium.com/learning-golang-with-a-java-background-a-developers-journey-part-i-3615aff8c983">Part I</a>, I highly recommend starting there for a smoother progression. In this article, we’ll delve into one of the core aspects of programming — <strong>collections</strong>. Specifically, we’ll focus on arrays, slices, maps, and their Golang equivalents. By the end, you’ll have a solid understanding of how these data structures function in Golang and how they differ from or align with what you may already know in Java.</p><h3>Collections in Golang</h3><p>Collections are the backbone of most programs, allowing developers to efficiently store, retrieve, and manipulate data. For Java developers, collections like arrays, ArrayList, HashMap, and HashSet are second nature. In Golang, we have similar constructs, but they come with their own unique traits.</p><h3>Arrays and Slices</h3><p>In Java, arrays are fixed-length collections, and dynamic resizing is achieved through classes like ArrayList. In Golang, we also have <strong>arrays</strong> (fixed length) and <strong>slices</strong>, which can dynamically resize. Think of slices as Golang&#39;s answer to Java&#39;s ArrayList.</p><p>Here’s a quick comparison:</p><ul><li><strong>Array</strong>: A collection with a fixed length.</li><li><strong>Slice</strong>: A dynamic-length abstraction over arrays, offering flexibility and functionality.</li></ul><p><strong>Java Example:</strong></p><pre>// Array<br>int[] example = new int[]{1, 2, 3, 4};<br><br>// ArrayList<br>List&lt;Integer&gt; arrayList = new ArrayList&lt;&gt;();<br><br>// Adding the element<br>arrayList.add(1); // [1]<br><br>// Removing the element at the index<br>arrayList.remove(1); // [1]</pre><h4>Golang Example:</h4><pre>// Array<br>example := [4]int{1, 2, 3, 4}<br><br>// Slice<br>var mySlice []int // Declares a slice of integers with a nil value<br><br>// Slice with length<br>mySlice := make([]int, 5) // Length and capacity are both 5<br><br>// Slice with length and capacity<br>mySlice2 := make([]int, 5, 10) // Length is 5, capacity is 10<br><br>// Slice with no size and capacity<br>mySlice3 := []int{} // Instantiating the slice with an empty array</pre><p>In Golang, the make function is crucial for creating slices. It allows you to define both the <strong>length</strong> (number of elements) and the <strong>capacity</strong> (potential size without reallocating memory).</p><h4>Adding and Removing Elements</h4><p>Adding elements to slices in Golang is intuitive. Using the built-in append function, you can grow a slice dynamically. Removing or modifying elements can be achieved with slicing operations.</p><pre>// Creating a slice<br>numbers := []int{1, 2, 3, 4, 5}<br>fmt.Println(&quot;Original slice:&quot;, numbers) // Output: [1 2 3 4 5]<br><br>// Slicing a slice (uses for deletion as well)<br>subSlice := numbers[1:4]<br>fmt.Println(&quot;Sub-slice:&quot;, subSlice) // Output: [2 3 4]<br><br>// Appending to a slice<br>numbers = append(numbers, 6, 7)<br>fmt.Println(&quot;Slice after append:&quot;, numbers) // Output: [1 2 3 4 5 6 7]<br><br>// Sorting the slice<br>slices.Sort(numbers)</pre><h3>Maps</h3><p>Maps, or dictionaries, are key-value data structures that are indispensable in modern programming. Like Java’s HashMap, Golang&#39;s map is a flexible way to associate keys with values.</p><h4>Java Example:</h4><pre>// Initializing HashMap<br>Map&lt;Integer, Integer&gt; mapObject = new HashMap&lt;&gt;();<br><br>// Adding key-value pairs<br>mapObject.put(1, 1);<br><br>// Removing a key<br>mapObject.remove(1);<br><br>// Checking if a key exists<br>boolean containsKey = mapObject.containsKey(1);<br><br>// Looping through the map<br>for (Map.Entry&lt;Integer, Integer&gt; entry : mapObject.entrySet()) {<br>    Integer key = entry.getKey();<br>    Integer value = entry.getValue();<br>    System.out.println(key + &quot;: &quot; + value);<br>}</pre><h4>Golang Example:</h4><pre>// Initializing the map<br>mapObject := make(map[int]int)<br><br>// Adding key-value pairs<br>mapObject[1] = 1<br><br>// Deleting a key<br>delete(mapObject, 1)<br><br>// Checking if a key exists<br>value, ok := mapObject[1] // &#39;ok&#39; is true if the key is present<br><br>// Looping through the map<br>for key, value := range mapObject {<br>    println(key, value)<br>}</pre><h3>Sets</h3><p>While Java has a dedicated HashSet class, Golang does not have a built-in set data structure. Instead, developers simulate sets using maps, where the map&#39;s key represents the set element, and the value is typically an empty struct (struct{}) to save memory.</p><h4>Java Example:</h4><pre>// Initializing HashSet<br>Set&lt;Integer&gt; set = new HashSet&lt;&gt;();<br><br>// Adding elements<br>set.add(1);<br>set.add(2);<br><br>// Removing elements<br>set.remove(1);</pre><h4>Golang Example:</h4><pre>// Initializing the set<br>set := make(map[int]struct{})<br><br>// Adding elements<br>set[0] = struct{}{}<br>set[1] = struct{}{}<br><br>// Looping through the set<br>for key := range set {<br>    println(key)<br>}</pre><h3>Conclusion</h3><p>In this article, we’ve explored how Golang handles essential collections — arrays, slices, maps, and sets — and how they compare to their Java counterparts. These data structures are fundamental to writing clean, efficient, and idiomatic code in Golang.</p><p>Transitioning from Java to Golang might feel daunting at first, but understanding these foundational elements will make the process much smoother.</p><p>Stay tuned for <strong>Part III</strong> of this series, where we’ll dive into advanced Golang topics, including <strong>pointers</strong>, <strong>channels</strong>, and <strong>contexts</strong>. Mastering these concepts will help you unlock the full potential of Go as a modern programming language.</p><p>Happy coding, and see you in the next installment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efbd9fbce470" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Essential kubectl Commands for Beginners]]></title>
            <link>https://saravanastar.medium.com/essential-kubectl-commands-for-beginners-0bb8300bf00c?source=rss-f1a83961ef09------2</link>
            <guid isPermaLink="false">https://medium.com/p/0bb8300bf00c</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kubectl-commands]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Saravanakumar Arunachalam]]></dc:creator>
            <pubDate>Wed, 08 Jan 2025 17:32:12 GMT</pubDate>
            <atom:updated>2025-01-09T01:02:34.652Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DNCVMpmPejkhtQBR4pg4YQ.png" /></figure><p>If you’re new to Kubernetes, mastering kubectl is your first step toward managing clusters like a pro. This quick guide will help you learn the most essential commands every beginner should know. And remember, for operations specific to a namespace, use the -n &lt;namespace&gt; flag to simplify your workflow.</p><h3>Context</h3><p><strong>List all k8s Context</strong></p><pre>kubectl config get-contexts</pre><p><strong>Describe the context</strong></p><pre>kubectl config get-contexts my-context</pre><p><strong>Use the Context</strong></p><pre>kubectl config use-context CONTEXT_NAME</pre><p><strong>Show the KubeConfig</strong></p><pre>kubectl config view</pre><h3>Namespace Management</h3><p>Namespaces allow you to organize and manage resources within your cluster.</p><p><strong>List all namespaces:</strong></p><pre>kubectl get namespaces</pre><p><strong>Create a new namespace:</strong></p><pre>kubectl create namespace &lt;namespace-name&gt;</pre><p><strong>Delete a namespace:</strong></p><pre>kubectl delete namespace &lt;namespace-name&gt;</pre><p><strong>Set the default namespace for the current context:</strong></p><pre>kubectl config set-context --current --namespace=&lt;namespace-name&gt;</pre><h3>Pod Operations</h3><p>Pods are the fundamental units of deployment in Kubernetes.</p><p><strong>List all pods in the current namespace:</strong></p><pre>kubectl get pods</pre><p><strong>Delete a specific pod:</strong></p><pre>kubectl delete pod &lt;pod-name&gt;</pre><p><strong>Execute a command inside a pod</strong></p><pre>kubectl exec -it &lt;pod-name&gt; -- &lt;command&gt;</pre><p>Example:</p><pre>kubectl exec -it &lt;pod-name&gt; -- bash</pre><p><strong>Print environment variables of a pod:</strong></p><pre>kubectl exec -it &lt;pod-name&gt; -- env</pre><p><strong>Filter pods by label:</strong></p><pre>kubectl get pods -l &lt;label-key&gt;=&lt;label-value&gt;</pre><p>Example:</p><pre>kubectl get pods -l app=webapp</pre><p><strong>Create a pod with a specific image:</strong></p><pre>kubectl run &lt;pod-name&gt; --image=&lt;image-name&gt; --restart=Never</pre><p>Example:</p><pre>kubectl run &lt;pod-name&gt; --image=&lt;image-name&gt; --restart=Never</pre><p><strong>Generate pod YAML without creating it:</strong></p><pre>kubectl run &lt;pod-name&gt; --image=&lt;image-name&gt; --restart=Never --dry-run=client -o yaml</pre><p>Example:</p><pre>kubectl run web --image=nginx --restart=Never --dry-run=client -o yaml</pre><p><strong>Port-forward a pod to localhost:</strong></p><pre>kubectl port-forward pod/&lt;pod-name&gt; &lt;local-port&gt;:&lt;pod-port&gt;</pre><p>Example:</p><pre>kubectl port-forward pod/web 8080:80</pre><h3>Deployment Management</h3><p>Deployments manage the deployment and scaling of pod sets.</p><p><strong>List all deployments:</strong></p><pre>kubectl get deployments</pre><p><strong>Create a deployment:</strong></p><pre>kubectl create deployment &lt;deployment-name&gt; --image=&lt;image-name&gt;</pre><p>Example:</p><pre>kubectl create deployment webapp --image=nginx</pre><p><strong>Update the image of a deployment:</strong></p><pre>kubectl set image deployment/&lt;deployment-name&gt; &lt;container-name&gt;=&lt;new-image&gt;</pre><p>Example:</p><pre>kubectl set image deployment/webapp nginx=nginx:1.19</pre><p><strong>Scale a deployment</strong></p><pre>kubectl scale deployment/&lt;deployment-name&gt; --replicas=&lt;number-of-replicas&gt;</pre><p>Example:</p><pre>kubectl scale deployment/webapp --replicas=3</pre><p><strong>Roll back a deployment to a previous revision:</strong></p><pre>kubectl rollout undo deployment/&lt;deployment-name&gt;</pre><p>Example:</p><pre>kubectl rollout undo deployment/webapp</pre><h3>Service Management</h3><p>Services expose your applications to the network.</p><p><strong>List all services:</strong></p><pre>kubectl get services</pre><p><strong>Create a service to expose a deployment:</strong></p><pre>kubectl expose deployment/&lt;deployment-name&gt; --port=&lt;port&gt; --target-port=&lt;target-port&gt; --type=&lt;service-type&gt;</pre><p>Example:</p><pre>kubectl expose deployment/webapp --port=80 --target-port=8080 --type=LoadBalancer</pre><p><strong>Delete a service</strong></p><pre>kubectl delete service &lt;service-name&gt;</pre><p><strong>Port-Forward a Service</strong></p><pre>kubectl port-forward service/myservice 8443:https</pre><h3>ConfigMap and Secret Management</h3><p>ConfigMaps and Secrets manage configuration data and sensitive information.</p><p><strong>Create a ConfigMap from a file:</strong></p><pre>kubectl create configmap &lt;configmap-name&gt; --from-file=&lt;file-path&gt;</pre><p>Example</p><pre>kubectl create configmap app-config --from-file=config.yaml</pre><p><strong>Create a Secret from literal values:</strong></p><pre>kubectl create secret generic &lt;secret-name&gt; --from-literal=&lt;key&gt;=&lt;value&gt;</pre><p>Example:</p><pre>kubectl create secret generic db-secret --from-literal=username=admin --from-literal=password=secret</pre><p><strong>View a ConfigMap:</strong></p><pre>kubectl get configmap &lt;configmap-name&gt; -o yaml</pre><p><strong>View a Secret (base64 encoded):</strong></p><pre>kubectl get secret &lt;secret-name&gt; -o yaml</pre><h3>Logs and Events</h3><p>Monitoring logs and events is crucial for debugging.</p><p><strong>View logs of a pod:</strong></p><pre>kubectl logs &lt;pod-name&gt;</pre><p><strong>Stream logs of a pod:</strong></p><pre>kubectl logs -f &lt;pod-name&gt;</pre><p><strong>View events in the current namespace:</strong></p><pre>kubectl get events</pre><h3>Node Management</h3><p>Nodes are the worker machines in a Kubernetes cluster.</p><p><strong>List all nodes:</strong></p><pre>kubectl get nodes</pre><p><strong>View detailed information about a node:</strong></p><pre>kubectl describe node &lt;node-name&gt;</pre><p><strong>Cordon a node (mark as unschedulable):</strong></p><pre>kubectl cordon &lt;node-name&gt;</pre><p><strong>Uncordon a node (mark as schedulable):</strong></p><pre>kubectl uncordon &lt;node-name&gt;</pre><p><strong>Drain a node (safely evict all pods):</strong></p><pre>kubectl drain &lt;node-name&gt; --ignore-daemonsets --delete-emptydir-data</pre><h3>Pro Tip</h3><p>For any operation specific to a namespace, always include the -n &lt;namespace&gt; flag. For example:</p><pre>kubectl get pods -n dev</pre><h3>Ready to Start?</h3><p>These commands are your entry point into the powerful world of Kubernetes. Start experimenting with them today, and you’ll be on your way to becoming a Kubernetes expert!</p><p>For more commands please reference: <a href="https://kubernetes.io/docs/reference/kubectl/">https://kubernetes.io/docs/reference/kubectl/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0bb8300bf00c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Golang with a Java Background: A Developer’s Journey — Part I]]></title>
            <link>https://saravanastar.medium.com/learning-golang-with-a-java-background-a-developers-journey-part-i-3615aff8c983?source=rss-f1a83961ef09------2</link>
            <guid isPermaLink="false">https://medium.com/p/3615aff8c983</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Saravanakumar Arunachalam]]></dc:creator>
            <pubDate>Wed, 08 Jan 2025 01:35:42 GMT</pubDate>
            <atom:updated>2026-11-12T13:10:09.399Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Learning Golang with a Java Background: A Developer’s Journey — Part I</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UUN6_CcJ48CYThB7SslvoA.png" /></figure><p>Transitioning from Java to Golang can be an exciting and challenging experience. As a Java developer exploring Golang, I want to share my journey, highlighting key differences and the reasons why Java developers might consider learning Go. Both languages have distinct strengths, trade-offs, and use cases, making a comparison both insightful and practical.</p><h3>Why Transition from Java to Golang?</h3><p>Java, a widely-used object-oriented language, boasts robust libraries for web development (e.g., Spring Framework), automatic garbage collection, and a rich ecosystem. However, its high memory footprint can be a drawback for web services. For example, a Spring-based executable JAR typically requires a minimum of 512 MB of memory.</p><p>In contrast, Golang (Go) is celebrated for its efficiency in concurrency handling, memory management, and smaller memory footprints for executables. Yet, Go introduces its own learning challenges, such as its limited object-oriented programming (OOP) support and the concept of pointers, which might be new to Java developers.</p><p>With these differences in mind, let’s explore some practical comparisons between Java and Go.</p><h3>Core Differences Between Java and Golang</h3><h4>Main Method</h4><p>In both languages, the main method serves as the entry point, but their syntax differs.</p><p><strong>Java Example:</strong></p><pre>public static void main(String[] args) {<br>// Your code here<br>}</pre><p><strong>Golang Example:</strong></p><pre>func main() {<br>    // Your code here<br>}</pre><h4>Data Types</h4><p>Here’s a comparison of common data types in Java and Golang:</p><pre><br>| **Java**   | **Golang**   |<br>|------------|--------------|<br>| byte       | byte         |<br>| char       | rune         |<br>| boolean    | bool         |<br>| short      | int16        |<br>| int        | int32        |<br>| long       | int64        |<br>| float      | float32      |<br>| double     | float64      |<br>| -          | complex64    |<br>| -          | complex128   |<br></pre><h4>Operators</h4><p>Both Java and Go share many operators, but there are notable differences:</p><ul><li><strong>No Ternary Operator in Go:</strong> Use if-else statements for conditional expressions.</li><li><strong>Bitwise Complement (~) in Java:</strong> Go uses ^ for bit-flipping.</li><li><strong>Right Shift (&gt;&gt;) Behavior:</strong> In Go, it’s always unsigned, while Java has both signed (&gt;&gt;) and unsigned (&gt;&gt;&gt;) shifts.</li><li><strong>No instanceof in Go:</strong> Use type assertions or reflection for type checking.</li></ul><h4>Control Flow</h4><p><strong>Conditionals (if, else if, else)</strong></p><ul><li><strong>Java:</strong> Parentheses are mandatory around conditions.</li><li><strong>Golang:</strong> Parentheses are omitted, and variables can be declared within the if statement.</li></ul><p><strong>Java Example:</strong></p><pre>if (x &gt; 0) {<br>    System.out.println(&quot;Positive&quot;);<br>} else if (x &lt; 0) {<br>    System.out.println(&quot;Negative&quot;);<br>} else {<br>    System.out.println(&quot;Zero&quot;);<br>}</pre><p><strong>Golang Example:</strong></p><pre>if x &gt; 0 {<br>    fmt.Println(&quot;Positive&quot;)<br>} else if x &lt; 0 {<br>    fmt.Println(&quot;Negative&quot;)<br>} else {<br>    fmt.Println(&quot;Zero&quot;)<br>}</pre><p><strong>Switch/Case</strong></p><ul><li>In Go, break statements are implicit, while Java requires them to prevent fall-through.</li><li>Go supports multiple values per case and allows expressions in cases.</li></ul><p><strong>Java Example:</strong></p><pre>switch (day) {<br>    case 1:<br>        System.out.println(&quot;Monday&quot;);<br>        break;<br>    case 2:<br>        System.out.println(&quot;Tuesday&quot;);<br>        break;<br>    default:<br>        System.out.println(&quot;Other Day&quot;);<br>}</pre><p><strong>Golang Example:</strong></p><pre>switch day {<br>case 1:<br>    fmt.Println(&quot;Monday&quot;)<br>case 2:<br>    fmt.Println(&quot;Tuesday&quot;)<br>default:<br>    fmt.Println(&quot;Other Day&quot;)<br>}</pre><p><strong>Loops</strong></p><p>Go offers a single for loop construct that replaces Java’s for, while, and do-while.</p><p><strong>Java Example (for loop):</strong></p><pre>for (int i = 0; i &lt; 5; i++) {<br>    System.out.println(i);<br>}</pre><p><strong>Golang Example (for loop):</strong></p><pre>for i := 0; i &lt; 5; i++ {<br>    fmt.Println(i)<br>}</pre><h4>Object Creation</h4><p>Go’s structural composition differs significantly from Java’s class-based approach.</p><p><strong>Java Example:</strong></p><pre>class Person {<br>    String name;<br>    int age;<br><br>    Person(String name, int age) {<br>        this.name = name;<br>        this.age = age;<br>    }<br>}<br><br>Person p = new Person(&quot;Alice&quot;, 25);</pre><p><strong>Golang Example:</strong></p><pre>type Person struct {<br>    Name string<br>    Age  int<br>}<br><br>p := Person{Name: &quot;Alice&quot;, Age: 25}</pre><h4>Error Handling</h4><p>Java uses exceptions, while Go emphasizes explicit error handling.</p><p><strong>Java Example:</strong></p><pre>try {<br>    // Code that may throw an exception<br>} catch (Exception e) {<br>    e.printStackTrace();<br>}</pre><p><strong>Golang Example:</strong></p><pre>if err != nil {<br>    fmt.Println(err)<br>}</pre><p>Go also introduces defer to schedule cleanup tasks, which execute when the function ends.</p><h3>Access Modifiers</h3><p>Access modifiers are an important concept in programming as they control the visibility and accessibility of classes, methods, and variables. They determine what can be accessed from outside the module or class we are writing. In Java, there are four main access modifiers: private, public, protected, and default. Similarly, in Go (Golang), the concept is simplified by using the case of the first letter of the variable or method/function name to determine its visibility.</p><p>Java Access Modifiers:</p><p>1. <strong>Default</strong>: When no access modifier is defined, the default access level is used. It allows access only within the same package.</p><p>2. <strong>Private</strong>: The private access modifier restricts access to within the same class only. It is the most restrictive access level.</p><p>3. <strong>Public</strong>: The public access modifier allows access from any other class. It is the least restrictive access level.</p><p>4. <strong>Protected</strong>: The protected access modifier allows access within the same package and also to subclasses.</p><p>In Go, identifiers starting with an <strong>uppercase letter are exported</strong> (public) and those starting with a <strong>lowercase letter are not exported</strong> (private).</p><p>Example in Java:</p><pre>    class MyClass {<br>        int x; // default - accessible within the package<br>        private int y; // private - accessible within the class<br>        public int z; // public - accessible from anywhere<br>        protected int a; // protected - accessible within the package and sub classes<br>    }</pre><p>Golang</p><pre><br>    type MyStruct struct {<br>        X int // exported<br>        y int // not exported<br>    }<br><br>    func (m *MyStruct) MyMethod() { // exported<br>        // code<br>    }<br><br>    func (m *MyStruct) myMethod() { // not exported<br>        // code<br>    }</pre><h3>Key Differences and Takeaways</h3><ul><li><strong>Paradigm:</strong> Java focuses on object-oriented programming, while Go leans toward simplicity and structural composition.</li><li><strong>Memory Footprint:</strong> Go executables are smaller, making it suitable for microservices.</li><li><strong>Concurrency:</strong> Go’s goroutines are lightweight compared to Java’s threads.</li><li><strong>Learning Curve:</strong> Java developers may find Go’s lack of OOP and pointers challenging initially.</li></ul><p>Both Java and Go have their strengths and are suited to different scenarios. For a developer transitioning to Go, understanding these differences and adapting to Go’s minimalistic design can lead to building efficient, high-performance applications.</p><p>If you’re interested in diving deeper into collections in Golang, you can explore all the details in Part II of the series: <a href="https://medium.com/@saravanastar/learning-golang-with-a-java-background-a-developers-journey-part-ii-efbd9fbce470">Learning Golang with a Java Background — A Developer’s Journey — Part II</a>. This article focuses on arrays, slices, maps, and sets in Golang, comparing them to their Java counterparts to help developers transition seamlessly. Whether you’re curious about dynamic resizing with slices or how to simulate sets using maps, it’s all covered in the write-up. Check it out to enhance your understanding!</p><h3>Looking Ahead: Threads, Goroutines, and Channels</h3><p>This is the first part of my journey in comparing Java and Golang. In the next part, I will delve deeper into Java Threads and Go’s Goroutines and Channels. These constructs are vital for handling concurrency in both languages and reflect their unique philosophies in software design.</p><p>Stay tuned for an in-depth exploration of how Java’s multithreading model compares to Go’s lightweight goroutines, as well as how channels in Go simplify data communication between concurrent processes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3615aff8c983" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Uninterrupted System Availability for Seamless Operations]]></title>
            <link>https://saravanastar.medium.com/uninterrupted-system-availability-for-seamless-operations-0be9df62799b?source=rss-f1a83961ef09------2</link>
            <guid isPermaLink="false">https://medium.com/p/0be9df62799b</guid>
            <category><![CDATA[replication]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[availability]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[redundancy]]></category>
            <dc:creator><![CDATA[Saravanakumar Arunachalam]]></dc:creator>
            <pubDate>Wed, 15 May 2024 02:51:17 GMT</pubDate>
            <atom:updated>2024-05-16T01:51:59.398Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*aKavtviE6zfSM2CC2xtDBg@2x.jpeg" /></figure><p>Availability refers to the ability of a system to remain operational and produce expected results. It’s often measured as a percentage, such as 99.9%, 99.99%, or 99.999% uptime in public cloud systems. This availability is crucial for ensuring that services are consistently accessible to users without significant interruptions.</p><p>The formula to calculate uptime is:</p><p><strong>Availability=(Uptime​/Total hours)×100</strong></p><p>Designing a system for availability involves anticipating and mitigating potential failures. During the design process, it’s important to ask “What-If” questions to identify possible failure scenarios and plan appropriate solutions:</p><ul><li>What if requests overload a single system? Implement a load balancer to distribute the load.</li><li>What if there are too many write operations? Create read replicas to offload write traffic.</li><li>What if complex queries strain the system and database? Use caching mechanisms or optimize queries and database structures.</li><li>What if requests start queuing up? Implement connection pooling, scale app instances, optimize queries, or normalize tables and create indexes.</li></ul><p>System design often involves trade-offs, and choosing the right approach depends on the specific requirements and constraints. Below key topics are vital for attaining system availability.</p><h3>Redundancy/Replication</h3><p>One strategy for enhancing availability is redundancy or replication. This includes:</p><ol><li><strong>Hot Redundancy</strong>: Suitable for critical systems intolerant to failures. For instance, adding new application servers and load balancers to handle increased traffic.</li><li><strong>Warm Redundancy</strong>: Acts as a shadow mode for tolerating momentary failures, such as using database replicas that can be promoted in case of a failure(master/slave replication).</li><li><strong>Cold Redundancy</strong>: Acceptable for non-critical applications where downtime is acceptable, like storing backups in cost-effective services like S3 Glacier.</li></ol><h3><strong>Identifying the Fault</strong></h3><p>Identifying faults involves monitoring system health through mechanisms like heartbeats in distributed systems. Clusters of nodes communicate with each other, and if a node stops sending heartbeats, it’s considered faulty. Technologies like Kafka Zookeeper or load balancers use these signals to detect and respond to failures, such as choosing a new leader or avoiding sending traffic to a failed instance.</p><h3>Failover mechanisms</h3><p>Failover mechanisms are critical for system resilience. They involve strategies like promoting a read replica to the main instance in case of database failures, handling pod failures in Kubernetes clusters, or implementing DNS failover to redirect traffic to alternate systems if one fails.</p><p>By integrating redundancy, fault detection, and failover mechanisms into system design, we can enhance availability and ensure continuous operation even during unforeseen failures or disruptions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0be9df62799b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Performance Insights]]></title>
            <link>https://saravanastar.medium.com/performance-insights-e2243b70522e?source=rss-f1a83961ef09------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2243b70522e</guid>
            <category><![CDATA[health-systems]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[system]]></category>
            <dc:creator><![CDATA[Saravanakumar Arunachalam]]></dc:creator>
            <pubDate>Sun, 28 Apr 2024 01:59:46 GMT</pubDate>
            <atom:updated>2024-04-28T02:06:41.149Z</atom:updated>
            <content:encoded><![CDATA[<p>This article delves into the intricacies of application performance and the key factors that influence it. Performance refers to the efficiency with which a system operates under a given workload and hardware configuration. It’s a broad topic that encompasses various aspects, and this article aims to provide insights on how to approach performance optimization at a high level.</p><h3>Performance Metrics</h3><p>Two primary objectives are commonly used to measure system performance:</p><ol><li>Latency</li><li>Throughput</li></ol><p>1. <strong>Latency</strong></p><p>Latency, in the context of a client-server application, refers to the time it takes for the server to accept a request and for the client to receive a response. In simpler terms, it can be calculated as:</p><p><strong>Latency </strong>= <em>Response Time − Processing Time</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*tpHPPViwqHd4jEcZgMIMqQ.png" /><figcaption>Latency</figcaption></figure><p>Why does Latency happen?</p><p>Latency can occur due to various reasons:</p><ul><li><strong>Insufficient Resources</strong>: When the system lacks the necessary resources to handle the workload efficiently, leading to delays in processing requests.</li><li><strong>Slow Performance</strong>: Even with adequate hardware, if the components operate sluggishly, it can impact overall system responsiveness.</li><li><strong>Sequential Access</strong>: When sequentially accessing resources causes bottlenecks and delays, akin to a queue forming at a single billing station in a shop.</li></ul><p>2. <strong>Throughput</strong></p><p>Throughput measures the system’s ability to handle concurrent requests. It is directly influenced by latency; an increase in latency can reduce the number of concurrent requests that can be processed efficiently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/231/1*6wSeqdYd_ea9QtVvfsOa_w.png" /><figcaption>Throughput</figcaption></figure><blockquote><strong>Improving Performance</strong></blockquote><p>To enhance application performance, the focus should be given to improving latency, throughput, and overall capacity:</p><ol><li><strong>Efficiency</strong>: Enhance resource utilization efficiency to improve <strong>latency</strong>.</li><li><strong>Concurrency</strong>: Handle concurrent requests effectively to improve <strong>throughput</strong>.</li><li><strong>Capacity</strong>: Scale resources dynamically based on workload demands.</li></ol><h3><strong>Efficiency</strong></h3><p>Efficiency in resource utilization and optimizing various components helps increase the system&#39;s performance.</p><ul><li><strong>CPU</strong>: Minimize context switching and optimize code to efficient algorithm.</li><li><strong>Memory/Disk</strong>: Utilize asynchronous log writing, efficient DB queries, and caching strategies.</li><li><strong>Network</strong>: Utilize persistent connections, SSL caching, and compression techniques.</li><li><strong>Efficient Algorithm/DB Query</strong>: Develop optimized logic, utilize connection pooling, and optimize database queries</li><li><strong>Database Efficiency</strong>: Focus on database schemas, normalization, and implement caching for frequently accessed data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*Ciq7k0CpxRvhBPjNHYVlEA.png" /></figure><h3><strong>Concurrency: Enhancing Throughput for Improved Performance</strong></h3><p>Once we’ve tackled the latency of individual requests, the next step is to focus on enhancing throughput by handling concurrent requests efficiently. Concurrency involves processing multiple requests in parallel, which can introduce queuing and resource contention challenges, particularly with network, CPU, and disk resources.</p><p><strong>Challenges with Concurrency</strong></p><p>When dealing with concurrent requests, several challenges may arise:</p><ol><li><strong>Queuing</strong>: Concurrent requests can lead to queuing, where requests wait in line to be processed.</li><li><strong>Resource Contention</strong>: Resources like network bandwidth, CPU processing power, and disk access may face contention issues when multiple requests compete for them simultaneously.</li></ol><p><strong>Strategies for Handling Concurrency</strong></p><p>To address these challenges and improve throughput, various strategies can be implemented:</p><ol><li><strong>Thread Pool</strong>: Utilize a thread pool in web servers to manage and allocate threads efficiently, allowing for concurrent request processing without overwhelming system resources.</li><li><strong>Vertical Scaling</strong>: Increase CPU resources (vertical scaling) to handle more concurrent requests effectively.</li><li><strong>Connection Pooling</strong>: Implement connection pooling in databases to efficiently manage database connections and reduce overhead in handling concurrent database requests.</li><li><strong>Locking Techniques</strong>: Use locking techniques such as optimistic and pessimistic locking to manage concurrent access to shared resources, ensuring data integrity and preventing conflicts.</li></ol><h3><strong>Capacity Planning</strong></h3><p>Capacity planning involves ensuring the system can handle both expected and unexpected loads effectively. Once we’ve optimized latency and throughput for expected loads, scaling the system becomes crucial when unexpected surges occur.</p><p><strong>Scalability in the Cloud</strong></p><p>Moving to the cloud provides scalability advantages, allowing us to scale system capacity dynamically based on workload demands. Similar to how a shop needs to increase sales personnel during peak hours, scaling our system in the cloud enables us to handle sudden increases in traffic or workload efficiently.</p><p>By implementing strategies for concurrency management and having a scalable architecture, we can enhance system performance, responsiveness, and overall user experience, even during periods of high demand or unexpected load spikes.</p><p>By addressing these factors comprehensively, applications can achieve better performance, responsiveness, and scalability to meet user demands effectively.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2243b70522e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices simplified]]></title>
            <link>https://saravanastar.medium.com/microservices-simplified-84b6dfa2dd83?source=rss-f1a83961ef09------2</link>
            <guid isPermaLink="false">https://medium.com/p/84b6dfa2dd83</guid>
            <category><![CDATA[decomposition]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Saravanakumar Arunachalam]]></dc:creator>
            <pubDate>Fri, 22 Mar 2024 15:30:12 GMT</pubDate>
            <atom:updated>2024-03-22T15:51:09.854Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*Aimjf2z3ePfCiSAHJiQQjw.jpeg" /><figcaption>microservices</figcaption></figure><h4>Problem Statement</h4><p>As our customer base continues to expand, there is a pressing need to expedite customer requests. Scaling the application to meet this demand effectively is crucial. However, scaling the monolithic application poses significant challenges.</p><h4>Understanding Microservices Architecture</h4><p>Microservices architecture is a concept that has gained traction in recent years, but its essence remains simple: breaking down larger services into smaller, more manageable components. This architectural style aims to address the increasing demands of user workloads by creating smaller, more specialized services.</p><h4>Simplicity in Complexity</h4><p>At its core, microservices architecture involves dividing a larger service-oriented architecture into smaller, more focused components. Despite the buzz surrounding microservices, it’s essential not to overcomplicate the concept. Essentially, it’s about breaking down complex systems into smaller, more manageable pieces.</p><h4>Application in Real-Life Scenarios</h4><p>Consider the analogy of delivering food in a metropolitan area. Instead of using a large truck, opting for smaller vehicles like cars or bicycles may enable quicker navigation through traffic and faster delivery times. Similarly, microservices allow for more efficient handling of user requests, optimizing latency and throughput based on growing user bases</p><h4>Roles of Microservices</h4><p>In the microservices landscape, various roles serve specific functions:</p><ul><li><strong>Data Service</strong>: Connects data sources and provides data to dependent services.</li><li><strong>Business Service</strong>: Houses all business logic, including validation and transaction handling.</li><li><strong>Translation Service</strong>: Translates business objects into formats understandable to client applications.</li><li><strong>Edge Service</strong>: Acts as a gateway or proxy, enabling clients to connect to different microservices seamlessly.</li></ul><h4>Design Principles</h4><p>Several design principles guide the creation, integration, and maintenance of microservices:</p><h4>Decomposition Principles:</h4><ul><li><strong>Domain-Driven Design (DDD)</strong>: Focuses on designing subdomains within larger business domains, creating services and models for access.</li><li><strong>Strangler</strong>: Involves gradually migrating smaller components from a monolithic application to microservices.</li><li><strong>Business Process Aggregator</strong>: Combines related business services into a single service for specific use cases.</li><li><strong>Sidecar</strong>: Supports the main application by extracting components and deploying them as dependent applications within the same instance.</li></ul><p><strong>Integration Principles</strong>:</p><ul><li><strong>Gateway</strong>: Acts as an entry and exit point for connecting with microservices, simplifying client connections.</li><li><strong>Aggregator</strong>: Gathers data from multiple services and returns aggregated results to clients.</li><li><strong>Edge Pattern</strong>: Serves traffic at the network edge, such as Content Delivery Networks (CDNs).</li></ul><p><strong>Data Principles:</strong></p><ul><li><strong>Single DB</strong>: Each microservice connects to a single database, aiding scalability.</li><li><strong>Shared DB</strong>: Multiple microservices connect to the same database with different schema sets, simplifying initial setups.</li><li><strong>CQRS and Event Sourcing</strong>: Microservices communicate asynchronously through events.</li></ul><p><strong>Operational Aspects</strong>: Maintaining microservices requires additional effort in observability, alerting, documentation, service discovery, and continuous delivery. These operational aspects ensure better user experiences and necessitate measures like logging, metrics, and tracing tools such as Splunk, Datadog, and Dynatrace.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84b6dfa2dd83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[gRPC with Java]]></title>
            <link>https://saravanastar.medium.com/grpc-with-java-957ef5114a97?source=rss-f1a83961ef09------2</link>
            <guid isPermaLink="false">https://medium.com/p/957ef5114a97</guid>
            <category><![CDATA[grpc-java]]></category>
            <category><![CDATA[http2]]></category>
            <category><![CDATA[grpc]]></category>
            <dc:creator><![CDATA[Saravanakumar Arunachalam]]></dc:creator>
            <pubDate>Sun, 03 Jul 2022 22:00:25 GMT</pubDate>
            <atom:updated>2022-07-05T15:35:02.608Z</atom:updated>
            <content:encoded><![CDATA[<p>Would like to share my learning with you all about the gRPC. There are so many articles around the internet about the why gRPC and when to use that. Just want to showcase here how to implement gRPC server using java.</p><p>Maven as package manager and find its dependency below.</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;io.grpc&lt;/groupId&gt;<br>    &lt;artifactId&gt;grpc-netty-shaded&lt;/artifactId&gt;<br>    &lt;version&gt;${grpc.version}&lt;/version&gt;<br>    &lt;scope&gt;runtime&lt;/scope&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;io.grpc&lt;/groupId&gt;<br>    &lt;artifactId&gt;grpc-protobuf&lt;/artifactId&gt;<br>    &lt;version&gt;${grpc.version}&lt;/version&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;io.grpc&lt;/groupId&gt;<br>    &lt;artifactId&gt;grpc-stub&lt;/artifactId&gt;<br>    &lt;version&gt;${grpc.version}&lt;/version&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;<br>    &lt;artifactId&gt;annotations-api&lt;/artifactId&gt;<br>    &lt;version&gt;6.0.53&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>Below is the maven plugin configuration to generate the java class from the proto file. It is similar like SOAP Web service, generating stub classes and use it wherever we need to use either client or server.</p><pre>&lt;build&gt;<br>  &lt;extensions&gt;<br>    &lt;extension&gt;<br>      &lt;groupId&gt;kr.motd.maven&lt;/groupId&gt;<br>      &lt;artifactId&gt;os-maven-plugin&lt;/artifactId&gt;<br>      &lt;version&gt;1.6.2&lt;/version&gt;<br>    &lt;/extension&gt;<br>  &lt;/extensions&gt;<br>  &lt;plugins&gt;<br>    &lt;plugin&gt;<br>      &lt;groupId&gt;org.xolstice.maven.plugins&lt;/groupId&gt;<br>      &lt;artifactId&gt;protobuf-maven-plugin&lt;/artifactId&gt;<br>      &lt;version&gt;0.6.1&lt;/version&gt;<br>      &lt;configuration&gt;<br>        &lt;protocArtifact&gt;com.google.protobuf:protoc:3.19.2:exe:${os.detected.classifier}&lt;/protocArtifact&gt;<br>        &lt;pluginId&gt;grpc-java&lt;/pluginId&gt;<br>        &lt;pluginArtifact&gt;io.grpc:protoc-gen-grpc-java:1.47.0:exe:${os.detected.classifier}&lt;/pluginArtifact&gt;<br>      &lt;/configuration&gt;<br>      &lt;executions&gt;<br>        &lt;execution&gt;<br>          &lt;goals&gt;<br>            &lt;goal&gt;compile&lt;/goal&gt;<br>            &lt;goal&gt;compile-custom&lt;/goal&gt;<br>          &lt;/goals&gt;<br>        &lt;/execution&gt;<br>      &lt;/executions&gt;<br>    &lt;/plugin&gt;<br>  &lt;/plugins&gt;<br>&lt;/build&gt;</pre><p>Referenced the above configuration from the github repo <a href="https://github.com/grpc/grpc-java">https://github.com/grpc/grpc-java</a></p><p>Please check it out the reference link for the grpc maven plugin <a href="https://www.xolstice.org/protobuf-maven-plugin/usage.html">https://www.xolstice.org/protobuf-maven-plugin/usage.html</a></p><p>Find the steps below for the gRPC service creation process</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z94VRzp6tRig72rX" /><figcaption>protobuf process</figcaption></figure><h3><strong>Defining the proto</strong></h3><p>Let us design the user service to add, get and find all user related data. Find the sample proto file below for the same.</p><p><a href="https://grpc.io/docs/what-is-grpc/introduction/">https://grpc.io/docs/what-is-grpc/introduction/</a></p><pre>syntax = &quot;proto3&quot;;<br>package com.ask.grpc;<br><br>option java_package = &quot;com.ask.grpc.proto&quot;;<br>option java_generic_services = true;<br>option java_outer_classname = &quot;UserDetailProto&quot;;<br>option java_multiple_files = true;<br>import &quot;google/protobuf/empty.proto&quot;;<br><br>service UserService {<br>  rpc save(User) returns (User) {}<br>  rpc get(User) returns (User) {}<br>  rpc findAll (google.protobuf.Empty) returns (stream User) {}<br>}<br><br>message User {<br>  string id = 1;<br>  string name = 2;<br>  string email = 3;<br>  optional int32 age = 4;<br>  repeated Address addresses = 5;<br>}<br><br>message Address {<br>  string address1 = 1;<br>  string address2 = 2;<br>  string state = 3;<br>  string city = 4;<br>  string country = 5;<br>  string phoneNumber = 6;<br>  PhoneType phoneType = 7;<br>}<br>enum PhoneType {<br>  <em>MOBILE </em>= 0;<br>  <em>HOME </em>= 1;<br>}</pre><h3><strong>Proto compilation and Stub Generation</strong></h3><p>As already added the above plugin, run the below maven command to generate the java class for the grpc proto</p><blockquote>mvn clean install</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*jPTEShqMm6azKucGZvKiqQ.png" /><figcaption>grpc stub generation</figcaption></figure><p>Stubs are generated and use the Stub classes and implement the changes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aW41RoZNC7__e2OF-RJhBg.png" /></figure><p>To implement the user service, just used the HashMap to store and retrieve the user details for the simplicity.</p><h3><strong>Implement gRPC Server</strong></h3><p>Creating the gRPC server with UserService on the port 8080.</p><pre>package com.ask.grpc;<br><br><br>import com.ask.grpc.service.UserServiceImpl;<br>import io.grpc.Server;<br>import io.grpc.ServerBuilder;<br><br>import java.io.IOException;<br><br>public class Application {<br><br>  public static void main(String[] args) throws InterruptedException, IOException {<br><br>    final Server server = ServerBuilder.<em>forPort</em>(8080).addService(new UserServiceImpl()).build();<br>    Runtime.<em>getRuntime</em>()<br>        .addShutdownHook(<br>            new Thread(<br>                () -&gt; {<br>                  server.shutdown();<br>                  System.<em>out</em>.println(&quot;Successfully stopped the server&quot;);<br>                }));<br>    server.start();<br>    System.<em>out</em>.println(&quot;Server started&quot;);<br>    server.awaitTermination();<br>  }<br>}</pre><h3><strong>gRPC Client</strong></h3><p>To invoke the gRPC server, used the Bloom-rpc as a client.</p><p>installation details are in the link <a href="https://github.com/bloomrpc/bloomrpc">https://github.com/bloomrpc/bloomrpc</a></p><p>Let’s load the proto file into the client and invoke the gRPC server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJVKv4q4m6RCQ7tue6SbZw.png" /><figcaption>Bloom-GRPC client</figcaption></figure><p>Detailed code in the following repo <a href="https://github.com/saravanastar/grpc-java">https://github.com/saravanastar/grpc-java</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=957ef5114a97" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>