<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Experiments on Programmer's Insight</title><link>https://blog.ganapathy.xyz/experiments/</link><description>Recent content in Experiments on Programmer's Insight</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 02 Mar 2025 00:15:42 -0800</lastBuildDate><atom:link href="https://blog.ganapathy.xyz/experiments/index.xml" rel="self" type="application/rss+xml"/><item><title>Service Mesh Implementation for Go Microservices</title><link>https://blog.ganapathy.xyz/2025/03/service-mesh-implementation-for-go.html</link><pubDate>Mon, 07 Mar 2022 00:15:00 -0800</pubDate><guid>https://blog.ganapathy.xyz/2025/03/service-mesh-implementation-for-go.html</guid><description>&lt;h1&gt;&amp;nbsp;Introduction&lt;/h1&gt;&#10;&lt;p&gt;As microservice architectures grow in complexity, the challenges of service-to-service communication become increasingly difficult to solve at the application level. Service meshes have emerged as a powerful solution to these challenges, providing a dedicated infrastructure layer to handle network communication between services while offering features like load balancing, service discovery, traffic management, security, and observability.&lt;/p&gt;&#10;&lt;p&gt;Over the past year, I've been implementing and optimizing service mesh solutions for Go microservices in production environments. In this article, I'll share practical insights on implementing service meshes for Go applications, comparing popular options like Istio and Linkerd, and demonstrating how to configure and optimize them for production use.&lt;/p&gt;</description></item><item><title>Event-Driven Architecture with Go and Kafka</title><link>https://blog.ganapathy.xyz/2021/10/event-driven-architecture-with-go-and.html</link><pubDate>Wed, 20 Oct 2021 11:00:00 -0700</pubDate><guid>https://blog.ganapathy.xyz/2021/10/event-driven-architecture-with-go-and.html</guid><description>&lt;h1&gt;Introduction&lt;/h1&gt;&#10;&lt;p&gt;As systems grow in complexity and scale, traditional request-response architectures often struggle to meet demands for scalability, resilience, and flexibility. Event-driven architecture (EDA) has emerged as a powerful pattern to address these challenges, enabling systems to react to changes in state through the production, detection, and consumption of events.&lt;/p&gt;&#10;&lt;p&gt;Over the past year, I've been designing and implementing event-driven systems using Go and Apache Kafka for several high-throughput applications. In this article, I'll share practical insights on building event-driven architectures with Go, covering event sourcing concepts, reliable message processing, handling schema evolution, and implementing exactly-once semantics.&lt;/p&gt;</description></item><item><title>Building Observability into Go Microservices</title><link>https://blog.ganapathy.xyz/2020/05/building-observability-into-go.html</link><pubDate>Tue, 19 May 2020 01:00:00 -0700</pubDate><guid>https://blog.ganapathy.xyz/2020/05/building-observability-into-go.html</guid><description>&lt;h1&gt;&amp;nbsp;Introduction&lt;/h1&gt;&#10;&lt;p&gt;As organizations adopt microservice architectures, the complexity of their systems increases dramatically. Instead of monitoring a single monolithic application, teams now need to track the health and performance of dozens or even hundreds of distributed services. This shift has made observability not just nice-to-have but essential for operating reliable systems.&lt;/p&gt;&#10;&lt;p&gt;Observability refers to the ability to understand the internal state of a system based on its external outputs. In the context of microservices, this means having visibility into what's happening within and between services, being able to identify issues quickly, and understanding the impact of changes or failures.&lt;/p&gt;</description></item><item><title>Advanced Testing Strategies for Go Microservices</title><link>https://blog.ganapathy.xyz/2020/01/advanced-testing-strategies-for-go.html</link><pubDate>Mon, 27 Jan 2020 12:30:00 -0800</pubDate><guid>https://blog.ganapathy.xyz/2020/01/advanced-testing-strategies-for-go.html</guid><description>&lt;h1&gt;Introduction&lt;/h1&gt;&#10;&lt;p&gt;As microservice architectures continue to gain popularity, testing these distributed systems has become increasingly complex. Unlike monolithic applications where most functionality lives within a single codebase, microservices involve numerous small, independently deployable services that communicate over the network. This distribution introduces new testing challenges including network reliability, service versioning, and environment consistency.&lt;/p&gt;&#10;&lt;p&gt;Go has emerged as a popular language for building microservices due to its performance, concurrency model, and simple deployment. However, to build reliable, production-ready microservices in Go, a comprehensive testing strategy is essential. Over the past year, I've helped organizations improve their microservice testing approaches, and in this article, I'll share advanced testing strategies that go beyond basic unit testing.&lt;/p&gt;</description></item><item><title>Implementing gRPC Services in Go</title><link>https://blog.ganapathy.xyz/2019/11/implementing-grpc-services-in-go.html</link><pubDate>Mon, 18 Nov 2019 18:30:00 -0800</pubDate><guid>https://blog.ganapathy.xyz/2019/11/implementing-grpc-services-in-go.html</guid><description>&lt;h1&gt;Introduction&lt;/h1&gt;&#10;&lt;p&gt;As microservice architectures have gained prominence, the need for efficient, type-safe, and language-agnostic communication between services has become increasingly important. While REST APIs with JSON have been the dominant approach for service-to-service communication, they come with limitations: lack of strict typing, inefficient text-based serialization, and no built-in support for streaming.&lt;/p&gt;&#10;&lt;p&gt;gRPC, developed by Google, addresses these limitations by providing a high-performance, open-source RPC (Remote Procedure Call) framework. Based on Protocol Buffers (protobuf) for interface definition and binary serialization, gRPC offers significant advantages for microservice communication.&lt;/p&gt;</description></item><item><title>Building a Distributed Task Queue in Go</title><link>https://blog.ganapathy.xyz/2018/03/building-distributed-task-queue-in-go.html</link><pubDate>Tue, 27 Mar 2018 13:00:00 -0700</pubDate><guid>https://blog.ganapathy.xyz/2018/03/building-distributed-task-queue-in-go.html</guid><description>&lt;p&gt;&lt;br&gt;&lt;/p&gt;&#10;&lt;h1&gt;Introduction&lt;/h1&gt;&#10;&lt;p&gt;As applications scale and architectures become more distributed, the need for reliable background processing becomes increasingly important. Task queues (also known as job queues) allow applications to offload time-consuming or resource-intensive operations from the main request-handling flow, improving responsiveness and scalability.&lt;/p&gt;&#10;&lt;p&gt;Over the past three years of working with Go, I've implemented several task processing systems for different use cases. In this article, I'll share the patterns and practices I've found effective for building distributed task queues in Go, covering architecture design, messaging systems integration, worker pool implementation, error handling, and approaches for ensuring reliability in distributed environments.&lt;/p&gt;</description></item><item><title>Building Microservices with Go: First Steps</title><link>https://blog.ganapathy.xyz/2015/10/building-microservices-with-go-first.html</link><pubDate>Fri, 30 Oct 2015 23:00:00 -0700</pubDate><guid>https://blog.ganapathy.xyz/2015/10/building-microservices-with-go-first.html</guid><description>&lt;h1&gt;Introduction&lt;/h1&gt;&#10;&lt;p&gt;The microservices architectural style has gained significant popularity in recent years as organizations seek to build more scalable, resilient, and maintainable systems. Unlike monolithic applications where all functionality is packaged into a single unit, microservices architecture breaks down applications into smaller, independently deployable services that communicate over well-defined APIs.&lt;/p&gt;&#10;&lt;p&gt;Go (or Golang) has emerged as an excellent language for building microservices due to its performance characteristics, small memory footprint, built-in concurrency support, and comprehensive standard library. After exploring Go's concurrency model earlier this year, I've spent the past several months applying these concepts to build microservices, and I'd like to share my experiences and insights.&lt;/p&gt;</description></item><item><title>Self Modifying Code</title><link>https://blog.ganapathy.xyz/2013/04/self-modifying-code.html</link><pubDate>Wed, 17 Apr 2013 19:52:00 -0700</pubDate><guid>https://blog.ganapathy.xyz/2013/04/self-modifying-code.html</guid><description>&lt;div&gt;&#10;Sorry guys. It's been a while. I'm near the end of Spring Semester with hectic things ahead.&lt;br&gt;&#10;In the mean time, I thought I would post something for us to chew.&lt;br&gt;&#10;&lt;br&gt;&#10;Okay this post is about Self Modifying Code which I came across recently in my course work&lt;br&gt;&#10;where there was a line "The issues with Binary Translation (VMM) is Self Modifying Code".&lt;br&gt;&#10;&lt;br&gt;&#10;&amp;nbsp;Lets not look into VMM aspects, rather I shall restrict myself to the later.&lt;br&gt;&#10;&lt;br&gt;&#10;What is Self Modifying Code?&lt;br&gt;&#10;&lt;br&gt;&#10;Program that purposely alters its own instructions while executing.&lt;br&gt;&#10;Something like a chameleon :-)&lt;br&gt;&#10;&lt;br&gt;&#10;If we write a code that improperly manipulates a buffer then its a self modifying code :-) leading to crash.&lt;br&gt;&#10;&lt;br&gt;&#10;Questions arise as to why we need this kind of code for which I would suggest to read the &lt;a href="http://en.wikipedia.org/wiki/Self-modifying_code" rel="noopener noreferrer"&gt;wikipedia&lt;/a&gt; article for its usages.&lt;br&gt;&#10;&lt;br&gt;&#10;Of-course one can use this to create viruses ! making life difficult for anti-virus programs / honeypots.&lt;br&gt;&#10;&lt;br&gt;&#10;It is not the code that gets changed [ Of course it needs to :-) ] but the executable that needs to change while its running. This restricts us to OS specific.&lt;br&gt;&#10;&lt;br&gt;&#10;Say suppose we have a program emitting some output. Now lets open the executable using &lt;br&gt;&#10;hex editor, modify the executable to emit a different one.&lt;br&gt;&#10;&lt;br&gt;&#10;If we see windows updates, its evident that program which is in execution is closed, re-written and started again. Can't this be done while the program is in execution?&lt;br&gt;&#10;&lt;br&gt;&#10;Consider a huge deployment where there is a small bug with respect to your component.&lt;br&gt;&#10;The fix is just adding a check or changing some macro.&lt;br&gt;&#10;&lt;br&gt;&#10;Instead of rebuilding the entire component,&amp;nbsp; is it possible to write a small piece of code ( a function ) which could tweak into image of running file and fixes the bug by altering it.&lt;br&gt;&#10;This would be of great help. isn't it ? :-)&lt;br&gt;&#10;&lt;br&gt;&#10;So how do we do it?&amp;nbsp; I'm also trying it.&lt;br&gt;&#10;In the mean time, you guys too can try.&lt;br&gt;&#10;&lt;br&gt;&#10;Lets state our objective&lt;br&gt;&#10;&lt;br&gt;&#10;a) We know the operating system where our "*.so || *.exe || *.sl" is running.&lt;br&gt;&#10;b) Our objective is to tweak this executable for a minor fix that was found in site deployment.&lt;br&gt;&#10;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Note : we are not supposed to restart the process]&lt;br&gt;&#10;&lt;br&gt;&#10;Have fun while trying :)&lt;br&gt;&#10;&lt;br&gt;&lt;/div&gt;</description></item><item><title>Nitty-Gritty Things - 1</title><link>https://blog.ganapathy.xyz/2013/03/nitty-gritty-things-1.html</link><pubDate>Sat, 23 Mar 2013 10:53:00 -0700</pubDate><guid>https://blog.ganapathy.xyz/2013/03/nitty-gritty-things-1.html</guid><description>&lt;div&gt;&#10;In this blog lets talk about some nitty-gritty implementation stuffs.&lt;br&gt;&#10;&lt;br&gt;&#10;Okay. So assuming the reader knows C/C++&lt;br&gt;&#10;&lt;br&gt;&#10;a) How to add time restrictions to user input?&lt;br&gt;&#10;&lt;br&gt;&#10;To elaborate, we know in C, the user input is read using scanf/getc/getchar and in C++ using cin object.&lt;br&gt;&#10;&lt;br&gt;&#10;So our objective is to add some time limit so that user inputs the value before the timeout.&lt;br&gt;&#10;&lt;br&gt;&#10;a) You can do by calling a script written in bash/python etc from C code and evaluate.&lt;br&gt;&#10;b) May be create a thread and fire the thread when timeout happens.&lt;br&gt;&#10;&lt;br&gt;&#10;Is there any other way? &amp;lt;Think before scrolling down&amp;gt;&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;. &lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;a href="http://www.gnu.org/software/libc/manual/html_node/Setting-an-Alarm.html" rel="noopener noreferrer"&gt;http://www.gnu.org/software/libc/manual/html_node/Setting-an-Alarm.html&lt;/a&gt;&lt;br&gt;&#10;&lt;a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/alarm.html" rel="noopener noreferrer"&gt;http://pubs.opengroup.org/onlinepubs/009695399/functions/alarm.html&lt;/a&gt; &lt;br&gt;&#10;&lt;br&gt;&#10;After reading the above links, I came up with this.&lt;br&gt;&#10;&lt;br&gt;&#10;#include&amp;lt;stdio.h&amp;gt;&lt;br&gt;&#10;#include&amp;lt;unistd.h&amp;gt;&lt;br&gt;&#10;&lt;br&gt;&#10;#define TIMEOUT 5&lt;br&gt;&#10;int main()&lt;br&gt;&#10;{&lt;br&gt;&#10;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int t_iTemp;&lt;br&gt;&#10;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while( alarm(TIMEOUT), ( t_iTemp = getchar() ) != EOF )&lt;br&gt;&#10;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&#10;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putchar(t_iTemp);&lt;br&gt;&#10;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&#10;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br&gt;&#10;&lt;br&gt;&#10;}&lt;br&gt;&#10;&lt;br&gt;&#10;This program waits for 5 secs. If user doesn't input anything, it exits else just echoes the input&lt;br&gt;&#10;and waits for next 5 secs.&lt;br&gt;&#10;&lt;br&gt;&#10;The idea is simple i.e to generate a signal based on timer.&lt;br&gt;&#10;But the important takeaway is about alarm function.&lt;br&gt;&lt;br&gt;Okay lets see one more.&lt;br&gt;&#10;&lt;br&gt;&#10;b) Say you are developing a clock app. Now you will have conditions for hours,seconds,mins etc&lt;br&gt;&#10;&lt;br&gt;&#10;The thing we will talk is how do you display 00 when the clock moves from 59 in case of mins/secs and 23 in case of hour.&lt;br&gt;&#10;&lt;br&gt;&#10;When we think about it, its nothing but printing "00". But remember here we are talking about numbers :-)&lt;br&gt;&#10;&lt;br&gt;&#10;What happens when you assign 00 to a integer and print it. It should be printing 0 instead of 00.&lt;br&gt;&#10;So how do you print an integer as 00. This is what we will be talking.&lt;br&gt;&#10;&lt;br&gt;&#10;&amp;lt;Think before scrolling&amp;gt;&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;..&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;..&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;.&lt;br&gt;&#10;&lt;br&gt;&#10;You can use a format specifier :D&lt;br&gt;&#10;&lt;br&gt;&#10;int a = 00;&lt;br&gt;&#10;printf("%d",a) -&amp;gt; 0&lt;br&gt;&#10;printf("%02d",a) -&amp;gt; 00 &lt;br&gt;&#10;&lt;br&gt;&#10;However there are functions which can replicate a given number/character which is the takeaway.&lt;br&gt;&#10;Check the below link. &lt;br&gt;&#10;&lt;a href="http://www.cplusplus.com/reference/iomanip/setfill/" rel="noopener noreferrer"&gt;http://www.cplusplus.com/reference/iomanip/setfill/&lt;/a&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp;int hrs = 0;&lt;br&gt;&#10;&amp;nbsp;cout&amp;lt;&amp;lt;setw(2)&amp;lt;&amp;lt;setfill('0')&amp;lt;&amp;lt;hrs&amp;lt;&amp;lt;endl; &lt;br&gt;&#10;&lt;br&gt;&#10;Hope you enjoyed reading and got something out of it.&lt;br&gt;&#10;Please post comments/suggestions(if any).&lt;/div&gt;</description></item></channel></rss>