Building Resilient Workflows with Temporal.io: A Coffee Shop Tutorial

    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? Enter Temporal.io - a workflow orchestration platform that makes building reliable distributed applications dramatically easier. In this comprehensive tutorial, we’ll build a coffee shop ordering system that demonstrates Temporal’s powerful capabilities. ...

    November 22, 2025 · 12 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

    Banker's Algorithm: Deadlock Avoidance Through Safe State Detection

    The Banker’s Algorithm The Banker’s Algorithm is a deadlock avoidance algorithm developed by Edsger Dijkstra in 1965. It models a bank that has limited cash and customers with credit limits who request loans in chunks. The bank only grants loans if the system stays in a “safe state” - meaning it can fulfill all future maximum requests. The Scenario A bank has: Limited cash available Multiple customers with credit limits Customers request loans in chunks over time The rules: ...

    November 18, 2025 · 14 min · Rafiul Alam

    Producer-Consumer: The Unbounded Buffer

    The Producer-Consumer Problem The Producer-Consumer pattern is one of the most fundamental concurrency patterns. It appears everywhere in modern software: Message queues (RabbitMQ, Kafka, SQS) Task processing (background jobs, worker pools) Data pipelines (ETL, streaming analytics) Event systems (event buses, pub/sub) Buffering (I/O buffers, network buffers) The Setup: Producers generate data, consumers process it. They run concurrently and need to coordinate through a shared buffer. The Unbounded Buffer Variant In this first variant, we use an unbounded buffer - the queue can grow infinitely (until we run out of memory). This is the simplest version and showcases Go’s beautiful channel abstraction. ...

    November 15, 2025 · 7 min · Rafiul Alam

    Go 1.25: Game-Changing Features You Need to Know

    Go 1.25 is Here! Go 1.25 was released on August 12, 2025, bringing some of the most exciting features we’ve seen in recent Go versions. After working with these features extensively, I can confidently say this release is a game-changer for concurrent programming, testing, and performance optimization. Let’s dive into the major features with practical, real-world examples you can use right away. 1. testing/synctest: Revolutionary Concurrent Testing The new testing/synctest package finally solves one of Go’s biggest testing challenges: testing concurrent code with time-dependent behavior. Previously, testing concurrent code meant dealing with time.Sleep() calls and flaky tests. Not anymore. ...

    November 13, 2025 · 12 min · Rafiul Alam

    The Token Ring: Fair Resource Access Through Token Passing

    The Token Ring Problem 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’s simple, fair, and starvation-free. The Scenario Nodes arranged in a ring: N nodes form a logical ring A single token passes around the ring Only token holder can enter critical section After using resource, pass token to next node Properties: Fair (FIFO order), no starvation, deadlock-free The challenge: ...

    November 10, 2025 · 11 min · Rafiul Alam

    The River Crossing: Group Formation with Constraints

    The River Crossing Problem The River Crossing Problem, inspired by Allen Downey’s “The Little Book of Semaphores,” demonstrates constrained group formation and safety-critical synchronization. It models scenarios where groups must form under specific rules before proceeding - common in distributed systems and resource allocation. The Scenario A river crossing with: Two types of people: Hackers (H) and Employees (E) A boat that holds exactly 4 people Random arrivals on the riverbank Safety rules for boarding: ...

    November 5, 2025 · 11 min · Rafiul Alam

    Dining Philosophers: The Asymmetric Solution

    The Elegant Solution In the previous articles, we explored the deadlock problem and the waiter solution. Now we’ll see the most elegant solution: the Asymmetric Solution, also known as Resource Ordering. The Key Insight: Deadlock requires circular wait. Break the circle, prevent the deadlock. The Asymmetric Solution Explained Instead of all philosophers picking up forks in the same order (left then right), we make ONE philosopher do the opposite: Philosophers 0-3: Pick up left fork first, then right fork Philosopher 4: Pick up right fork first, then left fork This simple change breaks the circular dependency and prevents deadlock! ...

    November 4, 2025 · 8 min · Rafiul Alam

    Dining Philosophers: The Waiter Solution

    Breaking the Deadlock In the previous article, we saw how the naive implementation of the Dining Philosophers problem inevitably leads to deadlock. Now we’ll implement the Waiter Solution - a centralized coordinator that prevents deadlock by controlling resource access. The Waiter Solution Concept The Idea: Add a waiter who controls access to the forks. No philosopher can pick up forks without the waiter’s permission. The waiter ensures that at most 4 philosophers can attempt to pick up forks simultaneously. ...

    October 31, 2025 · 7 min · Rafiul Alam

    The Gossiping Problem: Efficient Information Spreading

    The Gossiping Problem 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. The Scenario N people, N secrets: Person i knows secret Si initially When persons i and j call each other, they share ALL secrets they know Goal: Everyone knows all N secrets Question: What’s the minimum number of calls? The Mathematical Result For n ≥ 4 people: ...

    October 29, 2025 · 10 min · Rafiul Alam