Lesson 3 of 9 · 26m
Buffering, Backpressure, and Delivery Semantics
Queues, batching, retries, and Kafka versus direct shipping — the unglamorous mechanics that decide whether logs arrive during an incident.
Ingest pipelines fail in slow motion. First the queue grows. Then latency climbs. Then nodes run out of disk or memory, usually minutes after the original downstream problem began. The system that looked redundant on a diagram collapses because every layer retried into every other layer.
Batching is a trade, not a free win
Large batches reduce indexing and network overhead. They also increase latency and amplify retry cost. A batch of 5 MB that fails is 5 MB retried; a batch of 500 KB is easier on both ends.
Reasonable starting point:
# vector sink sketch
[sinks.elastic]
type = "elasticsearch"
inputs = ["normalize"]
compression = "gzip"
batch.max_bytes = 4_000_000
batch.timeout_secs = 2
request.timeout_secs = 10
buffer.type = "disk"
buffer.max_size = 2_000_000_000Tune with measurements. Do not copy these numbers into production because they are integers in a YAML block.
Kafka is a shock absorber, not a magic cloak
A Kafka or Redpanda tier between collectors and indexers is justified when ingest spikes are large, downstream maintenance is frequent, or multiple consumers need the same stream. It gives you durable buffering and replay. It also gives you a distributed system to operate.
Direct shipping is fine for many small environments. If the Elasticsearch cluster is down for five minutes and your agents can buffer on local disk, adding Kafka may be more failure domain than benefit.
Retries need ceilings and jitter
A tight retry loop is a denial-of-service attack against your own logging cluster:
attempt 1: immediate
attempt 2: 200ms + jitter
attempt 3: 1s + jitter
attempt 4+: capped at 30s, dead-letter after policy limitPoison events matter. One malformed event that always fails mapping can block a partition or fill a retry loop forever. Route failures to a dead-letter stream with enough context to fix them.
Exactly-once is mostly a lie here
In practice, delivery is at-least-once at some boundaries and at-most-once at others. Your operational model should be:
- deduplicate by event ID when exactness matters
- tolerate duplicates in dashboards
- measure lag, loss, and retry volume continuously
Field notes
- Alert on queue age, not just queue size. Ten thousand fresh events is fine; ten thousand events from an hour ago means you are blind.
- Compression usually pays for itself, but test CPU overhead on constrained edge nodes.
- Make flush behavior explicit on shutdown. SIGKILL is not a graceful drain.
- Replay is a superpower and a footgun. Replaying a bad day of traffic can re-trigger every alert derived from it.
Was this lesson helpful?