viewof buf_samplesPerSec = Inputs.range([1, 1000], {value: 10, step: 1, label: "Samples per Second"})
viewof buf_bytesPerSample = Inputs.select([1, 2, 4, 8], {value: 2, label: "Bytes per Sample"})
viewof buf_maxOutageMin = Inputs.range([5, 480], {value: 60, step: 5, label: "Max Outage Duration (minutes)"})
viewof buf_safetyMargin = Inputs.range([1.0, 3.0], {value: 1.5, step: 0.1, label: "Safety Margin"})
viewof buf_availableRAM = Inputs.range([4, 512], {value: 64, step: 4, label: "Available RAM (KB)"})Buffer Sizing for Outages
Buffer Sizing for Outages
animation
analytics-ml
edge-acquisition
Try Change Max Outage Duration (minutes) to 120.
Observe Compare Full Resolution Buffer and Tiered Retention Buffer in Buffer Sizing Results for 120 minutes.
Explain Describe how 10x Downsampled retention reduces bytes compared with Full Resolution.
Technical boundaries. The rate input must be the peak accepted arrival rate. Safety Margin applies to the full resolution buffer; tiered retention uses 5 minutes full resolution, up to 55 minutes downsampled, then summaries.
NoteBuffer Sizing for Outages
Calculate the required buffer size for your edge device based on sampling rate, expected outage duration, and available memory. The rate input must be the peak accepted arrival rate, not the calm average. See how tiered retention can help when memory is constrained.
buf_outageSeconds = buf_maxOutageMin * 60
buf_minSamples = Math.ceil(buf_samplesPerSec * buf_outageSeconds * buf_safetyMargin)
buf_minBytes = buf_minSamples * buf_bytesPerSample
buf_minKB = buf_minBytes / 1024
buf_fitsInRAM = buf_minKB <= buf_availableRAM
buf_ramPct = (buf_minKB / buf_availableRAM) * 100
// Tiered retention calculation
buf_tier1Min = 5 // Full resolution for last 5 min
buf_tier1Samples = buf_samplesPerSec * buf_tier1Min * 60
buf_tier1Bytes = buf_tier1Samples * buf_bytesPerSample
buf_tier2Min = Math.min(55, Math.max(0, buf_maxOutageMin - buf_tier1Min)) // 10x downsampled
buf_tier2Samples = Math.ceil((buf_samplesPerSec / 10) * buf_tier2Min * 60)
buf_tier2Bytes = buf_tier2Samples * buf_bytesPerSample
buf_tier3Min = Math.max(0, buf_maxOutageMin - buf_tier1Min - buf_tier2Min) // Summary only
buf_tier3Windows = Math.ceil(buf_tier3Min / 5) // 5-min summary windows
buf_tier3Bytes = buf_tier3Windows * 24 // 6 floats per summary
buf_tieredTotal = buf_tier1Bytes + buf_tier2Bytes + buf_tier3Bytes
buf_tieredKB = buf_tieredTotal / 1024
buf_tieredFits = buf_tieredKB <= buf_availableRAM
buf_tieredSavings = buf_minKB > 0 ? ((buf_minKB - buf_tieredKB) / buf_minKB) * 100 : 0html`<div style="background: var(--bs-light, #f8f9fa); border: 1px solid var(--bs-border-color, #dee2e6); border-radius: 8px; padding: 1.2rem; color: var(--bs-body-color);">
<h4 style="margin-top:0; color: #2C3E50;">Buffer Sizing Results</h4>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem;">
<div style="padding: 0.8rem; border-radius: 6px; text-align: center; background: ${buf_fitsInRAM ? 'rgba(22,160,133,0.08)' : 'rgba(231,76,60,0.08)'};">
<div style="font-size: 0.8rem; color: #374151;">Full Resolution Buffer</div>
<div style="font-size: 1.5rem; font-weight: bold; color: ${buf_fitsInRAM ? '#0f6b5c' : '#9f1d1d'};">${buf_minKB < 1024 ? buf_minKB.toFixed(1) + " KB" : (buf_minKB/1024).toFixed(2) + " MB"}</div>
<div style="font-size: 0.85rem; color: ${buf_fitsInRAM ? '#0f6b5c' : '#9f1d1d'};">${buf_fitsInRAM ? "Fits in RAM (" + buf_ramPct.toFixed(0) + "% used)" : "Exceeds RAM! (" + buf_ramPct.toFixed(0) + "% needed)"}</div>
</div>
<div style="padding: 0.8rem; border-radius: 6px; text-align: center; background: ${buf_tieredFits ? 'rgba(22,160,133,0.08)' : 'rgba(230,126,34,0.08)'};">
<div style="font-size: 0.8rem; color: #374151;">Tiered Retention Buffer</div>
<div style="font-size: 1.5rem; font-weight: bold; color: ${buf_tieredFits ? '#0f6b5c' : '#8a4a00'};">${buf_tieredKB < 1024 ? buf_tieredKB.toFixed(1) + " KB" : (buf_tieredKB/1024).toFixed(2) + " MB"}</div>
<div style="font-size: 0.85rem; color: #0d47a1;">${buf_tieredSavings.toFixed(0)}% smaller than full buffer</div>
</div>
</div>
<table style="width:100%; border-collapse: collapse; font-size: 0.85rem;">
<tr style="background: rgba(44,62,80,0.06);">
<th style="padding: 5px 8px; text-align: left;">Retention Tier</th>
<th style="padding: 5px 8px; text-align: center;">Duration</th>
<th style="padding: 5px 8px; text-align: center;">Resolution</th>
<th style="padding: 5px 8px; text-align: right;">Bytes</th>
</tr>
<tr style="border-bottom: 1px solid var(--bs-border-color, #dee2e6);">
<td style="padding: 5px 8px; color: #0f6b5c;">Full Resolution</td>
<td style="padding: 5px 8px; text-align: center;">${buf_tier1Min} min</td>
<td style="padding: 5px 8px; text-align: center;">${buf_samplesPerSec} Hz</td>
<td style="padding: 5px 8px; text-align: right;">${(buf_tier1Bytes/1024).toFixed(1)} KB</td>
</tr>
<tr style="border-bottom: 1px solid var(--bs-border-color, #dee2e6);">
<td style="padding: 5px 8px; color: #0d47a1;">10x Downsampled</td>
<td style="padding: 5px 8px; text-align: center;">${buf_tier2Min} min</td>
<td style="padding: 5px 8px; text-align: center;">${(buf_samplesPerSec/10).toFixed(1)} Hz</td>
<td style="padding: 5px 8px; text-align: right;">${(buf_tier2Bytes/1024).toFixed(1)} KB</td>
</tr>
<tr>
<td style="padding: 5px 8px; color: #474091;">Summary Only</td>
<td style="padding: 5px 8px; text-align: center;">${buf_tier3Min} min</td>
<td style="padding: 5px 8px; text-align: center;">1 per 5 min</td>
<td style="padding: 5px 8px; text-align: right;">${(buf_tier3Bytes/1024).toFixed(1)} KB</td>
</tr>
</table>
${!buf_fitsInRAM && buf_tieredFits ? html`<p style="margin-top: 0.8rem; padding: 0.5rem; background: rgba(22,160,133,0.1); border-radius: 4px; font-size: 0.85rem;"><strong>Recommendation:</strong> Full resolution buffer does not fit in ${buf_availableRAM} KB RAM, but tiered retention fits at ${buf_tieredKB.toFixed(1)} KB. Use tiered retention to survive ${buf_maxOutageMin}-minute outages without data loss.</p>` : !buf_fitsInRAM && !buf_tieredFits ? html`<p style="margin-top: 0.8rem; padding: 0.5rem; background: rgba(231,76,60,0.1); border-radius: 4px; font-size: 0.85rem;"><strong>Warning:</strong> Neither strategy fits in ${buf_availableRAM} KB RAM. Reduce outage tolerance, sampling rate, or add external flash storage.</p>` : html`<p style="margin-top: 0.8rem; padding: 0.5rem; background: rgba(52,152,219,0.06); border-radius: 4px; font-size: 0.85rem;"><strong>Good:</strong> Full resolution buffer fits in RAM. Tiered retention is still recommended as a fallback for unexpectedly long outages.</p>`}
</div>`