What Is Batching in the OpenTelemetry Collector?
A friendly, ground-up guide to the simple idea of sending telemetry in groups instead of one piece at a time: what the batch processor does, how it decides when to send, how to tune it, and what can go wrong.
Imagine a small village with a bus stop. If the driver left the stop every time one passenger arrived, the bus would make hundreds of trips each day, burning fuel to carry one person at a time. Instead, the bus waits. It leaves when it is full, or when the timetable says it is time to go, whichever comes first. Fewer trips carry far more people, and everyone still reaches the city on time.
Batching in the OpenTelemetry Collector works exactly like that bus. The Collector receives a huge stream of tiny pieces of telemetry, such as spans, metrics and logs. Instead of forwarding each piece alone, it collects them into groups, called batches, and sends each group together. In this guide, we will learn what batching is, how the Collector decides when to send, and how to set it up wisely, using simple words and everyday examples.
1The Problem: Sending Tiny Pieces Is Wasteful
Before learning the tool, let us feel the problem it solves.
A quick reminder of the Collector
The OpenTelemetry Collector is a standalone program that receives telemetry, which is information that software sends out about itself, such as traces, metrics and logs. It can clean and reshape the data, and then forward it to storage systems, called backends. Inside the Collector, data flows through a pipeline: receivers bring data in, processors work on it, and exporters send it out.
What happens if we send every piece alone?
Think about a busy online store. It may create tens of thousands of spans every second. If the Collector sent each span to the backend in its own network request, several bad things would happen.
- Too many trips. Every network request has a fixed cost: opening a connection, adding headers, waiting for a reply. Doing this thousands of times a second wastes huge effort.
- Poor compression. Compression works by finding repeating patterns. A single tiny message has very few patterns, but a large group of similar messages compresses very well.
- Overloaded backends. Many storage systems prefer fewer, larger writes. A flood of tiny requests can slow them down, trigger rate limits, or raise your bill.
- Higher CPU use. Each send needs work, such as encoding the data and managing connections. Doing it per item multiplies that cost.
Think of a post office. If the delivery van left for every single letter, the post office would need hundreds of vans, and most would travel almost empty. Instead, letters go into bags, and a van takes a full bag at a scheduled time. Batching is the bag.
2So, What Is Batching in the Collector?
The short answer first, and then the details.
Batching in the Collector means holding incoming telemetry for a short time, grouping it into larger bundles, and then sending each bundle on together. In the Collector, this is mainly done by a processor called the batch processor. It works for all three signals: traces, metrics and logs.
The batch processor follows a very simple rule. It sends a batch when either the batch has collected enough items, or enough time has passed since the batch began, whichever happens first. This two-part rule is the heart of batching.
flowchart TD
A["Telemetry arrives from receivers"] --> B["Batch processor collects items"]
B --> C{"Has the batch reached the target size?"}
C -->|Yes| D["Send batch now"]
C -->|No| E{"Has the timeout expired?"}
E -->|Yes| D
E -->|No| B
D --> F["Exporter sends batch to backend"]
What counts as one item?
The batch size is counted in the natural unit of each signal. For traces, it counts spans. For logs, it counts log records. For metrics, it counts data points, which are the individual measurements, and not the number of metrics. This small detail matters when you pick a size, because one metric can contain many data points.
Do not confuse this with batching inside the SDK of your application. The SDK has its own batch span processor and batch log processor, which group data before sending it to the Collector. Collector batching is a second, separate round of grouping that happens later in the journey.
3Core Concepts: The Knobs You Can Turn
The batch processor has only a few settings. Understanding each one is most of the skill.
| Setting | What It Controls | Plain Meaning |
|---|---|---|
timeout | The longest time a batch may wait before being sent | The bus timetable. Even if the bus is empty, it leaves on time. A common default is 200 milliseconds. |
send_batch_size | The number of items that triggers a send | The bus is full and leaves. A common default is 8,192 items. |
send_batch_max_size | The largest batch allowed to leave | A hard cap. Bigger bundles are split into pieces. By default there is no cap. |
metadata_keys | Request details used to keep separate batches for different senders | Separate buses for separate destinations, such as one per customer |
metadata_cardinality_limit | The maximum number of separate batches created by metadata | A safety limit on how many buses can exist at once |
The most confusing pair: send size versus max size
Beginners often think send_batch_size is a strict limit. It is not. It is a trigger. It says, “once I have at least this many items, send.” But a big group of incoming data can arrive all at once, so the batch could end up larger than that number. If you want a firm upper limit, you must set send_batch_max_size. When it is set, the processor splits large bundles so that none is bigger than the limit. The max size must be equal to or larger than the send size.
Imagine a lift with a sign: “Doors close after 8 people.” That is the trigger. But a tour group of 20 walks in together. The lift would carry all 20. If there is also a weight limit sign, “Maximum 12 people,” then the group must be split into two trips. The first sign is the send size. The second is the max size.
Why the max size matters in real life
Many receiving systems refuse messages that are too large. For example, a common default limit for a single network message in the gRPC technology is around four megabytes. If your batches grow bigger than the backend allows, the whole batch may be rejected, and you will lose data or waste retries. A sensible max size keeps each bundle within a safe range.
4Internal Working: What Happens Inside the Processor
Let us follow items as they arrive over a few moments.
sequenceDiagram
participant R as Receiver
participant B as Batch Processor
participant E as Exporter
participant K as Backend
R->>B: 3000 spans arrive
B->>B: Hold items and start timer
R->>B: 6000 more spans arrive
B->>B: Total passes 8192 so size trigger fires
B->>E: Send batch of spans
E->>K: One network request
R->>B: 500 spans arrive
B->>B: Hold items and start timer
B->>B: Timer expires with batch still small
B->>E: Send small batch because of timeout
E->>K: One network request
Items Arrive
A receiver hands telemetry to the batch processor. The processor accepts it quickly and places it in an internal holding area.
The Timer Starts
When the first item enters an empty batch, a clock starts running for the timeout.
A Trigger Fires
Either the item count reaches the send size, or the timer reaches the timeout. Whichever happens first causes a send.
Optional Splitting
If a max size is set and the batch is bigger, the processor cuts it into pieces no larger than the limit.
Hand-Off to the Exporter
The finished batch moves to the next component, usually an exporter, which sends it over the network to a backend.
Flush on Shutdown
When the Collector is shutting down in an orderly way, the processor sends whatever is still waiting, so that little is lost.
A separate batcher for each pipeline
Each pipeline gets its own working copy of a processor. If you list the same batch processor in two pipelines, such as traces and logs, each pipeline has its own independent batch. They do not share items. This keeps signals from mixing.
Batching by sender with metadata
Sometimes one Collector serves several customers or teams, and you must not mix their data in one batch. The batch processor can keep separate batches for each value of chosen request details, called metadata, such as a tenant ID in an incoming request header. This is powerful, but each unique value creates its own batch in memory, which is why there is a cardinality limit to protect the Collector.
5Where Batching Sits in the Pipeline
Order matters, and batching has a favourite spot.
In a pipeline, every processor works on the output of the one before it. The batch processor is normally placed near the end, right before the exporters. The reason is simple: other processors may remove, change or reshape data. If you batch first and filter later, the batches become uneven and smaller than planned, and you have wasted effort.
flowchart LR
R["Receiver"] --> M["Memory Limiter"]
M --> E1["Enrichment"]
E1 --> F["Filter and Redaction"]
F --> S["Sampling"]
S --> B["Batch"]
B --> X["Exporter"]
X --> BK["Backend"]
Memory Limiter First
It protects the Collector at the door. It should see data before anything heavy happens.
Enrich, Filter and Redact
These change or remove data. Do them before batching so batches contain only what will be sent.
Sample Before Batching
Sampling removes data. There is no point packing items that will be thrown away a moment later.
Batch Last
Group what remains into efficient bundles for the trip out.
Think of packing a suitcase. You first decide what to take, remove what is not needed, and wash what is dirty. Only then do you pack everything into the bag. Packing first and sorting later would be a mess. Batching is the final packing step.
A batch processor with tail sampling needs care. Tail sampling waits to see complete traces. Put the batch processor after it, never before, or the batching may scatter spans of the same trace in ways that confuse the sampling decision.
6Why Batching Helps: The Benefits in Detail
Four separate gains come from the same simple idea.
Fewer Requests
One request carries thousands of items. The fixed cost of connecting and waiting for a reply is shared by all of them.
Better Compression
Large groups of similar data shrink much better than tiny messages, so less data travels over the network. This can reduce transfer costs in the cloud.
Gentler on Storage
Backends often handle fewer, larger writes much better than a storm of small ones, and may charge or limit by request count.
Less CPU Per Item
Encoding, connection handling and retries are done once per batch, not once per item.
Smoother Traffic
Bursty input is turned into steadier output. Spikes are absorbed into larger batches instead of hammering the backend.
Lower Bills
Fewer requests, smaller transfers and lighter loads often mean a lower cost for hosting the Collector and for data transfer.
Production Example: The Request Storm
A team once ran a Collector with no batching. Their backend began to reject data because it was getting over fifty thousand small requests each minute. After adding a batch processor with default settings, the same data arrived in a few hundred requests. The rejections stopped, the Collector used less CPU, and the monthly network cost dropped noticeably.
7The Two Buffers: Batch Processor and Exporter Queue
Many beginners do not realise that data can wait in more than one place.
After the batch processor creates a batch, the next step is the exporter. Most exporters have their own sending queue, a waiting line for batches that are ready to be sent, along with retry settings that try again when the backend is briefly unavailable. So there are two places where data waits in memory.
flowchart LR
A["Items arrive"] --> B["Buffer 1: Batch Processor groups items"]
B --> C["Buffer 2: Exporter sending queue holds finished batches"]
C --> D{"Backend accepted the batch?"}
D -->|Yes| E["Done"]
D -->|No| F["Retry with waiting time between attempts"]
F --> C
F --> G["Give up after the retry limit and drop the batch"]
Buffer 1: Batch Processor
- Purpose is to group items into efficient bundles
- Holds data only briefly, controlled by the timeout
- Lives in memory, so data is lost if the Collector crashes
- Does not retry. Its job ends when it hands the batch on
Buffer 2: Exporter Queue
- Purpose is to survive slow or briefly broken backends
- Holds finished batches while retries happen
- Can be in memory, or stored on disk for better survival of restarts
- Has a size limit, and drops data if it overflows
An important honest limit
Because the batch processor accepts data and then sends it later in the background, the sender who gave it the data is usually told “received” long before the data reaches the backend. If the backend later fails for long enough that retries run out, or the Collector crashes, the sender never learns that some data was lost. This is a known trade-off of batching in a processor.
The OpenTelemetry community has been working on moving batching into the exporter’s own sending queue, which can be combined with disk-based storage and gives more honest feedback to senders. This area has been changing, so check the current Collector documentation to see which approach is recommended for your version.
If losing data on a crash is unacceptable for you, look at exporter queues that store data on disk, instead of relying on in-memory batching alone. Even then, no setup is perfectly lossless, so decide how much loss your business can accept.
8Tuning: Finding the Right Settings
There is no magic number. The right values depend on your traffic and your backend.
The central trade-off: speed versus efficiency
Every batching choice balances two things. Freshness means how soon data appears in your dashboards. Efficiency means how cheaply the data is moved. A short timeout and small batch give fresher data but more requests. A long timeout and big batch give fewer requests but later data.
| If You Choose | You Gain | You Pay |
|---|---|---|
| Shorter timeout | Data reaches the backend sooner | More, smaller requests and higher overhead |
| Longer timeout | Fuller batches and fewer requests | Data is delayed by up to the timeout |
| Smaller batch size | Lower memory use and smaller messages | More requests and less compression benefit |
| Larger batch size | Fewer requests and better compression | More memory and a risk of oversized messages |
| Setting a max size | Safe, predictable message sizes | Slightly more work splitting large bundles |
Read the Collector’s own numbers
The batch processor reports metrics about itself. Their names begin with the word otelcol followed by processor and batch. The exact names can vary by version, but the ideas are stable, and they tell you what is happening.
- How many batches were sent because of size, versus how many were sent because of the timeout.
- The sizes of the batches that were sent, both in item count and, in newer versions, in bytes.
- The number of separate metadata batches, if you use metadata keys.
flowchart TD
S["Look at batch metrics"] --> Q1{"Are most sends caused by the timeout?"}
Q1 -->|Yes| Q2{"Are batches much smaller than the size target?"}
Q2 -->|Yes| A1["Traffic is low or timeout is short. Consider a longer timeout or smaller size target"]
Q2 -->|No| A2["Settings look balanced"]
Q1 -->|No| Q3{"Are most sends caused by the size trigger?"}
Q3 -->|Yes| Q4{"Are batches exceeding backend message limits?"}
Q4 -->|Yes| A3["Set or lower the max size"]
Q4 -->|No| A4["Traffic is high and batching is efficient"]
Q3 -->|No| A5["Check for traffic problems or missing data"]
Think of the bus again. If the bus almost always leaves because of the timetable and carries only three people, either the timetable is too short or too few people ride at that hour. If the bus always fills up within seconds, you are carrying plenty of people, and the bus is being used well. The numbers on the bus tell you which case you are in.
A practical approach
Start With the Defaults
They are chosen to work well for many situations. Do not tune before you have real data.
Check Your Backend’s Limits
Find the maximum message size and request rate your backend accepts, and set a max size that stays safely below it.
Watch the Metrics Under Real Load
Observe how batches are triggered, and how large they are, at your busiest and quietest times.
Change One Setting at a Time
Adjust a single value, wait, and compare. Changing several together hides what helped.
Retest After Traffic Changes
A new feature or a big customer can change your traffic shape. Review the settings again when that happens.
9Batching and the Memory Limiter: A Team
Held data takes up memory, and memory is not unlimited.
Every item held in a batch uses memory. If your traffic suddenly jumps, many batches may hold a lot of data for a moment. The memory limiter processor is the Collector’s guard for this problem. It watches the Collector’s memory use, and when it gets near a limit, it starts refusing new data so the Collector does not crash. This is why it is placed before the batch processor.
Production Example: The Black Friday Spike
An online retailer’s traffic triples in a few minutes. Without protection, batches and queues would grow until the Collector ran out of memory and was restarted by the system, losing everything it held. With a memory limiter in front, the Collector politely refuses some data at the peak. Senders retry shortly after, and most data still arrives. A small delay replaces a crash.
Sizing the Collector
Add up the memory that batches could use at once, such as the batch size times the typical item size, times the number of pipelines, times any metadata batches. Then add the exporter queue. Compare it with the memory your container is allowed to use. If the numbers are close, either lower the sizes or raise the container limit.
10Batching in Different Deployment Layouts
Where you run the Collector affects how you batch.
Collector Beside the App
A small Collector on the same machine or pod. Batches are small to moderate. Short timeouts keep data fresh and memory low.
Central Collector
A shared Collector that receives from many agents. Larger batches make sense here, since traffic is higher and the final trip to the backend is the most expensive.
Many Customers in One Collector
Use metadata keys so each customer’s data is batched separately, and set a cardinality limit to protect memory.
Serverless and Jobs
If a program ends quickly, a long batch timeout can leave data unsent. Make sure data is flushed before shutdown.
flowchart LR
A1["App with SDK batching"] --> AG1["Agent Collector with small batches"]
A2["App with SDK batching"] --> AG2["Agent Collector with small batches"]
AG1 --> GW["Gateway Collector with larger batches"]
AG2 --> GW
GW --> BE["Backend"]
Notice that batching can happen three times along the way: in the application’s SDK, in the agent Collector and in the gateway Collector. Each round has a different purpose. The first makes the trip from the app efficient. The second makes the trip to the gateway efficient. The last makes the final trip to the backend efficient. Do not worry about “double batching.” It is normal, as long as the total delay stays within what you can accept.
Delays add up. If the SDK waits five seconds, the agent waits a second, and the gateway waits another few seconds, data may reach the backend ten or more seconds late. That may be fine for troubleshooting, but too slow for fast alerts. Add up the waits across all layers.
11Advantages, Disadvantages and Trade-offs
Honest accounting of what batching gives and what it costs.
Advantages
- Efficient network use: fewer, larger requests
- Better compression: smaller data over the wire
- Gentler on backends: fewer writes and lower chance of rate limiting
- Lower resource cost: less CPU and fewer connections
- Smooths spikes: bursty traffic becomes steadier
- Simple to set up: works well with defaults
Disadvantages
- Adds delay: data waits up to the timeout
- Uses memory: held data counts against limits
- Can lose data: in-memory batches vanish if the Collector crashes
- Hides failures from senders: acceptance happens before delivery
- Wider blast radius: one bad record can cause a whole batch to be rejected
- Evolving area: recommendations about where to batch have been changing
Key trade-offs
| Decision | Option A | Option B |
|---|---|---|
| Where to batch | In a processor, which is simple and widely used | In the exporter queue, which can pair with disk storage and clearer feedback |
| Batch size | Large, for efficiency | Small, for low memory and fast delivery |
| Timeout | Long, for fuller batches | Short, for fresher data |
| Durability | In-memory, for speed and simplicity | Disk-backed queues, for survival of restarts at some cost to speed |
| Multi-tenant batching | Separate batches per tenant, for isolation | One shared batch, for lower memory use and simplicity |
12Security Considerations
Batching does not change what your data says, but it does change where data sits and for how long.
Data Sits in Memory
Batches hold real telemetry in the Collector’s memory. If the machine is compromised, this data may be exposed. Limit access to Collector hosts.
Redact Before You Batch
Place redaction and attribute-removal processors before batching, so that sensitive values are never held in batches at all.
Resource Exhaustion
An attacker or a bug that floods the Collector can fill memory with batches. A memory limiter and sensible sizes protect against this.
Cardinality Abuse
If batching by metadata, a sender could invent endless metadata values and force thousands of tiny batches. Keep the cardinality limit in place.
Keep Tenants Apart
Separate batches per tenant avoid mixing different customers’ data in one bundle sent to a backend.
Encrypt the Export Path
Use encrypted, authenticated connections from the Collector to the backend, since batches carry a lot of data in one go.
Disk-backed queues write telemetry to storage. If that data contains sensitive values, the files themselves become something to protect. Encrypt the disk, restrict access, and clean up old files.
13Monitoring, Logging and Troubleshooting
A pipeline that handles your monitoring data needs to be monitored too.
- Trigger mix: watch the share of sends caused by size versus timeout. A sudden change shows that traffic patterns have shifted.
- Batch sizes: track average and largest batch sizes. Very small ones waste efficiency, and very large ones risk rejection.
- Refused data: if the memory limiter is refusing data, the Collector is under pressure.
- Exporter failures and drops: watch for failed sends, retries, and dropped batches from full queues.
- Queue depth: an exporter queue that is always nearly full means the backend cannot keep up.
- Collector memory and CPU: check that these stay well below the container’s limits.
- Received versus sent counts: compare items received with items exported. A growing gap means loss somewhere in between.
- Collector logs: rejected-message errors from the backend often point to batches that are too large.
Common symptoms and likely causes
| Symptom | Likely Cause | What to Try |
|---|---|---|
| Data arrives late in dashboards | Timeouts stacked across layers, or a long timeout | Add up waits across SDK, agent and gateway, then shorten the largest |
| Backend rejects messages as too large | No max size, so batches grow too big | Set a max size below the backend’s limit |
| Many tiny requests | Timeout firing before batches fill | Raise the timeout or lower the size trigger |
| Collector memory keeps growing | Large batches, many pipelines, metadata batches or full queues | Lower sizes, limit metadata cardinality, add a memory limiter |
| Data missing after a restart | In-memory batches and queues were lost | Consider disk-backed queues and graceful shutdown |
| Batch processor seems to do nothing | Defined but not listed in the pipeline | Add it to the processors list of the pipeline |
14Design Patterns and Anti-Patterns
Habits worth copying and traps worth avoiding.
Good design patterns
Protect, Process, Batch
Memory limiter first, shaping processors in the middle, batch last. A simple and reliable order.
Cap the Message Size
Always know your backend’s message limit and set a max size beneath it.
Layered Batching
Small batches at the edge, larger batches at the gateway, each tuned to its job.
Two Buffers, Two Purposes
Use the batch processor for grouping and the exporter queue, optionally on disk, for resilience.
Measure Then Tune
Use the processor’s own metrics to guide changes, one at a time.
Graceful Shutdown
Give the Collector time to flush batches when it is stopped or replaced, for example during a rolling update.
Anti-patterns
The Mistake
Leaving the batch processor out entirely on a high-traffic pipeline.
Why It Hurts
The backend sees a flood of tiny requests, and costs, CPU use and rejection rates all rise.
Better Approach
Add a batch processor, or exporter-level batching, to every pipeline that sends data over the network.
The Mistake
Placing the batch processor early, before filters, redaction or sampling.
Why It Hurts
Batches are formed and then shrunk or reshaped, wasting effort, creating uneven sizes and holding sensitive data longer than needed.
Better Approach
Make batching one of the last steps before the exporter.
The Mistake
Setting a huge batch size and a long timeout without a max size.
Why It Hurts
Batches can exceed backend message limits and be rejected whole, and memory use can balloon.
Better Approach
Choose a moderate size, set a max size, and confirm the numbers against the backend’s limits.
The Mistake
Treating the batch processor as a durable store that guarantees delivery.
Why It Hurts
It holds data in memory and reports success before data reaches the backend. A crash or long outage loses data silently.
Better Approach
Use exporter queues, disk storage where needed, and monitor the gap between received and exported counts.
The Mistake
Using a high-cardinality value, such as a request ID, as a metadata key for batching.
Why It Hurts
Each unique value creates its own batch in memory, which can exhaust memory and defeat the purpose of batching.
Better Approach
Use only keys with a small, known set of values, such as a tenant or team, and keep the cardinality limit on.
15Best Practices and Common Mistakes
A practical checklist for healthy batching.
Best practices
- Batch every networked pipeline. Traces, metrics and logs should all be grouped before leaving the Collector.
- Put batching last. After protection, shaping and sampling, and just before export.
- Start with defaults. Tune only after watching real behaviour.
- Set a max size. Keep messages safely below your backend’s limits.
- Pair with a memory limiter. Put it first, and size the container to match.
- Add up delays. Count the timeouts at every layer, from SDK to gateway.
- Keep metadata batching small. Use few keys with few values, and keep the limit on.
- Plan for restarts. Allow graceful shutdown and consider disk-backed queues if loss is costly.
- Monitor the batch metrics. Review trigger mix, batch sizes and drops regularly.
- Check release notes. The recommended place for batching has been changing, so confirm advice for your version.
Common mistakes beginners make
- Defining the batch processor but forgetting to list it in the pipeline.
- Believing the send size is a hard limit, when it is only a trigger.
- Forgetting that metrics are counted in data points, not in metric names.
- Putting the batch processor before sampling or filtering.
- Ignoring the combined delay of batching in several layers.
- Assuming “accepted by the Collector” means “stored in the backend”.
- Using unbounded metadata values and causing memory growth.
16Real-World and Industry Examples
How batching shows up in tools and platforms you may already know.
OpenTelemetry Helm Chart and Demos
The ready-made configurations used by the OpenTelemetry project for Kubernetes typically include a memory limiter and a batch processor in their pipelines. This shows how widely the “protect first, batch last” pattern is accepted as a sensible starting point.
AWS Distro for OpenTelemetry
Amazon’s distribution of the Collector provides example configurations that include batching before sending data to AWS monitoring services. Teams running on containers and serverless platforms use these as a base and then tune sizes and timeouts to their traffic.
Grafana Alloy
Grafana Alloy, an agent built on Collector components, offers a batch component with the same ideas of size, timeout and maximum size. Teams sending data to Grafana’s stack use it to reduce the number of requests and control message size.
Large E-Commerce Platforms
Companies that run very high traffic online stores typically place an agent Collector next to each service and a gateway Collector in front of their storage. Small, quick batches at the edge keep applications light. Larger batches at the gateway keep the cost of writing to storage under control during sales events.
Multi-Tenant Observability Providers
Providers that receive telemetry for many customers in one Collector layer use metadata-based batching so that each customer’s data is grouped and routed separately, with limits that stop one customer from consuming all the memory.
A typical journey for a growing team
Basic Setup
Memory limiter first and batch last, with default settings, in every pipeline.
Watch the Metrics
Build a small dashboard of batch triggers, sizes, refused data and exporter failures.
Set Safe Limits
Add a max size matched to the backend, and size container memory to match the settings.
Add Resilience
Add exporter queues with retries, and disk-backed storage where losing data is costly.
Review Regularly
Revisit settings when traffic changes, and read release notes about where batching is best done.
17Frequently Asked Questions
Quick answers to questions beginners ask most.
18Summary and Key Takeaways
If you remember only a few things, remember these.
Key Takeaways
- Batching is the bus that leaves when full or on time. The Collector groups telemetry and sends each group when it reaches the target size or when the timeout expires, whichever comes first.
- It makes sending cheaper. Fewer requests, better compression, gentler load on backends and lower CPU use all come from this one simple idea.
- Send size is a trigger, max size is a limit. To keep messages below a backend’s limit, you must set the maximum size as well.
- Place it last. Put the memory limiter first, shape and sample the data in the middle, and batch just before the exporter.
- There are two buffers. The batch processor groups items, while the exporter queue holds finished batches during retries. Both live in memory unless you choose disk-backed storage.
- Know the trade-offs. Batching adds delay, uses memory and can lose data on a crash, and the delay adds up across SDK, agent and gateway layers.
- Tune with evidence. Start with defaults, read the batch processor’s own metrics, change one setting at a time, and check current guidance, since the best place to batch has been evolving.