viewof numBindings = Inputs.range([10, 500], {
value: 100,
step: 10,
label: "Number of bindings in exchange:"
})
viewof matchTime = Inputs.range([5, 50], {
value: 10,
step: 5,
label: "Pattern match time per binding (μs):",
format: x => `${x} μs`
})
viewof matchingQueues = Inputs.range([1, 10], {
value: 3,
step: 1,
label: "Number of matching queues:"
})
viewof payloadSize = Inputs.range([50, 1000], {
value: 200,
step: 50,
label: "Message payload size (bytes):",
format: x => `${x} B`
})
viewof messagesPerSec = Inputs.range([100, 10000], {
value: 4800,
step: 100,
label: "Messages per second:",
format: x => x.toLocaleString()
})
// Calculations
routingTime = numBindings * matchTime / 1000 // Convert to ms
metadataSize = 80 // bytes
memoryOverhead = matchingQueues * (payloadSize + metadataSize)
cpuTimePerSec = messagesPerSec * routingTime / 1000 // CPU-seconds per wall-clock second
coresNeeded = Math.ceil(cpuTimePerSec)
html`<div style="background: #f8f9fa; border-left: 4px solid #2C3E50; padding: 15px; margin-top: 15px; font-family: Arial, sans-serif;">
<h4 style="color: #2C3E50; margin-top: 0;">Illustrative Routing Cost Model</h4>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 10px;">
<div style="background: white; padding: 12px; border-radius: 4px; border: 1px solid #e0e0e0;">
<div style="color: #7F8C8D; font-size: 12px; text-transform: uppercase; margin-bottom: 5px;">Routing Time</div>
<div style="color: #16A085; font-size: 24px; font-weight: bold;">${routingTime.toFixed(2)} ms</div>
<div style="color: #7F8C8D; font-size: 11px; margin-top: 3px;">Assumes each binding costs the entered time</div>
</div>
<div style="background: white; padding: 12px; border-radius: 4px; border: 1px solid #e0e0e0;">
<div style="color: #7F8C8D; font-size: 12px; text-transform: uppercase; margin-bottom: 5px;">Memory Overhead</div>
<div style="color: #E67E22; font-size: 24px; font-weight: bold;">${(memoryOverhead / 1024).toFixed(2)} KB</div>
<div style="color: #7F8C8D; font-size: 11px; margin-top: 3px;">Illustrative ${matchingQueues} copies; broker memory use varies</div>
</div>
<div style="background: white; padding: 12px; border-radius: 4px; border: 1px solid #e0e0e0;">
<div style="color: #7F8C8D; font-size: 12px; text-transform: uppercase; margin-bottom: 5px;">CPU Load</div>
<div style="color: ${cpuTimePerSec > 4 ? '#E74C3C' : '#16A085'}; font-size: 24px; font-weight: bold;">${cpuTimePerSec.toFixed(2)} CPU-s/s</div>
<div style="color: #7F8C8D; font-size: 11px; margin-top: 3px;">CPU-seconds per wall-clock second</div>
</div>
<div style="background: white; padding: 12px; border-radius: 4px; border: 1px solid #e0e0e0;">
<div style="color: #7F8C8D; font-size: 12px; text-transform: uppercase; margin-bottom: 5px;">Cores Needed</div>
<div style="color: #3498DB; font-size: 24px; font-weight: bold;">${coresNeeded}</div>
<div style="color: #7F8C8D; font-size: 11px; margin-top: 3px;">Routing-only CPU equivalent, not host sizing</div>
</div>
</div>
<div style="margin-top: 12px; padding: 10px; background: ${cpuTimePerSec > 4 ? '#fee' : '#efe'}; border-radius: 4px; font-size: 13px; color: #2C3E50;">
${cpuTimePerSec > 4
? `Warning: High CPU load detected. Consider reducing pattern complexity or distributing load across multiple brokers.`
: `This assumed routing load equals about ${coresNeeded} CPU core(s); benchmark the broker before sizing a host.`}
</div>
<div style="margin-top: 12px; padding: 12px; background: white; border-radius: 4px; border: 1px solid #e0e0e0;">
<div style="color: #2C3E50; font-weight: bold; margin-bottom: 8px;">Formula explanation</div>
<ul style="margin: 0; padding-left: 1.1rem; color: #2C3E50; font-size: 13px;">
<li><strong>Routing time:</strong> ${numBindings} bindings × ${matchTime} μs = ${routingTime.toFixed(2)} ms</li>
<li><strong>Memory overhead:</strong> ${matchingQueues} queue copies × (${payloadSize} B payload + 80 B metadata) = ${memoryOverhead} B</li>
<li><strong>CPU load:</strong> ${messagesPerSec.toLocaleString()} msg/s × ${routingTime.toFixed(3)} ms routing time = ${cpuTimePerSec.toFixed(2)} CPU-s/s</li>
</ul>
</div>
</div>`AMQP Message Routing Performance
AMQP Message Routing Performance
animation
amqp
protocols
messaging
Try Change number of bindings in exchange to 200.
Observe Watch Routing Time, Memory Overhead, CPU Load, and Cores Needed with 200 bindings.
Explain Explain why 200 bindings increase routing time when pattern match time per binding stays at 10 μs.
Technical boundaries. Each binding costs the entered time, and each queue copy includes 80 B metadata. Cores Needed is a routing-only CPU equivalent; broker memory use varies.
Tip
Checkpoint: Message Routing Flow
Checkpoint: Message Routing Flow
You now know:
- Producers publish to exchanges, not directly to application-owned queues.
- The broker evaluates bindings, then copies the message only into matching queues.
- The default example shows a 100-binding exchange, 3 matching queues, a 200-byte payload, and 4,800 messages per second, so routing cost is a design input rather than a hidden detail.
Follow One Message Through the Routing Parts
Give one message an identity, route it to two intended consumers, change one binding, repeat it, and restart a consumer. Record the exchange, queue, route key, receiver, and final state. A live connection does not prove correct routing.