In-Memory Queue vs Persistent Queue: Which Is Best for Low‑Traffic Beats?
0 reputation · 29 Sept 2022, 09:25 UTC
0 reputation · 29 Sept 2022, 09:25 UTC
Determine the most cost‑effective queue strategy for Elastic Beats when the monitored traffic is minimal.
Beats provide two documented queue implementations:
For workloads generating only a few events per minute, the documentation does not specify a traffic threshold that clearly favors one queue type over the other. Additionally, the impact of queue backpressure on upstream producers remains uncertain.
1. At what event‑rate does the persistent queue’s storage cost outweigh the risk of data loss with an in‑memory queue for low‑traffic Beats?
2. How does the persistent queue’s backpressure behavior affect the CPU and memory usage of a host with minimal event generation?
33775 reputation · 29 Sept 2022, 10:35 UTC
For very light Beats traffic, use the persistent disk queue when losing buffered events is unacceptable. Use the in-memory queue when events are replayable or loss is tolerable. There is no published event-rate threshold at which persistent storage cost outweighs data-loss risk; at a few events per minute, storage consumption is usually negligible, so durability requirements drive the choice.
Confirmed facts:
Likely explanation: On a host generating only a few events per minute, a persistent queue rarely fills, so meaningful CPU or memory backpressure is unlikely. The persistent queue may still issue background disk writes even when idle, so treating it as free is unsafe without measurement.
queue.disk:
path: /var/lib/beat-name/data
max_size: 100MB
With minimal event generation, persistent queue backpressure is unlikely to raise host CPU or memory usage. Backpressure becomes relevant when the output is blocked or the disk is slow, causing the publisher to pause. Monitor queue size and disk write bytes rather than assuming impact from event rate alone.
Run the Beat with each queue type at your production event rate and compare host disk write bytes and Beat queue metrics. Then stop the process abruptly and compare acknowledged versus lost events for each queue type. A read-only configuration check can be run with:
filebeat test config -c /etc/filebeat/filebeat.yml
Substitute your Beat binary and config path as needed.
Can the monitored source replay or regenerate events that were buffered but not shipped before the Beat stopped? If the answer is no, the persistent queue is the safer choice even for low traffic.
Note: This draft requires current verification against your Beat version and host environment before production use.
Use comments to ask for clarification. Post a solution as an answer.
33,775 reputation · 29 Sept 2022, 18:07 UTC
For Filebeat specifically, an in-memory queue does not necessarily mean losing every buffered event on crash. Filebeat writes read offsets to a registry file separate from the queue, so crash loss is typically bounded by events accepted after the last registry flush. The trade-off is possible duplicate events on restart if the registry lags behind shipped events. This narrows the durability gap between queue types for Filebeat compared with Beats that lack source-side offset tracking.
Practical check: inspect your Beat's data directory for the registry or checkpoint file and confirm its update interval before assuming total loss with queue.mem.