<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Distributed-Systems on Rafiul Alam</title>
    <link>https://alamrafiul.com/tags/distributed-systems/</link>
    <description>Recent content in Distributed-Systems on Rafiul Alam</description>
    <image>
      <title>Rafiul Alam</title>
      <url>https://alamrafiul.com/papermod-cover.png</url>
      <link>https://alamrafiul.com/papermod-cover.png</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Mon, 23 Mar 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://alamrafiul.com/tags/distributed-systems/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Building Real-World Event Streaming Systems with Go and Kafka</title>
      <link>https://alamrafiul.com/posts/golang-kafka-practical-guide/</link>
      <pubDate>Mon, 23 Mar 2026 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/golang-kafka-practical-guide/</guid>
      <description>A practical, hands-on guide to Apache Kafka with Go — covering producers, consumers, consumer groups, and three real-world use cases: e-commerce order processing, real-time analytics, and microservices event coordination.</description>
    </item>
    
    <item>
      <title>Messaging Systems: A Visual Reference</title>
      <link>https://alamrafiul.com/posts/messaging-systems-visual-guide/</link>
      <pubDate>Mon, 23 Mar 2026 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/messaging-systems-visual-guide/</guid>
      <description>15 messaging scenarios with increasing complexity — Kafka, RabbitMQ, and JetStream NATS compared through diagrams. Less words, more architecture.</description>
    </item>
    
    <item>
      <title>Caching Strategies: A Visual Guide</title>
      <link>https://alamrafiul.com/posts/caching-strategies-visual-guide/</link>
      <pubDate>Sun, 15 Mar 2026 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/caching-strategies-visual-guide/</guid>
      <description>Visual deep dive into caching strategies — cache-aside, write-through, write-behind, read-through, eviction policies, and distributed caching explained through Mermaid diagrams with incremental complexity.</description>
    </item>
    
    <item>
      <title>Distributed Transactions: A Visual Guide</title>
      <link>https://alamrafiul.com/posts/distributed-transactions-visual-guide/</link>
      <pubDate>Fri, 13 Mar 2026 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/distributed-transactions-visual-guide/</guid>
      <description>Visual deep dive into distributed transactions — Two-Phase Commit, Three-Phase Commit, Saga patterns, and compensation strategies explained through Mermaid diagrams with incremental complexity.</description>
    </item>
    
    <item>
      <title>Distributed Storage: A Visual Guide</title>
      <link>https://alamrafiul.com/posts/distributed-storage-visual-guide/</link>
      <pubDate>Wed, 11 Mar 2026 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/distributed-storage-visual-guide/</guid>
      <description>Visual deep dive into distributed storage — replication strategies, partitioning schemes, consistent hashing, and data placement explained through Mermaid diagrams with incremental complexity.</description>
    </item>
    
    <item>
      <title>Consensus Algorithms: A Visual Guide</title>
      <link>https://alamrafiul.com/posts/consensus-algorithms-visual-guide/</link>
      <pubDate>Mon, 09 Mar 2026 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/consensus-algorithms-visual-guide/</guid>
      <description>Visual deep dive into consensus algorithms — Raft leader election, log replication, Paxos prepare-accept, and Multi-Paxos optimizations explained through Mermaid diagrams with incremental complexity.</description>
    </item>
    
    <item>
      <title>Building Resilient Workflows with Temporal.io: A Coffee Shop Tutorial</title>
      <link>https://alamrafiul.com/blogs/temporal-coffee-shop-workflow/</link>
      <pubDate>Sat, 22 Nov 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/blogs/temporal-coffee-shop-workflow/</guid>
      <description>&lt;p&gt;Building reliable distributed systems is challenging. Network failures, service outages, and unexpected errors can leave your workflows in inconsistent states. What if there was a way to build workflows that are inherently resilient, automatically handling retries, timeouts, and state management?&lt;/p&gt;
&lt;p&gt;Enter &lt;strong&gt;Temporal.io&lt;/strong&gt; - a workflow orchestration platform that makes building reliable distributed applications dramatically easier. In this comprehensive tutorial, we&amp;rsquo;ll build a coffee shop ordering system that demonstrates Temporal&amp;rsquo;s powerful capabilities.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>The Token Ring: Fair Resource Access Through Token Passing</title>
      <link>https://alamrafiul.com/blogs/token-ring/</link>
      <pubDate>Mon, 10 Nov 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/blogs/token-ring/</guid>
      <description>&lt;h2 id=&#34;the-token-ring-problem&#34;&gt;The Token Ring Problem&lt;/h2&gt;
&lt;p&gt;The Token Ring is a classic distributed mutual exclusion algorithm where nodes are arranged in a logical ring, and a single token circulates. Only the node holding the token can access the shared resource. It&amp;rsquo;s simple, fair, and starvation-free.&lt;/p&gt;
&lt;h2 id=&#34;the-scenario&#34;&gt;The Scenario&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Nodes arranged in a ring:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;N nodes form a logical ring&lt;/li&gt;
&lt;li&gt;A single token passes around the ring&lt;/li&gt;
&lt;li&gt;Only token holder can enter critical section&lt;/li&gt;
&lt;li&gt;After using resource, pass token to next node&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Properties&lt;/strong&gt;: Fair (FIFO order), no starvation, deadlock-free&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;The challenge:&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>The Gossiping Problem: Efficient Information Spreading</title>
      <link>https://alamrafiul.com/blogs/gossiping-problem/</link>
      <pubDate>Wed, 29 Oct 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/blogs/gossiping-problem/</guid>
      <description>&lt;h2 id=&#34;the-gossiping-problem&#34;&gt;The Gossiping Problem&lt;/h2&gt;
&lt;p&gt;The Gossiping Problem is a classic problem in distributed systems and graph theory. N people each know a unique secret, and they share information through phone calls. On each call, both parties share all secrets they know. The goal: find the minimum number of calls needed for everyone to know all secrets.&lt;/p&gt;
&lt;h2 id=&#34;the-scenario&#34;&gt;The Scenario&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;N people, N secrets:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Person i knows secret Si initially&lt;/li&gt;
&lt;li&gt;When persons i and j call each other, they share ALL secrets they know&lt;/li&gt;
&lt;li&gt;Goal: Everyone knows all N secrets&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Question&lt;/strong&gt;: What&amp;rsquo;s the minimum number of calls?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;the-mathematical-result&#34;&gt;The Mathematical Result&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;For n ≥ 4 people:&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Building Scalable Event-Driven Microservices in Go: A User and Notes Service Example</title>
      <link>https://alamrafiul.com/posts/event-driven-microservices-go/</link>
      <pubDate>Wed, 15 Oct 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/event-driven-microservices-go/</guid>
      <description>Learn how to build scalable, resilient event-driven microservices in Go using NATS JetStream, Watermill, Bun ORM, and PostgreSQL with practical User and Notes service examples.</description>
    </item>
    
    <item>
      <title>Two Generals&#39; Problem: The Impossibility of Perfect Consensus</title>
      <link>https://alamrafiul.com/blogs/two-generals-problem/</link>
      <pubDate>Tue, 14 Oct 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/blogs/two-generals-problem/</guid>
      <description>&lt;h2 id=&#34;the-two-generals-problem&#34;&gt;The Two Generals&amp;rsquo; Problem&lt;/h2&gt;
&lt;p&gt;The Two Generals&amp;rsquo; Problem, also known as the Two Armies Problem, is a classic thought experiment that demonstrates the &lt;strong&gt;impossibility&lt;/strong&gt; of achieving perfect consensus over an unreliable communication channel. It was first formulated by E. A. Akkoyunlu, K. Ekanadham, and R. V. Huber in 1975.&lt;/p&gt;
&lt;h2 id=&#34;the-scenario&#34;&gt;The Scenario&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Two armies need to coordinate an attack:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;General A and General B surround an enemy&lt;/li&gt;
&lt;li&gt;They must attack &lt;strong&gt;simultaneously&lt;/strong&gt; to win&lt;/li&gt;
&lt;li&gt;If only one attacks → defeat&lt;/li&gt;
&lt;li&gt;They communicate via &lt;strong&gt;messengers&lt;/strong&gt; through enemy territory&lt;/li&gt;
&lt;li&gt;Messages can be &lt;strong&gt;lost&lt;/strong&gt; or &lt;strong&gt;intercepted&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Question&lt;/strong&gt;: Can they guarantee coordinated attack?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;the-impossible-dilemma&#34;&gt;The Impossible Dilemma&lt;/h2&gt;
&lt;div class=&#34;mermaid&#34;&gt;%%{init: {&#39;theme&#39;:&#39;dark&#39;, &#39;themeVariables&#39;: {&#39;primaryTextColor&#39;:&#39;#e5e7eb&#39;,&#39;secondaryTextColor&#39;:&#39;#e5e7eb&#39;,&#39;tertiaryTextColor&#39;:&#39;#e5e7eb&#39;,&#39;textColor&#39;:&#39;#e5e7eb&#39;,&#39;nodeTextColor&#39;:&#39;#e5e7eb&#39;,&#39;edgeLabelText&#39;:&#39;#e5e7eb&#39;,&#39;clusterTextColor&#39;:&#39;#e5e7eb&#39;,&#39;actorTextColor&#39;:&#39;#e5e7eb&#39;}}}%%
sequenceDiagram
    participant GA as General A
    participant Enemy as Enemy Territory
    participant GB as General B

    Note over GA: Wants to attack&lt;br/&gt;at dawn

    GA-&gt;&gt;Enemy: &#34;Attack at dawn&#34;
    Enemy-&gt;&gt;GB: Message delivered

    Note over GB: Received message,&lt;br/&gt;but A doesn&#39;t know!

    GB-&gt;&gt;Enemy: &#34;Acknowledged&#34;
    Enemy-&gt;&gt;GA: ACK delivered?

    Note over GA: Received ACK,&lt;br/&gt;but B doesn&#39;t know!

    GA-&gt;&gt;Enemy: &#34;ACK of ACK&#34;
    Enemy-&gt;&gt;GB: Delivered?

    Note over GA,GB: This never ends!
&lt;/div&gt;
&lt;h2 id=&#34;the-core-problem&#34;&gt;The Core Problem&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;The infinite regress:&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>The Bully Election: Leader Election in Distributed Systems</title>
      <link>https://alamrafiul.com/blogs/bully-election/</link>
      <pubDate>Wed, 20 Aug 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/blogs/bully-election/</guid>
      <description>&lt;h2 id=&#34;the-bully-election-algorithm&#34;&gt;The Bully Election Algorithm&lt;/h2&gt;
&lt;p&gt;The Bully Algorithm, proposed by Hector Garcia-Molina in 1982, is a classic leader election algorithm for distributed systems. It&amp;rsquo;s called &amp;ldquo;bully&amp;rdquo; because the highest-numbered process always wins and &amp;ldquo;bullies&amp;rdquo; the others into accepting it as leader.&lt;/p&gt;
&lt;h2 id=&#34;the-scenario&#34;&gt;The Scenario&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;A distributed system needs a coordinator:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;N nodes in a network&lt;/li&gt;
&lt;li&gt;Each node has a unique ID (priority)&lt;/li&gt;
&lt;li&gt;One node must be elected as leader&lt;/li&gt;
&lt;li&gt;When the leader fails, a new leader must be elected&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rule&lt;/strong&gt;: The node with the highest ID wins&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;The protocol:&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>The Byzantine Generals: Achieving Consensus with Traitors</title>
      <link>https://alamrafiul.com/blogs/byzantine-generals/</link>
      <pubDate>Thu, 14 Aug 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/blogs/byzantine-generals/</guid>
      <description>&lt;h2 id=&#34;the-byzantine-generals-problem&#34;&gt;The Byzantine Generals Problem&lt;/h2&gt;
&lt;p&gt;The Byzantine Generals Problem, proposed by Leslie Lamport, Robert Shostak, and Marshall Pease in 1982, is one of the most important problems in distributed systems. It addresses the challenge of achieving consensus when some participants may be faulty or malicious.&lt;/p&gt;
&lt;h2 id=&#34;the-scenario&#34;&gt;The Scenario&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Byzantine army divisions surround a city:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;N generals command their divisions&lt;/li&gt;
&lt;li&gt;They must coordinate: &lt;strong&gt;attack&lt;/strong&gt; or &lt;strong&gt;retreat&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;They communicate via messengers&lt;/li&gt;
&lt;li&gt;Some generals are &lt;strong&gt;traitors&lt;/strong&gt; who send conflicting messages&lt;/li&gt;
&lt;li&gt;Goal: All &lt;strong&gt;loyal&lt;/strong&gt; generals must agree on the same plan&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;The challenge:&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Building Payment Gateway Integrations in Go: A Complete Guide</title>
      <link>https://alamrafiul.com/posts/payment-gateway-integration/</link>
      <pubDate>Mon, 17 Feb 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/payment-gateway-integration/</guid>
      <description>Learn how to design and implement robust payment gateway integrations with multiple providers, handling transactions, retries, atomicity, scheduling, and data persistence in both SQL and NoSQL databases.</description>
    </item>
    
    <item>
      <title>From Choreography to Durable Execution: Why Temporal Changes Everything</title>
      <link>https://alamrafiul.com/posts/temporal-durable-execution/</link>
      <pubDate>Sat, 08 Feb 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/temporal-durable-execution/</guid>
      <description>Discover how Temporal&amp;#39;s durable execution model replaces hope-driven choreography with reliable, observable workflows. Learn the difference between event-driven choreography and durable execution with practical Go examples.</description>
    </item>
    
    <item>
      <title>Microservices Architecture in Go: Building Distributed Systems</title>
      <link>https://alamrafiul.com/posts/go-microservices-architecture/</link>
      <pubDate>Sat, 25 Jan 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/go-microservices-architecture/</guid>
      <description>Learn how to implement Microservices Architecture in Go for building scalable, independently deployable services with clear boundaries and distributed communication patterns.</description>
    </item>
    
    <item>
      <title>Go Concurrency Pattern: The Login Counter</title>
      <link>https://alamrafiul.com/posts/go-login-counter/</link>
      <pubDate>Fri, 24 Jan 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/go-login-counter/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://alamrafiul.com/posts/go-ticket-seller/&#34;&gt;← Ticket Seller&lt;/a&gt; | &lt;a href=&#34;https://alamrafiul.com/concurrency-patterns/&#34;&gt;Series Overview&lt;/a&gt; | &lt;a href=&#34;https://alamrafiul.com/posts/go-monte-carlo-pi/&#34;&gt;Monte Carlo Pi →&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;the-problem-counting-what-you-cant-see&#34;&gt;The Problem: Counting What You Can&amp;rsquo;t See&lt;/h2&gt;
&lt;p&gt;Count concurrent users. On login: increment. On logout: decrement. Simple, right?&lt;/p&gt;
&lt;p&gt;Now add reality:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The counter is distributed across multiple servers&lt;/li&gt;
&lt;li&gt;A user&amp;rsquo;s session times out on one server but they&amp;rsquo;re active on another&lt;/li&gt;
&lt;li&gt;The increment message arrives after the decrement message&lt;/li&gt;
&lt;li&gt;Network partitions split your cluster&lt;/li&gt;
&lt;li&gt;Servers crash mid-operation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Suddenly, this &amp;ldquo;simple&amp;rdquo; counter becomes a distributed systems nightmare. Welcome to &lt;strong&gt;distributed counting&lt;/strong&gt;, where even addition is hard.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Visual Guide to Distributed Systems Patterns</title>
      <link>https://alamrafiul.com/posts/distributed-systems-visual-guide/</link>
      <pubDate>Fri, 17 Jan 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/distributed-systems-visual-guide/</guid>
      <description>A comprehensive visual guide to distributed systems patterns including Raft consensus, circuit breakers, load balancing algorithms, and message queue patterns with interactive Mermaid diagrams.</description>
    </item>
    
    <item>
      <title>Context Propagation Patterns in Go</title>
      <link>https://alamrafiul.com/posts/go-context-propagation/</link>
      <pubDate>Mon, 24 Jun 2024 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/go-context-propagation/</guid>
      <description>Master context propagation for tracing, cancellation, and deadlines across service boundaries in distributed Go applications.</description>
    </item>
    
    <item>
      <title>Circuit Breaker Pattern in Go</title>
      <link>https://alamrafiul.com/posts/go-circuit-breaker/</link>
      <pubDate>Wed, 12 Jun 2024 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/go-circuit-breaker/</guid>
      <description>Implement the Circuit Breaker pattern in Go for fault tolerance, preventing cascading failures, and building resilient distributed systems.</description>
    </item>
    
  </channel>
</rss>
