viewof dlqTTL = Inputs.range([0, 600], {value: 60, step: 10, label: "Message TTL (seconds, 0 = no TTL)"})
viewof dlqMaxLen = Inputs.range([0, 100], {value: 20, step: 5, label: "Max queue length (0 = unlimited)"})
viewof dlqMaxRetries = Inputs.range([1, 10], {value: 3, step: 1, label: "Max retry attempts"})
viewof dlqIncomingRate = Inputs.range([1, 20], {value: 5, step: 1, label: "Incoming messages/sec"})
viewof dlqProcessRate = Inputs.range([1, 20], {value: 3, step: 1, label: "Processing rate/sec"})
viewof dlqFailPct = Inputs.range([0, 100], {value: 30, step: 5, label: "Processing failure rate (%)"})Dead Letter Queue Scenario Explorer
Dead Letter Queue Scenario Explorer
Try Set incoming messages/sec to 5 and processing rate/sec to 3.
Observe Watch Still in Queue, In DLQ, and DLQ Breakdown by Trigger over the 30-second window.
Explain Explain why 5 incoming messages/sec and 3 processing rate/sec cause queue buildup.
Technical boundaries. The simulation uses a 30-second window. TTL expiration uses a fraction of queue size, and failed processing uses a random rejection with probability based on max retry attempts.
Configure a queue with DLQ settings and simulate message processing. Watch how messages flow from the main queue to the dead letter queue under different failure conditions.
dlqSim = {
const duration = 30;
const incoming = dlqIncomingRate;
const processing = dlqProcessRate;
const failRate = dlqFailPct / 100;
const maxLen = dlqMaxLen === 0 ? Infinity : dlqMaxLen;
const maxRetries = dlqMaxRetries;
const ttl = dlqTTL;
let queueSize = 0, dlqSize = 0;
let totalIn = 0, processed = 0, dlqByReject = 0, dlqByTTL = 0, dlqByOverflow = 0;
const timeline = [];
for (let t = 0; t < duration; t++) {
let newMsgs = incoming;
let overflow = 0;
if (queueSize + newMsgs > maxLen) {
overflow = (queueSize + newMsgs) - maxLen;
newMsgs = Math.max(0, maxLen - queueSize);
dlqByOverflow += overflow;
dlqSize += overflow;
}
queueSize += newMsgs;
totalIn += incoming;
if (ttl > 0 && queueSize > 0) {
const expired = Math.min(queueSize, Math.floor(queueSize * (1 / ttl)));
if (t > ttl && expired > 0) {
queueSize -= expired;
dlqByTTL += expired;
dlqSize += expired;
}
}
const canProcess = Math.min(queueSize, processing);
for (let m = 0; m < canProcess; m++) {
queueSize--;
if (Math.random() < failRate) {
if (Math.random() < 1 / maxRetries) {
dlqByReject++;
dlqSize++;
} else {
queueSize++;
}
} else {
processed++;
}
}
timeline.push({t, queueSize, dlqSize});
}
return {totalIn, processed, dlqSize, dlqByReject, dlqByTTL, dlqByOverflow, queueSize, timeline};
}
html`
<div style="background: #f8f9fa; padding: 20px; border-radius: 8px; border-left: 4px solid #E74C3C; margin: 20px 0;">
<div style="font-size: 15px; font-weight: bold; color: #2C3E50; margin-bottom: 15px;">DLQ Simulation (30-second window)</div>
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 15px;">
<div style="background: white; padding: 12px; border-radius: 6px; text-align: center;">
<div style="font-size: 11px; color: #7F8C8D;">Total Incoming</div>
<div style="font-size: 20px; font-weight: bold; color: #3498DB;">${dlqSim.totalIn}</div>
</div>
<div style="background: white; padding: 12px; border-radius: 6px; text-align: center;">
<div style="font-size: 11px; color: #7F8C8D;">Processed OK</div>
<div style="font-size: 20px; font-weight: bold; color: #16A085;">${dlqSim.processed}</div>
</div>
<div style="background: white; padding: 12px; border-radius: 6px; text-align: center;">
<div style="font-size: 11px; color: #7F8C8D;">Still in Queue</div>
<div style="font-size: 20px; font-weight: bold; color: #E67E22;">${dlqSim.queueSize}</div>
</div>
<div style="background: white; padding: 12px; border-radius: 6px; text-align: center;">
<div style="font-size: 11px; color: #7F8C8D;">In DLQ</div>
<div style="font-size: 20px; font-weight: bold; color: #E74C3C;">${dlqSim.dlqSize}</div>
</div>
</div>
<div style="background: white; padding: 15px; border-radius: 6px; margin-bottom: 12px;">
<div style="font-size: 12px; color: #7F8C8D; margin-bottom: 8px;">DLQ Breakdown by Trigger</div>
<div style="display: flex; gap: 0; border-radius: 6px; overflow: hidden; height: 30px; background: #ecf0f1;">
${dlqSim.dlqByReject > 0 ? `<div style="background: #E74C3C; flex: ${dlqSim.dlqByReject}; display: flex; align-items: center; justify-content: center; color: white; font-size: 10px; font-weight: bold; min-width: ${dlqSim.dlqByReject > 0 ? 40 : 0}px;">NACK ${dlqSim.dlqByReject}</div>` : ''}
${dlqSim.dlqByTTL > 0 ? `<div style="background: #9B59B6; flex: ${dlqSim.dlqByTTL}; display: flex; align-items: center; justify-content: center; color: white; font-size: 10px; font-weight: bold; min-width: 40px;">TTL ${dlqSim.dlqByTTL}</div>` : ''}
${dlqSim.dlqByOverflow > 0 ? `<div style="background: #E67E22; flex: ${dlqSim.dlqByOverflow}; display: flex; align-items: center; justify-content: center; color: white; font-size: 10px; font-weight: bold; min-width: 40px;">Overflow ${dlqSim.dlqByOverflow}</div>` : ''}
${dlqSim.dlqSize === 0 ? `<div style="flex: 1; display: flex; align-items: center; justify-content: center; color: #7F8C8D; font-size: 11px;">No messages in DLQ</div>` : ''}
</div>
<div style="display: flex; gap: 15px; font-size: 11px; color: #7F8C8D; margin-top: 8px;">
<span><span style="display:inline-block;width:10px;height:10px;background:#E74C3C;border-radius:2px;vertical-align:middle;margin-right:3px;"></span> Consumer reject (NACK)</span>
<span><span style="display:inline-block;width:10px;height:10px;background:#9B59B6;border-radius:2px;vertical-align:middle;margin-right:3px;"></span> TTL expired</span>
<span><span style="display:inline-block;width:10px;height:10px;background:#E67E22;border-radius:2px;vertical-align:middle;margin-right:3px;"></span> Queue overflow</span>
</div>
</div>
<div style="background: white; padding: 12px; border-radius: 6px;">
<div style="font-size: 12px; color: #2C3E50; line-height: 1.7;">
<strong>Analysis:</strong>
${dlqIncomingRate > dlqProcessRate ? `Incoming rate (${dlqIncomingRate}/s) exceeds processing rate (${dlqProcessRate}/s), causing queue buildup.` : `Processing rate (${dlqProcessRate}/s) keeps up with incoming rate (${dlqIncomingRate}/s).`}
${dlqSim.dlqByOverflow > 0 ? ` Queue length limit caused ${dlqSim.dlqByOverflow} messages to overflow to DLQ -- consider increasing max queue length or adding consumers.` : ''}
${dlqSim.dlqByReject > 0 ? ` ${dlqSim.dlqByReject} messages exhausted retries and were rejected to DLQ -- investigate processing failures.` : ''}
${dlqSim.dlqSize === 0 ? ' No messages reached the DLQ. The system is handling the current load well.' : ''}
</div>
</div>
</div>
`