Backend & APIs · Pro
Build an MQTT Broker
Build a publish/subscribe message broker that speaks MQTT with topic matching, QoS levels, retained messages, and persistent sessions on an event-loop server.
You build an MQTT broker: a publish/subscribe message server that accepts client connections, decodes the binary MQTT control packets, routes published messages to subscribers via topic matching including wildcards, honors the protocol's quality-of-service levels, stores retained messages, and tracks per-client sessions, all on a single-threaded epoll-style event loop. It is worth building because it combines low-level binary protocol parsing with the concurrency model that powers high-throughput servers, and pub/sub is the backbone of IoT and event-driven systems. It is resume-defining because it shows you can implement a real wire protocol against its specification and build a non-blocking server that holds thousands of connections without a thread per client. You finish fluent in both protocol design and the event-loop architecture behind production network services.
What you build
- Binary parser and encoder for MQTT control packets
- CONNECT/CONNACK handshake with client identification
- Topic-based routing with single- and multi-level wildcards
- QoS 0, 1, and 2 publish flows with acknowledgements
- Retained messages delivered to new subscribers
- Persistent sessions that survive reconnects
- Non-blocking epoll event loop serving many concurrent clients
What it teaches
- Binary wire-protocol parsing and encoding
- Publish/subscribe and topic wildcard matching
- Quality-of-service delivery guarantees
- Non-blocking I/O with epoll event loops
- Connection and session state management
- Implementing software from a protocol specification
Sign in to open the build guide
Free account. Get the step-by-step build and every resource link.
Take it further
- Add full QoS 2 with the four-step exactly-once handshake.
- Persist sessions and retained messages to disk so they survive restarts.
- Add TLS and username/password authentication.


