viewof payloadSize = Inputs.range([1, 5000], {
value: 120,
step: 1,
label: "Payload size (bytes)"
})
viewof deliveryMode = Inputs.select(
["At-Most-Once (no ACK)", "At-Least-Once (with ACK)", "Transactional (not exactly once)"],
{value: "At-Least-Once (with ACK)", label: "Delivery mode"}
)
// Constants
frameHeader = 8
methodFrame = 40
contentHeader = 60
bodyFrame = 8
baseOverhead = frameHeader + methodFrame + contentHeader + bodyFrame
ackOverhead = deliveryMode === "At-Least-Once (with ACK)" ? 40 : 0
txOverhead = deliveryMode === "Transactional (not exactly once)" ? 200 : 0
totalOverhead = baseOverhead + ackOverhead + txOverhead
totalSize = payloadSize + totalOverhead
efficiency = (payloadSize / totalSize * 100).toFixed(1)
efficiencyColor = efficiency >= 80 ? "#16A085" : efficiency >= 50 ? "#E67E22" : "#E74C3C"
html`
<div style="background: #f8f9fa; padding: 20px; border-radius: 8px; border-left: 4px solid #2C3E50; margin: 20px 0;">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px;">
<div>
<div style="font-size: 14px; color: #7F8C8D; margin-bottom: 5px;">Payload</div>
<div style="font-size: 28px; font-weight: bold; color: #2C3E50;">${payloadSize} bytes</div>
</div>
<div>
<div style="font-size: 14px; color: #7F8C8D; margin-bottom: 5px;">Protocol Overhead</div>
<div style="font-size: 28px; font-weight: bold; color: #E67E22;">${totalOverhead} bytes</div>
</div>
</div>
<div style="margin-bottom: 20px;">
<div style="font-size: 14px; color: #7F8C8D; margin-bottom: 5px;">Overhead Breakdown</div>
<div style="font-size: 13px; color: #2C3E50; line-height: 1.8;">
• Frame header: ${frameHeader}B + Method frame: ${methodFrame}B + Content header: ${contentHeader}B + Body frame: ${bodyFrame}B = ${baseOverhead}B base<br>
${deliveryMode === "At-Least-Once (with ACK)" ? `• ACK overhead: ${ackOverhead}B` : ""}
${deliveryMode === "Transactional (not exactly once)" ? `• Assumed transaction overhead: ${txOverhead}B` : ""}
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
<div>
<div style="font-size: 14px; color: #7F8C8D; margin-bottom: 5px;">Total Message Size</div>
<div style="font-size: 24px; font-weight: bold; color: #2C3E50;">${totalSize} bytes</div>
</div>
<div>
<div style="font-size: 14px; color: #7F8C8D; margin-bottom: 5px;">Payload Efficiency</div>
<div style="font-size: 24px; font-weight: bold; color: ${efficiencyColor};">${efficiency}%</div>
<div style="font-size: 12px; color: #7F8C8D; margin-top: 4px;">
${efficiency >= 80 ? "Excellent" : efficiency >= 50 ? "Moderate" : "Poor"}
</div>
</div>
</div>
<div style="margin-top: 15px; padding: 15px; background: white; border-radius: 6px;">
<div style="font-size: 13px; color: #2C3E50; margin-bottom: 8px;">
<strong>Recommendation:</strong>
${efficiency < 50
? `Consider batching multiple messages to improve efficiency. Batching 10 messages would increase efficiency to ${(payloadSize * 10 / (payloadSize * 10 + totalOverhead) * 100).toFixed(1)}%.`
: efficiency < 80
? `Efficiency is moderate. For high-throughput scenarios, consider batching to reduce overhead.`
: `Excellent efficiency! Overhead is minimal relative to payload size.`}
</div>
</div>
</div>
`Interactive Calculator: AMQP Message Sizing
Interactive Calculator: AMQP Message Sizing
animation
amqp
protocols
messaging
Try Change payload size to 120 bytes.
Observe Watch Protocol Overhead and Payload Efficiency after Calculate message size.
Explain Explain why transactional delivery adds 200 bytes of assumed transaction overhead.
Technical boundaries. Frame sizes and ACK overhead are fixed. Transaction overhead is assumed to be 200 bytes; transactional delivery is not exactly once.