Scenario: You’re architecting a smart city platform with 50,000 streetlights, 200 traffic cameras, and 10 city-wide dashboards. Each streetlight sends on/off status + energy data every 5 minutes (50 bytes). Cameras stream alerts to 3 emergency services (police, fire, ambulance). Budget: $200K for backend messaging infrastructure over 5 years.
Think about:
- Would you use MQTT or AMQP for streetlight telemetry? Why?
- How would you route camera alerts so only relevant agencies receive them?
Key Insight: Use MQTT for streetlights (simple pub/sub, 50,000 × $0/sensor, minimal overhead) and AMQP for camera alerts (complex routing, “route by jurisdiction and severity”, guaranteed delivery).
MQTT broker handles 50,000 streetlights at approximately 167 messages/second (50,000 ÷ 300 s = 166.7 msg/s, easily managed by a single AWS IoT Core broker at $8/month). AMQP exchanges route camera alerts using bindings like routing_key: "zone.north.fire.critical" ensuring the North Fire Station only sees its relevant emergencies—this complex routing would require custom logic in MQTT.
Let’s quantify the message throughput for streetlights precisely. Each streetlight sends status and energy data every 5 minutes:
\[\text{Message Rate} = \frac{\text{streetlights} \times \text{messages per interval}}{\text{interval in seconds}} = \frac{50{,}000 \times 1}{300 \text{ s}} \approx 166.7 \text{ msg/s}\]
With an average message size of 50 bytes plus MQTT’s 2-byte header:
\[\text{Bandwidth} = 166.7 \text{ msg/s} \times 52 \text{ bytes} = 8{,}668.4 \text{ bytes/s} \approx 8.47 \text{ KB/s}\]
For the hybrid architecture 5-year total cost of ownership:
\[\text{TCO}_{\text{hybrid}} = \text{MQTT} + \text{AMQP} = (96 \times 5) + 15{,}000 + (5{,}000 \times 5) = \$40{,}480\]
This compares favorably to pure AMQP (estimated $80K+) or pure MQTT with custom routing ($60K+ in development costs).
Hybrid cost: MQTT broker ($96/year) + RabbitMQ cluster ($15K one-time, $5K/year maintenance) = ~$30K over 5 years vs $80K+ for pure AMQP everywhere or poor routing with pure MQTT.
Verify Your Understanding:
- Why might you bridge MQTT and AMQP at the backend (not choose one exclusively)?
- How does QoS 1 in MQTT compare to transactional guarantees in AMQP?