Why remote write falls behind and when to tune its queues
When a Prometheus server sends samples to a long-term store such as Thanos, Grafana Mimir or VictoriaMetrics, the first sign of trouble is usually data that arrives late in the store, or a write-ahead log (WAL) on the Prometheus host that keeps growing. Remote write is the part of Prometheus that reads samples out of its local storage and sends them to the remote endpoint. It does not keep a second copy of the data: the storage docs state that local storage is not clustered or replicated and should be run like any other single-node database, so the samples waiting in remote write queues are the ones that still need to leave the server. Prometheus holds these samples in queues split across shards, and each shard sends batches in parallel. The defaults often work well, and the first step is to confirm that the sample rate has actually outgrown them rather than changing settings by habit.
The defaults are a queue capacity of 10000 and a max_samples_per_send of 2000, under queue_config in the remote_write section of the configuration file. Per the Prometheus remote write tuning guidance, these values keep the memory used by each shard under 2 MB. The same guidance recommends setting capacity at 3 to 10 times max_samples_per_send, so a larger batch size should come with a larger queue. Before you change anything, check the remote write metrics on the Prometheus server to see whether samples are pending and whether the remote endpoint is slow, rejecting data, or limiting throughput. Tuning shards or queue sizes cannot fix a store that is overloaded, and it can make memory use worse on the Prometheus host.
Tuning becomes necessary when the rate of samples produced per second, multiplied by the time the endpoint needs to accept them, exceeds what the current shards can send. Ask your team to measure the ingestion rate, the number of active series, and the pending sample count over a representative period, including peak load and any restart or outage window. Also confirm with your store vendor or operator what write throughput and retry behavior the endpoint supports and how long it can be unavailable before samples are dropped. Those answers determine whether you adjust queue settings, add capacity to the store, reduce what Prometheus sends, or split the scrape load, and they should be written down before the change is made.
How samples flow from scrape to remote storage
Samples start when Prometheus scrapes a target and are appended to the head block and the write-ahead log. The remote write code then reads from the WAL and places samples into a queue, which is split across shards. Each shard collects batches of up to max_samples_per_send samples and sends them to the remote endpoint. When the remote side slows down, samples back up in the queues and the WAL, so check pending samples and queue fill before changing shard counts.
Samples move from scrape through the WAL and shards to remote storage, with backlog accumulating in the queue.
Which queue_config settings to change and when
The capacity setting controls how many samples each shard's in-memory queue can hold before Prometheus must wait for the remote endpoint to accept more. The default is 10000. A queue that stays full while the receiver answers normally usually means the shard is simply not sending fast enough, and a larger queue only delays the problem while adding memory. Raising capacity makes sense when short bursts of ingestion, such as a restart that releases a backlog of scrapes, fill the queue and then drain without growing. The trade-off is memory: each queued sample is held in RAM for the life of the queue, so capacity is the first setting to review when a server is near its memory limit. The Prometheus guidance recommends keeping capacity at 3 to 10 times max_samples_per_send.
- Symptom to watch: the queue stays near full during steady traffic, not only during bursts.
- Default to keep in mind: 10000, with
max_samples_per_sendat its default of 2000. - Memory trade-off: more capacity means more samples held in RAM per shard.
- Receiver load: capacity does not change request rate, so it does not add pressure on the receiver by itself.
- Typical mistake: raising capacity to hide a receiver that is slow or unreachable.
Before changing capacity, confirm the pending-sample and failed-send metrics for your version in the remote write documentation.
The max_shards setting caps how many parallel queues Prometheus runs for a remote write endpoint. Each shard reads from the write-ahead log, batches samples and sends them over its own connection, so more shards generally mean more samples in flight at once. Prometheus scales shard count up when samples arrive faster than the current shards can send, and max_shards is the ceiling. Increase it when the pending-sample count grows steadily and the receiver is healthy and has capacity to spare. Do not raise it when the receiver is rejecting requests or timing out, since more shards then multiply the load on a struggling endpoint. Every shard also has its own queue, so the total memory cost grows with the shard count.
- Symptom to watch: pending samples climb while the receiver's latency and error rate stay flat.
- Memory trade-off: each shard carries its own queue, so memory grows with the number of shards.
- Receiver load: more shards send more concurrent requests, which can overwhelm an endpoint that was already near its limit.
- Check first: whether the receiver is the bottleneck, by reviewing its ingestion metrics and error codes.
- Typical mistake: setting a high ceiling and assuming Prometheus will scale only when needed without measuring memory afterward.
Ask the receiver team for their accepted concurrency and rate limits before raising the ceiling.
The max_samples_per_send setting limits how many samples go into one remote write request. The default is 2000. Larger batches reduce per-request overhead, so a shard can move more samples per second with fewer round trips. Smaller batches send sooner and produce smaller payloads, which helps when a receiver rejects requests above a size limit or when a single failed batch must be retried quickly. The batch size also sets the upper bound for the capacity recommendation, because the queue needs room for several full batches. Changing this value affects how much data is in each retry, so a larger batch also means a larger amount of work repeated after a failure.
- Symptom to watch: throughput is low even though shards are available, which can point to small batches.
- Opposite symptom: requests fail with payload or timeout errors at the receiver, which can point to batches that are too large.
- Memory trade-off: larger batches hold more data in memory during construction and sending.
- Receiver load: larger requests are fewer but heavier, and smaller requests are more frequent.
- Keep the ratio: adjust capacity alongside this value so the 3 to 10 times guidance still holds.
Confirm the maximum request size and rate limits your receiver enforces before changing the batch size.
The batch timeout and retry settings control how long a request may wait for the receiver and how Prometheus behaves after a failed send. These settings matter most when the network or receiver is intermittent, not when ingestion simply exceeds throughput. A short timeout frees shards quickly so they can try again, but it may cut off requests that a slow receiver would have accepted. A long timeout keeps shards occupied and lets the queue grow during an outage. Retries recover from transient errors, but aggressive retry against a failing receiver multiplies load at the moment it can least absorb it. Check the exact key names and defaults in the configuration reference for your Prometheus version before editing them, since these settings are easy to confuse with scrape timeouts.
- Symptom to watch: bursts of timeout errors on the receiver side while its CPU and storage look normal.
- Symptom with long timeouts: shards appear busy for long periods, and pending samples rise during a brief outage.
- Memory trade-off: long waits keep more samples queued in memory.
- Receiver load: retries and quick reconnects increase requests exactly when the receiver is recovering.
- Separate from scrape timeouts: these control remote write, not how long a target has to answer a scrape.
Ask your receiver team how it behaves during partial outages, then test a change in a non-production environment first.
What each shard costs in memory and how to size max_shards
Each shard in the remote write queue is a parallel sender with its own buffer, so shard count multiplies memory cost. The remote write tuning guidance says the default values of capacity 10000 and max_samples_per_send 2000 keep the memory held by each shard under 2 MB. That figure is per shard, so 20 shards at the default settings can hold roughly 40 MB of queued samples before any overhead from the rest of the process. Treat max_shards as a memory budget you spend deliberately, not as a throughput dial you turn up until the lag goes away. The shard count also depends on the ingestion rate, which you must measure on your own server (for example, with the rate of prometheus_remote_storage_samples_in_total over a representative week), because no sample-rate figure applies to every estate.
The three settings work together. capacity is how many samples each shard can hold while it waits to send, and max_samples_per_send is how many samples go into one request. The guidance recommends setting capacity at 3 to 10 times max_samples_per_send, so a larger batch size needs a proportionally larger buffer. Raising max_shards adds parallel senders, which only helps if the receiver can accept more concurrent writes. A backlog that grows after you add shards often means the receiver, such as a Thanos Receive, Mimir or VictoriaMetrics endpoint, is now the bottleneck, and more shards will push its latency and error rate higher while the local queue still looks full. Check the receiver's own ingest metrics and error responses before you change the sender.
Size in steps. Change one value at a time, starting from the defaults, and raise max_shards by a small increment while you watch Prometheus process memory, the pending samples and the receiver's latency and error rate over a full business cycle. Confirm with your receiver's documentation what concurrency and batch size it accepts, and ask the receiver team what limits they enforce on your tenant. Keep headroom for queries and rule evaluation on the same process, since those also consume memory and do not appear in the queue numbers. If the backlog persists after the receiver is healthy and memory is still comfortable, the next step is usually to reduce ingestion or split the scrape load, not to keep adding shards.
The 2-hour WAL limit and the metrics that show pending samples
Remote write falls behind in stages: the queue fills, sends fail, and eventually data that is still in the local write-ahead log can age out before it reaches storage. The cards below cover the window that limits recovery and the signals that show you are approaching it, so you can alert while there is still time to act.
The WAL replay window
Prometheus keeps recent samples in a write-ahead log (WAL) and cuts them into two-hour blocks. Remote write can only resend samples that are still held in that log, so an outage longer than the window the log covers can leave a gap in the external store. Confirm the exact replay behavior, including how the WAL is retained and how it is replayed after a restart, in the storage and remote write docs before you size an outage budget.
Storage docsPending samples and queue fill
Each remote write queue holds samples waiting to be sent, bounded by the capacity setting in queue_config. A queue that stays near its capacity means senders cannot keep up with ingestion. Confirm the names of the pending sample and queue fill metrics in the Prometheus metrics reference for your version, then alert when the backlog grows over a sustained period, not on a single spike.
Failed and retried sends
Failed and retried send counters show whether the receiver is refusing or timing out requests. Retries increase load on a receiver that is already struggling, so a rising retry rate often precedes a growing backlog. Split the counters by endpoint where your version allows it, and check the receiver's own logs for status codes, timeouts and request size limits before changing queue settings.
Shard count changes
Prometheus adjusts the number of shards per queue between the minimum and max_shards based on how fast samples arrive and are sent. A shard count that climbs to its ceiling and stays there means the queue is short of parallel senders. Each shard adds memory, and the docs estimate under 2 MB per shard at default queue values, so raise max_shards only after you confirm the receiver can accept the extra concurrency.
Samples dropped on the receiver
Some samples are rejected by the receiver even when Prometheus sends them successfully. Common causes include out-of-order or too-old samples, per-tenant rate limits and label limits. These drops may not appear as failed sends on the Prometheus side, so check the receiver's own metrics and logs. Confirm which rejection counters your receiver exposes before you trust a green dashboard for the sending side.
Alerting before the WAL is at risk
Build an alert that fires while a growing backlog can still be cleared within the WAL window, not when the window has already closed. Combine a queue fill alert, a sustained retry rate and a receiver health check. Test the alert by briefly stopping the receiver in a non-production environment, then confirm that the backlog drains after recovery and that the alert clears on its own.
How to tune remote write in a staged rollout
This sequence moves remote write from default settings to tuned values one change at a time, with measurements, alerts and a rollback path at each stage. The result is a documented queue configuration that the receiver has been shown to handle under load.
Measure current ingestion and pending samples
Before changing anything, record the sample ingestion rate, the number of active series, and the remote write pending samples and shard counts on each Prometheus server that sends data. Your Prometheus team does this from the server's own metrics and the existing dashboards, and it should cover a normal business day and a peak period. The step is done when you have a baseline table per server that shows whether the queue already backs up at peak, and you can state which server is the one you plan to tune.
Set the remote write endpoint with default queue settings
Configure the remote_write block with the receiver URL, authentication and TLS settings, and leave queue_config at its defaults first. Defaults keep each shard's memory under the figure stated in the topic's researched values, so the first run measures the receiver and the link rather than your tuning guesses. Confirm the receiver's required headers, tenant identifiers and maximum request size with the team that runs it. The step is done when samples arrive at the receiver and the sending server reports no failed requests over a full observation window.
Add dashboards and alerts for pending samples and failures
Build a dashboard that charts pending samples, shard count, samples sent, and failed or retried sends for each remote write target, then add alert rules for a sustained growth in pending samples and for a rising failure rate. Your alerting owner should route these alerts to the team that operates the receiver, because a lagging queue often points to the receiver rather than the sender. The step is done when each alert has been tested with a short induced condition, such as a paused receiver in a test environment, and the alert fires and resolves as expected.
Change one queue parameter at a time under load
Adjust a single queue_config value, such as max_shards, max_samples_per_send or capacity, in a controlled window and record the exact before and after values. Keep the other values fixed so that any change in pending samples, memory use or receiver errors can be traced to one setting. Watch the memory of the Prometheus process while the change is active, because each shard adds memory use. The step is done when the server has run through a peak period with the change and the dashboard shows whether pending samples stayed flat or dropped.
Verify the receiver accepts the higher rate
Raise the sending rate only as far as the receiver shows headroom, and confirm this with the receiver's own metrics for ingestion latency, rejected samples, out-of-order errors and resource saturation. Ask the receiver operator to state its limits in writing, including per-tenant or per-request caps, since a higher sending rate can trip limits that the sender never reports. The step is done when the receiver stays within its own limits at the new rate for a full peak period and the sender's failure count remains at its baseline.
Document the chosen values and a rollback plan
Write down the final queue_config values for each sending server, the baseline and post-change measurements, the receiver limits you verified, and the date of each change. Include a rollback procedure that restores the previous configuration file and reloads Prometheus, and state who may trigger it and what signal would prompt it. Store the record with the configuration in version control so the values are reviewed alongside future changes. The step is done when another engineer can read the record and reproduce the configuration, and the rollback has been rehearsed in a non-production environment.
Security and operational risks of remote write endpoints
A remote write endpoint receives every sample Prometheus sends, so its transport security, credential handling, tenant isolation and change controls matter as much as queue settings. The cards below cover the risks that tuning work tends to touch: how credentials travel, where they are stored, how config changes reach the server, who can write into which tenant, and whether the host still has room for scraping and queries.
TLS and basic auth in transit
Remote write is configured under remote_write with a URL, and basic authentication sends a username and password on every request. Without TLS those credentials cross the network in cleartext. Prometheus supports TLS with TLS 1.2 as the minimum and client certificate authentication, so confirm the endpoint's https URL, its certificate chain, and whether the receiver accepts client certificates before you raise throughput. Never send basic auth over plain HTTP.
Secrets for remote write credentials
Tokens and passwords for the receiver should not be written inline in a configuration file that is copied into version control or shared with the team. Use a file-based secret, restrict read permissions on the Prometheus configuration and secret files to the service account, and keep the bcrypt-hashed passwords used for Prometheus's own web authentication separate from the credentials it presents to a receiver. Rotate credentials on a schedule your team can actually follow, and confirm the receiver's token scope before issuing it.
Admin and lifecycle endpoints during changes
Tuning often means editing queue_config and reloading. The --web.enable-lifecycle flag enables reload and shutdown endpoints, and --web.enable-admin-api enables destructive operations. Both are disabled by default. Keep them off on production servers unless a reload pipeline needs them, restrict the listener to trusted networks, and make sure a failed reload leaves the previous configuration running. Record who changed the queue settings and when.
Tenant headers on the receiver
Multi-tenant receivers such as Mimir use a tenant header to decide which customer's data a sample belongs to. Set the header with headers in remote_write and confirm that each Prometheus instance writes only to its own tenant. A misconfigured or missing header can mix series from different teams or sites into one tenant. Ask the receiver team which header name it expects, how it rejects unknown tenants, and what limits apply per tenant, because queue tuning can push a tenant past those limits.
Host sizing for scrapes and queries
Larger max_shards and max_samples_per_send values increase concurrent sends and the samples held in memory while batches wait. The shard memory guidance cited for the default queue settings is under 2 MB per shard, so multiply the shard count by your chosen batch size before raising it. Watch CPU, memory and scrape duration after each change, and leave headroom so that queries and scraping still finish when the remote endpoint slows down or the write-ahead log grows.
Questions buyers ask about remote write tuning
How much effort does remote write tuning take?
Effort depends on how far the default queue settings are from what your workload needs, and on how often the workload changes. Tuning starts with measuring: the sample rate, the number of active series, and how fast the receiver accepts writes. A stable estimate needs a test receiver under realistic load, not a single pass against production. Outage history matters because a Prometheus that has previously fallen behind usually needs a larger WAL and queue headroom checked against the outage length you expect. Ask any partner to split the work into measurement, change, and verification phases so you can see which part drives the total.
What drives the cost of tuning remote write?
The main cost is skilled engineering time, plus whatever test capacity you need to reproduce load. Costs go up with a higher sample rate, more series and churn, a receiver that is hard to measure, and several Prometheus servers that each need their own settings. Costs go down when metrics and receiver dashboards already exist and change windows are predictable. Remote write tuning is mostly one-time work, but it recurs when ingestion grows or the receiver changes. Ask for a quote that lists the measurement, test, change and handover steps separately.
Can our internal team tune remote write without a partner?
Yes, if at least one engineer understands Prometheus internals and can read the remote write metrics, and if you have a non-production receiver that can take realistic load. The work is mostly careful measurement and small, reversible changes to queue_config. Teams without that experience often change several values at once and cannot tell which change helped. A partner is more useful when the team lacks time, when the receiver is owned by another group, or when you need the result documented for an assessor. The Prometheus remote write tuning guidance is the natural starting point for either path.
What does the work need from our team?
Tuning needs four things from your side. First, read access to the Prometheus server's metrics and configuration, including the remote write counters. Second, a test receiver or a staging copy of the receiver that can absorb load similar to production. Third, change windows agreed in advance, because queue changes can alter memory use and how fast data reaches the receiver. Fourth, a named owner for the receiver, who can confirm its ingest limits and error responses. Without these, the work stops at estimates and cannot be verified.
What does a fixed-scope engagement with DeployOpen cover?
A fixed-scope engagement covers the agreed systems, deliverables and timeline written down before work starts. For remote write tuning, that normally means reviewing the current queue settings and metrics, reproducing load on a test receiver, proposing and applying changes within agreed windows, verifying results, and documenting the final configuration and alert thresholds for pending samples. It does not include changes to the receiver itself unless the scope says so. Ask for the list of systems, the test method and the handover documents in the written scope. DeployOpen does not publish a price list, so the quote follows from that scope.
When should we split a server instead of raising the shard count?
Raise shards only while the queue is the bottleneck and memory has headroom. Each shard carries its own queue and buffer, so more shards add memory cost, and the Prometheus docs recommend keeping queue capacity between 3 and 10 times max_samples_per_send. If the server is limited by active series, scrape load or query load, or if the receiver cannot take more parallel writes, more shards will not fix the problem. In those cases, consider splitting targets across servers, using federation for aggregated series, or moving to a central long-term store. Each option changes how queries and alerts work, so decide before the change, not after. Sizing guidance lives in your server's disk and memory review.
What signals show remote write is falling behind?
The clearest signal is a growing number of pending samples in the remote write metrics while the receiver keeps accepting writes. Watch for the queue reaching capacity, shards being added repeatedly, and failed or retried sends. Also check whether the WAL keeps growing, because remote write reads from the WAL, and a long outage can push data past the two-hour WAL boundary that Prometheus stores in blocks. Set alert thresholds from your own baseline, and confirm the exact metric names against your Prometheus version before writing alert rules.
Why a written scope matters before tuning a production sender
Changing remote write settings is a change to a production monitoring path, not a local configuration tweak. The sender in question is the Prometheus server that feeds your long-term store, and a mistake can silently delay or drop the samples your dashboards and alert rules depend on. Before anyone edits queue_config, put the scope in writing: which Prometheus servers are affected, which remote endpoints receive their samples, and who signs off on the change. Name each remote_write block by its target, because one server often feeds more than one destination, and a tuning change meant for one endpoint can shift load on another.
The written scope should also contain the test plan and the rollback. The test plan states what you will measure before and after the change, such as whether the pending samples metric for each queue stays flat or grows under normal and peak ingestion, and how the receiving system's write latency and error rates behave. It should also say which environment is used first and whether it resembles production in series count and scrape interval. The rollback names the previous capacity, max_shards and max_samples_per_send values, the exact file and reload method, and the condition that triggers reverting. Confirm with your platform team whether your Prometheus runs with the lifecycle endpoint enabled, since that determines how the reload is performed in your environment.
Scope also sets the boundary of responsibility. Ask who owns the receiving side, who gets paged if the endpoint rejects writes, and whether the agreed change window matches the period when the server carries its heaviest load. If a partner performs the work, the written scope is the document that defines deliverables, the environments touched and the evidence returned, so that the tuned settings, their memory impact and the monitoring you put in place can be reviewed by your own team afterward. Treat the scope as the control that makes the tuning reversible and reviewable rather than an informal favor to the sender.
How DeployOpen works on this
DeployOpen plans and tunes remote write for Prometheus servers that run in infrastructure you control, starting from measured queue behavior rather than guessed values. The work is delivered as a fixed-scope engagement with written deliverables, and ongoing support is available as a retainer.
How we scope
- Review the current remote write target, Prometheus version and the metrics that show pending samples on your servers.
- Agree in writing which queue settings, receivers and dashboards are in scope before any change is made.
- Confirm the memory budget per server, the WAL retention you can tolerate and the outage window the receiver must absorb.
How we build
- Test capacity, max_shards and max_samples_per_send changes in a staging copy that receives the same sample rate as production.
- Check shard memory against the available headroom and adjust capacity so it stays within a small multiple of max_samples_per_send.
- Verify under load that the queue drains after a simulated receiver slowdown and that the 2-hour WAL limit is not reached.
How we hand over
- Deliver the tuned configuration as files your team can version, review and roll back, with each value's reason recorded.
- Document the alerts on pending samples, failed sends and shard count, with thresholds agreed with your operators.
- Walk your engineers through the test results, the known limits of the chosen values and the steps to retune later.
How we support
- Offer a retainer that covers re-tests after Prometheus upgrades, receiver changes or significant growth in active series.
- Review queue metrics with your team on an agreed schedule and recommend changes in writing before they are applied.
- Confirm with your team, during scoping, which support hours, response expectations and upgrade cadence the retainer should include.

