Course outline

Prometheus / Advanced: scale, persistence, and safe validation / Lesson 21

Remote-write queue pressure and recovery

Measure remote-write backlog and tune a bounded queue with receiver capacity and data-loss windows in mind.

About 4 min readContent reviewed
On this page

Lesson goals

  • Trace the WAL, shard queues and remote receiver boundary.
  • Interpret backlog alongside throughput and receiver health.
  • Test recovery and resource limits before applying queue changes.

Trace samples to the receiver

A remote-write destination uses a queue that reads from the write-ahead log and sends samples through shards to the remote endpoint. The local server and receiver have different failure and retention boundaries. A rising pending count can indicate a slow receiver, network failure or insufficient sending capacity, but it does not alone identify the cause. Verify the installed Prometheus version and actual queue configuration before acting.

Measure backlog in context

The first expression sums a documented remote-write pending-samples metric for an illustrative lab. It intentionally combines destinations; inspect per-destination labels in the installed version when diagnosing a particular receiver. Compare backlog with ingestion rate, successful sends, retries, receiver limits, CPU, memory and network use. A falling queue after a restart does not prove that all unsent data arrived; verify destination data and the relevant loss window.

promql Inspect a synthetic aggregate backlog
sum(prometheus_remote_storage_samples_pending)

The metric name follows the documented remote-write practice. The aggregate can hide a single destination; inspect its labels in the installed version.

Change a bounded queue deliberately

The configuration fragment shows a synthetic endpoint and queue parameters. Its values are examples, not recommended defaults. Queue capacity and batch size affect memory per shard, while the maximum shard count affects concurrency and receiver load. Test one reviewed change at a time against representative synthetic traffic. A larger queue cannot repair an unavailable receiver indefinitely, and increasing parallelism can overload a constrained destination.

yaml An illustrative bounded remote-write queue
remote_write:
  - url: https://example.com/api/v1/write
    queue_config:
      capacity: 3000
      max_samples_per_send: 1000
      max_shards: 2

The endpoint and numbers are synthetic and unverified. Review actual version, receiver capacity and credentials before configuring a deployment.

Plan interruption and recovery

During a prolonged outage, unsent samples can age beyond what the local write-ahead log retains for replay; the exact operational window depends on the installed implementation and circumstances. Define acceptable loss, alerting and recovery procedures with the receiver owner. Simulate a short outage and restoration in an authorized lab, then compare source and destination series and timestamps. Avoid exposing remote-write credentials in configuration examples, logs or reports.

Verify the full pipeline

With disposable infrastructure, capture baseline throughput, queue depth, memory and receiver behavior. Apply the candidate configuration and repeat the same workload, including a slow receiver and recovery. Check data completeness and timestamp alignment at the destination, not only a green local scrape. Record versions, load and limits; the snippets are illustrative and neither Prometheus nor a remote receiver was executed for this lesson.

Common errors and fixes

A growing queue is fixed only by increasing capacity

Why it happens
The receiver or network bottleneck was not identified.
How to fix it
Measure the whole path and repair the limiting component.
Prevent it next time
Test a controlled slow receiver before tuning.

A queue looks empty after restart and data is assumed complete

Why it happens
Unsent samples may have aged out or been lost.
How to fix it
Compare source and destination data within the relevant time window.
Prevent it next time
Exercise outage and recovery with synthetic series.

More shards overwhelm the receiver

Why it happens
Concurrency was increased without a receiver budget.
How to fix it
Set a bounded policy based on measured capacity.
Prevent it next time
Load-test the full pipeline and monitor resource use.

2 practice exercises

1. The pending-samples metric rises while the receiver returns errors. What should you investigate first?

Show worked solution

Inspect safe receiver errors, network and authentication, and compare send throughput with ingestion. Do not assume queue capacity is the root cause. Test a controlled receiver failure and verify destination recovery.

2. Why is an empty pending queue after a long outage insufficient proof of complete delivery?

Show worked solution

The queue may no longer contain samples that aged out before they were sent. Compare the source and destination series and timestamps, and document the loss window for the installed system.

Key takeaways

  • Backlog, throughput, receiver health and resource use must be read together.
  • Queue tuning does not replace tested recovery or data-completeness checks.

Official references