Building Real-World Event Streaming Systems with Go and Kafka

    Introduction Apache Kafka is the backbone of event-driven architectures at companies like LinkedIn, Uber, and Airbnb. It lets services communicate asynchronously at massive scale — without coupling them together. Go is an excellent fit for Kafka workloads: lightweight goroutines, clean channel semantics, and minimal overhead make it easy to build high-throughput producers and consumers. This guide skips the theory-heavy basics and focuses on what you actually build. We’ll cover: Kafka’s core model in plain terms Setting up producers and consumers with kafka-go Three real-world use cases with full code and diagrams Patterns for reliability: retries, dead-letter queues, and consumer groups How Kafka Works (The Short Version) Kafka organizes data into topics. Each topic is split into partitions — ordered, immutable logs. Producers append messages to partitions. Consumers read messages from partitions at their own pace, tracking their position with an offset. ...

    March 23, 2026 · 12 min · Rafiul Alam

    Messaging Systems: A Visual Reference

    How to Read This Post Each scenario shows a diagram first, then a short note on why that system fits best. Complexity increases as you scroll. System Strength RabbitMQ Smart broker, routing flexibility, push-based delivery Kafka Immutable log, high throughput, replay from any offset JetStream NATS Lightweight persistence, built-in dedup, low operational cost Level 1 — Foundations 1. Simple Task Queue flowchart LR P[Producer] -->|task| Q[(Queue)] Q -->|deliver| C[Consumer] style P fill:#4a9eff,stroke:#2d7ed8,color:#fff style Q fill:#ff6b6b,stroke:#d44,color:#fff style C fill:#51cf66,stroke:#37b24d,color:#fff RabbitMQ. Push-based delivery with acknowledgments. Consumer confirms completion before the broker removes the message. No polling, no offset tracking — just send and ack. ...

    March 23, 2026 · 9 min · Rafiul Alam

    Caching Strategies: A Visual Guide

    How to Read This Post This post is a visual reference for caching strategies, organized by increasing complexity. Each section contains a Mermaid diagram followed by a brief explanation. No code — just patterns and pictures. Strategy Type Consistency Latency Complexity Best For Cache-Aside Read Eventual Low reads Low General purpose Read-Through Read Eventual Low reads Medium Read-heavy workloads Write-Through Write Strong High writes Medium Consistency-critical writes Write-Behind Write Eventual Low writes High Write-heavy workloads Write-Around Write Eventual Low writes Low Rarely-read written data LRU / LFU / TTL Eviction N/A N/A Low–Medium Memory management Consistent Hashing Distribution Varies Low High Horizontal scaling Multi-Layer Cache Read Eventual Very low High High-traffic systems Level 1 — Foundations 1. No Cache Baseline %%{init: {'theme':'dark', 'themeVariables': {'primaryTextColor':'#e5e7eb','secondaryTextColor':'#e5e7eb','tertiaryTextColor':'#e5e7eb','textColor':'#e5e7eb','nodeTextColor':'#e5e7eb','edgeLabelText':'#e5e7eb','clusterTextColor':'#e5e7eb','actorTextColor':'#e5e7eb'}}}%% flowchart LR subgraph Clients C1([Client 1]):::blue C2([Client 2]):::blue C3([Client 3]):::blue end subgraph Application A[App Server]:::purple end subgraph Storage DB[(Database)]:::red end C1 -->|Request| A C2 -->|Request| A C3 -->|Request| A A -->|"Query (50ms)"| DB DB -->|"Response (50ms)"| A A -->|"Total: ~100ms"| C1 A -->|"Total: ~100ms"| C2 A -->|"Total: ~100ms"| C3 classDef blue fill:#4a9eff,stroke:#4a9eff,color:#e5e7eb classDef red fill:#ff6b6b,stroke:#ff6b6b,color:#e5e7eb classDef purple fill:#a29bfe,stroke:#a29bfe,color:#e5e7eb No Cache Baseline — Every request hits the database directly. Under load, the database becomes the bottleneck: latency climbs, connections exhaust, and throughput collapses. This is the problem caching solves. ...

    March 15, 2026 · 11 min · Rafiul Alam

    Distributed Transactions: A Visual Guide

    How to Read This Post Each scenario shows a diagram first, then a short note on why the pattern matters. Complexity increases as you scroll. Pattern Approach Consistency Best For 2PC Coordinator-driven Strong (atomic) Short-lived, cross-DB 3PC Non-blocking 2PC Strong (reduces blocking) Theoretical improvement Saga Choreography Event-driven chain Eventual Loosely coupled services Saga Orchestration Central coordinator Eventual Complex workflows Outbox Pattern Local TX + relay At-least-once Event publishing guarantee Level 1 — Foundations 1. The Distributed Transaction Problem %%{init: {'theme':'dark', 'themeVariables': {'primaryTextColor':'#e5e7eb','secondaryTextColor':'#e5e7eb','tertiaryTextColor':'#e5e7eb','textColor':'#e5e7eb','nodeTextColor':'#e5e7eb','edgeLabelText':'#e5e7eb','clusterTextColor':'#e5e7eb','actorTextColor':'#e5e7eb'}}}%% flowchart TB C["Client: Place Order"] C --> OS["Order ServiceCreate order ✓"] C --> PS["Payment ServiceCharge $50 ✓"] C --> IS["Inventory ServiceReserve item ✗ FAILED"] IS -->|"What now?"| PROBLEM{{"Order created,payment charged,but no inventory!"}} PROBLEM --> Q1["Refund payment?"] PROBLEM --> Q2["Cancel order?"] PROBLEM --> Q3["Retry inventory?"] PROBLEM --> Q4["All of the abovein what order?"] style C fill:#4a9eff,stroke:#2d7ed8,color:#fff style OS fill:#51cf66,stroke:#37b24d,color:#fff style PS fill:#51cf66,stroke:#37b24d,color:#fff style IS fill:#ff6b6b,stroke:#d44,color:#fff style PROBLEM fill:#ffd43b,stroke:#f59f00,color:#333 style Q1 fill:#546e7a,stroke:#90a4ae,color:#fff style Q2 fill:#546e7a,stroke:#90a4ae,color:#fff style Q3 fill:#546e7a,stroke:#90a4ae,color:#fff style Q4 fill:#a29bfe,stroke:#6c5ce7,color:#fff The core problem. In a monolith, a single database transaction guarantees all-or-nothing. In microservices, each service has its own database — there’s no single transaction boundary. If one step fails after others succeed, you have an inconsistent state. ...

    March 13, 2026 · 10 min · Rafiul Alam

    The AI Inflection Point: What's Happening, Why It Matters, and How to Prepare

    Something shifted in early 2026 — and if you blinked, you might have missed it. The AI industry stopped running benchmark races and started asking harder questions: Can these systems actually work in production? Do the business models hold up? And how do we do this without blowing something up? This isn’t a hype piece. It’s a map — of where we are, why it matters, what could go wrong, and what you can do about it. ...

    March 13, 2026 · 10 min · Rafiul Alam

    Distributed Storage: A Visual Guide

    How to Read This Post Each scenario shows a diagram first, then a short note on why the pattern matters. Complexity increases as you scroll. Strategy Category Strength Trade-off Leader-Follower Replication Simple, strong consistency for reads Write bottleneck at leader Multi-Leader Replication Multi-DC writes Conflict resolution needed Leaderless (Quorum) Replication No single point of failure Tunable consistency Range Partitioning Partitioning Range scans, sorted data Hotspot risk Hash Partitioning Partitioning Even distribution No range queries Consistent Hashing Partitioning Minimal redistribution Virtual nodes needed Level 1 — Foundations 1. Single Node Storage %%{init: {'theme':'dark', 'themeVariables': {'primaryTextColor':'#e5e7eb','secondaryTextColor':'#e5e7eb','tertiaryTextColor':'#e5e7eb','textColor':'#e5e7eb','nodeTextColor':'#e5e7eb','edgeLabelText':'#e5e7eb','clusterTextColor':'#e5e7eb','actorTextColor':'#e5e7eb'}}}%% flowchart LR C1["Client 1"] --> DB[(Single Database)] C2["Client 2"] --> DB C3["Client 3"] --> DB DB -->|"⚡ crash"| LOST["All data LOSTAll clients BLOCKED"] style C1 fill:#4a9eff,stroke:#2d7ed8,color:#fff style C2 fill:#4a9eff,stroke:#2d7ed8,color:#fff style C3 fill:#4a9eff,stroke:#2d7ed8,color:#fff style DB fill:#ff6b6b,stroke:#d44,color:#fff style LOST fill:#546e7a,stroke:#90a4ae,color:#fff Single point of failure. One database handles everything — simple but fatal. If it crashes, all data is lost and all clients are blocked. Every distributed storage pattern exists to solve this problem. ...

    March 11, 2026 · 10 min · Rafiul Alam

    Consensus Algorithms: A Visual Guide

    How to Read This Post Each scenario shows a diagram first, then a short note on why the pattern matters. Complexity increases as you scroll. Algorithm Approach Strength Trade-off Raft Leader-based Understandable, widely adopted Leader bottleneck Paxos Proposer-based Formally proven, flexible Notoriously hard to implement Multi-Paxos Optimized Paxos Fewer round-trips with stable leader Complex recovery ZAB Leader-based Ordered broadcast (ZooKeeper) Tightly coupled to ZK Level 1 — Why Consensus? 1. The Agreement Problem %%{init: {'theme':'dark', 'themeVariables': {'primaryTextColor':'#e5e7eb','secondaryTextColor':'#e5e7eb','tertiaryTextColor':'#e5e7eb','textColor':'#e5e7eb','nodeTextColor':'#e5e7eb','edgeLabelText':'#e5e7eb','clusterTextColor':'#e5e7eb','actorTextColor':'#e5e7eb'}}}%% flowchart TB C[Client] -->|"SET x=5"| N1["Node Ax = 5 ✓"] C -->|"SET x=5"| N2["Node Bx = 5 ✓"] C -->|"SET x=5"| N3["Node C⚡ crashed"] N1 -->|"what is x?"| Q{{"Do all nodesagree x=5?"}} N2 -->|"what is x?"| Q N3 -->|"???"| Q Q -->|"With consensus"| YES["All agree on x=5even with failures"] Q -->|"Without consensus"| NO["Inconsistent statesplit brain possible"] style C fill:#4a9eff,stroke:#2d7ed8,color:#fff style N1 fill:#51cf66,stroke:#37b24d,color:#fff style N2 fill:#51cf66,stroke:#37b24d,color:#fff style N3 fill:#ff6b6b,stroke:#d44,color:#fff style Q fill:#ffd43b,stroke:#f59f00,color:#333 style YES fill:#51cf66,stroke:#37b24d,color:#fff style NO fill:#ff6b6b,stroke:#d44,color:#fff The core problem. Distributed nodes must agree on a single value even when some nodes crash or messages are delayed. Without consensus, you get split-brain — two parts of the system believing different things. ...

    March 9, 2026 · 10 min · Rafiul Alam

    Advanced Data Structures: A Coffee Shop Guide

    Understanding data structures can be challenging when they’re presented as abstract concepts. Let’s make them tangible by exploring them through something we all know: a coffee shop. From the order queue to delivery routes, every aspect of running a coffee shop mirrors fundamental computer science concepts. In this comprehensive guide, we’ll explore 25+ data structures through the lens of coffee shop operations, complete with visualizations and Go implementations. Part 1: The Basics Revisited The Order Line - Queue Every morning at the coffee shop, customers line up in order. First in, first out (FIFO). The person who arrives first gets served first. This is a queue. ...

    November 19, 2025 · 31 min · Rafiul Alam

    Best AI Research Papers: A Curated List from Foundation to Frontier

    The field of artificial intelligence has evolved rapidly over the past decades, driven by groundbreaking research papers that have fundamentally changed how we think about and build intelligent systems. Whether you’re a researcher, practitioner, or enthusiast, understanding these landmark papers is essential to grasping where AI is today and where it’s heading. This curated list covers the most influential AI research papers from the foundational classics to cutting-edge 2024-2025 breakthroughs. I’ve organized them chronologically and by domain to help you navigate this fascinating journey through AI’s evolution. ...

    November 19, 2025 · 7 min · Rafiul Alam

    Complete Guide to Go Concurrency Patterns: Visual Patterns & Code Examples

    Concurrency is one of Go’s most powerful features, built into the language from the ground up. This comprehensive guide covers all essential concurrency patterns with visual diagrams and practical code examples. Table of Contents Goroutines - Basic Concurrency Channels - Communication Select Statement - Multiplexing Worker Pool Pattern Fan-In Pattern Fan-Out Pattern Pipeline Pattern Semaphore Pattern Barrier Pattern Future/Promise Pattern Rate Limiting Pattern Circuit Breaker Pattern Context Pattern Mutex Pattern WaitGroup Pattern ErrGroup Pattern Goroutines - Basic Concurrency Goroutines are lightweight threads managed by the Go runtime. They enable concurrent execution with minimal overhead. ...

    November 18, 2025 · 17 min · Rafiul Alam