A complete in-memory message broker built from scratch in Python. Zero external dependencies. Pub/sub, queues, consumer groups, WAL, retries, dead letters, TCP protocol — all stdlib.
from brokerlite.broker import Broker from brokerlite.message import Message broker = Broker() broker.start() broker.create_topic("orders") broker.publish(Message(topic="orders", value=b"hello"))
Topics split into partitions for parallelism. Messages route by key hash. Consumer groups rebalance automatically when members join or leave.
topicspartitionsconsumer-groupsEvery message is tracked. Failed deliveries retry with exponential backoff and jitter. After max attempts, messages land in a dead letter queue for inspection and replay.
ackretrydlqAppend-only write-ahead log with automatic segment rotation. SQLite metadata for committed offsets and topic configs. Key-based compaction and time-based retention.
WALSQLitecompaction# Start server server = BrokerServer(host="0.0.0.0", port=9092) server.start(background=True) # Connect client client = BrokerClient(host="localhost", port=9092) client.connect() client.produce("events", b"click", key="user-1") msgs = client.fetch("events", partition=0, offset=0)