Design an MQTT broker for millions of devices
PremiumIoT systemHard
- MQTT
- QoS levels
- Retained messages
Quick answer
This ioT system interview question asks you to design an MQTT broker for millions of devices. Aim for a design that collects data from many devices and acts on it reliably, then explain device connections, ingestion, storage and trade-offs. Interviewers want to see how you handle unreliable networks, device scale and data volume.
The problem
Design an MQTT broker for millions of devices: a clustered broker that holds 20 million device connections, routes telemetry to backend services and commands back to devices. The hard parts are memory per connection, routing across nodes, sessions for offline devices and the reconnect storm after an outage.
Devices connect with MQTT 3.1.1 or 5 over TLS, publish telemetry to devices/{id}/telemetry, and subscribe to devices/{id}/cmd. Backend services consume telemetry through shared subscriptions and publish commands. The broker supports QoS 0, 1 and 2, retained messages, persistent sessions and last will messages.
What must an MQTT broker for millions of devices do?
- Connections: Devices authenticate with client certificates and may only use topics under their own ID.
- Telemetry: Device publishes reach backend consumers through shared subscriptions, load-balanced across consumer instances.
How well must it do it?
- Throughput: 1 million inbound publishes per second at peak, and 100,000 commands per second outbound.
- Latency: p99 under 50 ms from publish to subscriber inside the cluster.
What scale should you design for?
Use these numbers in your estimates.
The scale numbers unlock with this questionUnlock
Key concepts
- MQTT
- QoS levels
- Retained messages
- Persistent sessions
- Shared subscriptions
- Reconnect storms
How you’ll practise
- Requirements
- Estimate
- Device and connectivity
- Ingestion and processing
- Device management and updates
- Wrap-up
Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.
What do interviewers look for?
In any IoT system design round.
- Clarifies device count, message rate and payload size
- Handles devices that go offline and reconnect
- Plans ingestion that absorbs bursts
- Separates hot real-time data from long-term storage
- Covers device identity, updates and security
- Explains what runs on the device and what runs in the cloud
Questions people ask about this interview question
- Which design type is this question?
- It is an ioT system question. You design an MQTT broker for millions of devices and explain your choices the way you would in an interview.
- Is this question asked at entry level?
- It is marked Hard. It suits engineers preparing for senior interviews, where you are expected to drive the discussion and go deep on trade-offs.
- What should I cover first?
- Start with the devices, what they send, how often and what must happen with it. Agree on scope with the interviewer before you design anything.
- Can I practise it for free?
- It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.
Related questions
- Design an autonomous vehicle fleet coordination platformIoT system · HardPremium
- Design a smart EV charging network management platformIoT system · MediumPremium
- Design a smart utility meter monitoring platformIoT system · MediumPremium
- Design a pharmaceutical cold chain monitoring platformIoT system · MediumPremium
Updated · Written by the SevyDevy team