Networking & IoT · Interview question

Why is MQTT's publish/subscribe + broker model well-suited to IoT?

A strong answer

Several reasons converge. First, it solves the NAT problem: each device makes an outbound TCP connection to the broker and keeps it open, so even devices behind NAT (which can't accept inbound connections) can both send telemetry and receive commands over that single persistent link, the cloud never has to reach in. Second, publish/subscribe decouples producers from consumers: a sensor publishes to a topic without knowing who, if anyone, is listening, and consumers subscribe without knowing the sources, so you can add devices and services independently without reconfiguring the others, which scales to large, changing fleets. Third, it's lightweight: the fixed header can be as small as two bytes, which suits low-bandwidth, battery-powered links. Fourth, it has reliability and presence features tuned for flaky networks, QoS levels for lossy links, retained messages so a new subscriber immediately learns current state, and Last Will so the broker announces a device that dropped. Running over TCP (usually with TLS) gives it a reliable, securable transport. So MQTT matches IoT's realities: constrained devices, NAT, intermittent connectivity, and large decoupled fleets.

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

MQTT

The IoT publish/subscribe workhorse: a broker decouples publishers and subscribers over topics, devices dial out (NAT-friendly), and QoS, retained messages, and Last Will handle lossy links.

More MQTT questions

Browse all 472 interview questions
Why is MQTT's publish/subscribe + broker model well-suited to IoT? | EmbeddedPrep.io