In the previous part of this series, we built a Worker Pool from scratch, exploring point-to-point communication where a coordinator assigns jobs to individual workers. However, this 1-to-1 approach falls short when an event needs to be received by multiple independent components simultaneously (e.g., an Inventory Service, Email Service, and Analytics Service all responding to a checkout event).
Point-to-point messaging introduces tight coupling and makes systems brittle. To solve this, distributed architectures rely on the Publish / Subscribe (PubSub) pattern.
In this tutorial, we build a PubSub Broker entirely from scratch using raw Elixir process primitives:
spawn/1
send/2
receive/1
Process.monitor/1
Rather than relying on GenServer, Registry, Phoenix.PubSub, or external tools like RabbitMQ, the goal is to deeply understand the core mechanics of 1-to-many communication, topic routing tables, fan-out broadcasting, and subscriber lifecycle management.






















