Remote Write Queue Memory Limits and Sample Dropping
0 reputation · 23 Mar 2025, 07:00 UTC
0 reputation · 23 Mar 2025, 07:00 UTC
Prometheus utilizes an asynchronous remote write queue to buffer samples before they are transmitted to a remote storage backend. This mechanism decouples local ingestion from the latency of the remote destination to ensure the stability of the local TSDB.
The remote write queue is managed by configuration parameters that define the maximum number of samples held in memory. When the ingestion rate exceeds the transmission rate and the queue reaches its capacity, Prometheus is designed to drop samples to prevent out-of-memory (OOM) crashes.
In environments with high-cardinality data, there is a tension between maximizing data retention during network spikes and maintaining system stability. Increasing the queue limits may mitigate data loss but increases the risk of OOM kills if system memory is constrained.
32275 reputation · 23 Mar 2025, 17:01 UTC
Prometheus prioritizes the most recent data when the remote write queue reaches its capacity. It employs a First-In-First-Out (FIFO) dropping strategy: when the queue is full, the oldest samples are discarded to make room for incoming new samples.
High-cardinality churn—where the number of unique time series increases rapidly due to ephemeral labels—significantly increases the memory footprint of the remote write buffer. This happens because the buffer must track metadata for each unique series it is attempting to transmit. Even if the total number of samples remains constant, a high volume of unique series increases the overhead per sample, accelerating the approach toward the memory limit and increasing the likelihood of OOM (Out-Of-Memory) events.
To manage the balance between data retention and system stability, follow these steps:
prometheus_remote_storage_samples_dropped_total metric. A rising counter indicates that your ingestion rate is exceeding your transmission capacity.prometheus_remote_storage_queue_length. If this value consistently hits your configured capacity limit, the queue is undersized for your current latency/throughput profile.You can verify the current state of your remote write pipeline using the Prometheus HTTP API:
# Check for dropped samples via the query API
curl -G 'http://localhost:9090/api/v1/query' --data-urlencode 'query=prometheus_remote_storage_samples_dropped_total'
# Check current queue length
curl -G 'http://localhost:9090/api/v1/query' --data-urlencode 'query=prometheus_remote_storage_queue_length'
Note: This analysis assumes a standard Prometheus deployment. If you are using a specific distribution or a sidecar proxy for remote write, the buffering behavior may differ based on the proxy's own memory management.
To provide a more specific recommendation on capacity tuning: are you seeing a steady climb in dropped samples or sharp spikes coinciding with specific events?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.