viewof deviceCount = Inputs.range([100, 100000], {
value: 10000,
step: 100,
label: "Number of Devices"
})
viewof messageInterval = Inputs.select(
[10, 30, 60, 300, 600, 1800, 3600],
{
value: 300,
label: "Message Interval (seconds)",
format: x => x < 60 ? `${x}s` : x < 3600 ? `${x/60}min` : `${x/3600}hr`
}
)
viewof payloadSize = Inputs.range([10, 500], {
value: 50,
step: 10,
label: "Payload Size (bytes)"
})
viewof protocolType = Inputs.radio(
["MQTT", "AMQP", "Hybrid"],
{value: "Hybrid", label: "Architecture"}
)Protocol Overhead & Cost Calculator
Protocol Overhead & Cost Calculator
animation
amqp
protocols
messaging
Try Change Payload Size (bytes) from 50 to 500 and change Architecture.
Observe Watch Bandwidth, Monthly Cost, and Overhead Savings as payload size changes from 50 bytes.
Explain Explain why 2-byte and 8-byte headers affect Overhead Savings as payload size changes.
Technical boundaries. Message sizes add fixed 2-byte MQTT or 8-byte AMQP headers to payload. Monthly costs use $1 per million MQTT messages, fixed AMQP base and scaling costs, and a $200 Hybrid addition; Hybrid device bandwidth uses MQTT.
Interactive Protocol Calculator
NoteProtocol Overhead & Cost Calculator
Explore how protocol choice affects message size, bandwidth, and costs for your IoT deployment.
mqttHeaderSize = 2
amqpHeaderSize = 8
mqttMessageSize = payloadSize + mqttHeaderSize
amqpMessageSize = payloadSize + amqpHeaderSize
messagesPerSecond = deviceCount / messageInterval
messagesPerDay = messagesPerSecond * 86400
// Bandwidth calculations
mqttBandwidth = messagesPerSecond * mqttMessageSize / 1024 // KB/s
amqpBandwidth = messagesPerSecond * amqpMessageSize / 1024 // KB/s
mqttBandwidthDaily = mqttBandwidth * 86400 / 1024 // MB/day
amqpBandwidthDaily = amqpBandwidth * 86400 / 1024 // MB/day
// Cost calculations (AWS IoT Core for MQTT, RabbitMQ for AMQP)
mqttCostPerMonth = messagesPerDay * 30 / 1000000 * 1 // $1 per million messages
amqpCostPerMonth = 500 + (deviceCount > 10000 ? 300 : 0) // Base + scaling
hybridCostPerMonth = mqttCostPerMonth + 200 // MQTT broker + small AMQP cluster
selectedCost = protocolType === "MQTT" ? mqttCostPerMonth :
protocolType === "AMQP" ? amqpCostPerMonth :
hybridCostPerMonth
selectedBandwidth = protocolType === "MQTT" ? mqttBandwidth :
protocolType === "AMQP" ? amqpBandwidth :
mqttBandwidth // Hybrid uses MQTT for devices
// Create results display
html`
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin: 20px 0;">
<div style="background: linear-gradient(135deg, #2C3E50 0%, #34495E 100%); padding: 20px; border-radius: 8px; color: white;">
<div style="font-size: 14px; opacity: 0.9; margin-bottom: 8px;">Message Rate</div>
<div style="font-size: 28px; font-weight: bold;">${messagesPerSecond.toFixed(1)}</div>
<div style="font-size: 12px; opacity: 0.8; margin-top: 4px;">messages/second</div>
</div>
<div style="background: linear-gradient(135deg, #16A085 0%, #1ABC9C 100%); padding: 20px; border-radius: 8px; color: white;">
<div style="font-size: 14px; opacity: 0.9; margin-bottom: 8px;">Bandwidth</div>
<div style="font-size: 28px; font-weight: bold;">${selectedBandwidth.toFixed(2)}</div>
<div style="font-size: 12px; opacity: 0.8; margin-top: 4px;">KB/s (${(selectedBandwidth * 86400 / 1024 / 1024).toFixed(2)} GB/day)</div>
</div>
<div style="background: linear-gradient(135deg, #E67E22 0%, #F39C12 100%); padding: 20px; border-radius: 8px; color: white;">
<div style="font-size: 14px; opacity: 0.9; margin-bottom: 8px;">Monthly Cost</div>
<div style="font-size: 28px; font-weight: bold;">${"$" + (selectedCost.toFixed(0))}</div>
<div style="font-size: 12px; opacity: 0.8; margin-top: 4px;">${"$" + ((selectedCost * 12).toFixed(0))}/year</div>
</div>
<div style="background: linear-gradient(135deg, #3498DB 0%, #5DADE2 100%); padding: 20px; border-radius: 8px; color: white;">
<div style="font-size: 14px; opacity: 0.9; margin-bottom: 8px;">Overhead Savings</div>
<div style="font-size: 28px; font-weight: bold;">${((1 - mqttMessageSize/amqpMessageSize) * 100).toFixed(0)}%</div>
<div style="font-size: 12px; opacity: 0.8; margin-top: 4px;">MQTT vs AMQP</div>
</div>
</div>
<div style="margin: 20px 0; padding: 15px; background: #ECF0F1; border-left: 4px solid #2C3E50; border-radius: 4px;">
<strong>Protocol Comparison:</strong><br/>
<div style="margin-top: 10px; font-family: monospace; font-size: 13px;">
MQTT: ${mqttMessageSize} bytes/msg × ${messagesPerSecond.toFixed(1)} msg/s = ${mqttBandwidth.toFixed(2)} KB/s<br/>
AMQP: ${amqpMessageSize} bytes/msg × ${messagesPerSecond.toFixed(1)} msg/s = ${amqpBandwidth.toFixed(2)} KB/s<br/>
<span style="color: #16A085; font-weight: bold;">Bandwidth Savings: ${((amqpBandwidth - mqttBandwidth) / amqpBandwidth * 100).toFixed(1)}% with MQTT</span>
</div>
</div>
`md`
**Key Insights:**
${"\n"}
**First:** **MQTT** minimizes bandwidth with 2-byte headers (ideal for ${deviceCount.toLocaleString()} devices)
${"\n"}
**Next:** **AMQP** provides sophisticated routing but uses ${((amqpMessageSize - mqttMessageSize) / mqttMessageSize * 100).toFixed(0)}% more bandwidth per message
${"\n"}
**Then:** **Hybrid** architectures optimize costs: MQTT at edge (${"$" + (mqttCostPerMonth.toFixed(0))}/month) + AMQP for backend routing
`