colors = ({navy: "#2C3E50", teal: "#16A085", orange: "#E67E22", blue: "#3498DB", gray: "#7F8C8D", purple: "#9B59B6", red: "#E74C3C"})
viewof publishRate = Inputs.range([100, 50000], {
value: 5000,
step: 100,
label: "Publish rate (msg/sec):",
width: 400
})
viewof consumerProcessingTime = Inputs.range([1, 500], {
value: 10,
step: 1,
label: "Consumer processing time (ms/msg):",
width: 400
})
viewof prefetchCount = Inputs.range([1, 500], {
value: 10,
step: 10,
label: "Prefetch count:",
width: 400
})
// Calculations
consumerThroughput = 1000 / consumerProcessingTime // msg/sec per consumer
minConsumers = Math.ceil(publishRate / consumerThroughput)
actualThroughput = minConsumers * consumerThroughput
utilizationPercent = (publishRate / actualThroughput) * 100
queueGrowthRate = Math.max(0, publishRate - actualThroughput)
timeToFillQueue = queueGrowthRate > 0 ? (10000 / queueGrowthRate).toFixed(1) : "∞"
// Prefetch latency impact
networkRTT = 5 // ms
prefetchLatencyOverhead = (networkRTT / prefetchCount).toFixed(2)
html`
<div style="background: linear-gradient(135deg, ${colors.blue} 0%, ${colors.purple} 100%); padding: 25px; border-radius: 12px; color: white; margin: 20px 0; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
<h3 style="margin-top: 0; color: white; border-bottom: 2px solid rgba(255,255,255,0.3); padding-bottom: 10px;">Consumer Scaling Analysis</h3>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 20px;">
<div style="background: rgba(255,255,255,0.1); padding: 15px; border-radius: 8px; border-left: 4px solid ${colors.orange};">
<div style="font-size: 0.9em; opacity: 0.9; margin-bottom: 5px;">Consumers Needed</div>
<div style="font-size: 2em; font-weight: bold;">${minConsumers}</div>
<div style="font-size: 0.85em; opacity: 0.8; margin-top: 5px;">${consumerThroughput.toFixed(0)} msg/s each</div>
</div>
<div style="background: rgba(255,255,255,0.1); padding: 15px; border-radius: 8px; border-left: 4px solid ${colors.teal};">
<div style="font-size: 0.9em; opacity: 0.9; margin-bottom: 5px;">Total Capacity</div>
<div style="font-size: 2em; font-weight: bold;">${actualThroughput.toFixed(0)}</div>
<div style="font-size: 0.85em; opacity: 0.8; margin-top: 5px;">msg/sec</div>
</div>
<div style="background: rgba(255,255,255,0.1); padding: 15px; border-radius: 8px; border-left: 4px solid ${utilizationPercent > 95 ? colors.red : utilizationPercent > 80 ? colors.orange : colors.teal};">
<div style="font-size: 0.9em; opacity: 0.9; margin-bottom: 5px;">Utilization</div>
<div style="font-size: 2em; font-weight: bold;">${utilizationPercent.toFixed(1)}%</div>
<div style="font-size: 0.85em; opacity: 0.8; margin-top: 5px;">${utilizationPercent > 95 ? 'Critical' : utilizationPercent > 80 ? 'High' : '✓ Healthy'}</div>
</div>
<div style="background: rgba(255,255,255,0.1); padding: 15px; border-radius: 8px; border-left: 4px solid ${queueGrowthRate > 0 ? colors.red : colors.teal};">
<div style="font-size: 0.9em; opacity: 0.9; margin-bottom: 5px;">Queue Growth</div>
<div style="font-size: 2em; font-weight: bold;">${queueGrowthRate > 0 ? '+' + queueGrowthRate.toFixed(0) : '0'}</div>
<div style="font-size: 0.85em; opacity: 0.8; margin-top: 5px;">msg/sec ${queueGrowthRate > 0 ? '(BACKLOG!)' : '(stable)'}</div>
</div>
</div>
<div style="margin-top: 20px; padding: 15px; background: rgba(255,255,255,0.05); border-radius: 8px; border: 1px solid rgba(255,255,255,0.1);">
<strong>Prefetch Analysis:</strong> With prefetch=${prefetchCount}, network RTT adds ~${prefetchLatencyOverhead} ms average latency per message.
${prefetchCount < 10 ? 'Low prefetch increases network overhead. Consider 50-100 for batch processing.' : ''}
${prefetchCount > 200 ? ' High prefetch may delay message redistribution if a consumer fails.' : ''}
</div>
${queueGrowthRate > 0 ? html`
<div style="margin-top: 15px; padding: 15px; background: rgba(231, 76, 60, 0.2); border-radius: 8px; border-left: 4px solid ${colors.red};">
<strong>Warning:</strong> Queue fills at ${queueGrowthRate.toFixed(0)} msg/sec. A 10,000-message queue fills in ${timeToFillQueue} seconds.
Add ${Math.ceil(queueGrowthRate / consumerThroughput)} more consumer(s) or reduce processing time to ${(1000 / (publishRate / minConsumers)).toFixed(1)} ms.
</div>
` : ''}
</div>
`AMQP Throughput & Scaling Calculator
AMQP Throughput & Scaling Calculator
animation
amqp
protocols
messaging
Try Change consumer processing time to 20 ms/msg.
Observe Watch Consumers Needed, Total Capacity, Utilization, and Queue Growth at 20 ms/msg.
Explain Explain why increasing prefetch count reduces network overhead with network RTT fixed at 5 ms.
Technical boundaries. Consumer count rounds up to meet publish rate, so calculated Queue Growth stays zero. Prefetch latency uses a fixed 5 ms network RTT.
AMQP Throughput & Scaling Calculator
Determine consumer count requirements and identify throughput bottlenecks.