Why Buffering Matters
In observability pipelines, downstream systems can become slow or unavailable:- Network issues: Temporary connectivity problems
- Destination overload: Elasticsearch cluster under heavy load
- Rate limiting: API throttling from SaaS platforms
- Batch processing: Waiting for enough events to send efficiently
- Scheduled downtime: Maintenance windows for downstream services
- Cause data loss (dropped events)
- Propagate backpressure to sources (slowing collection)
- Reduce pipeline throughput
Buffer Types
Vector supports two buffer types: memory and disk.Memory Buffers
Fast, in-RAM buffering for normal operation
Disk Buffers
Persistent, high-capacity buffering for reliability
Memory Buffers
Memory buffers store events in RAM for fast access. Configuration:- ✅ Fast: No disk I/O overhead
- ✅ Low latency: Immediate access
- ✅ Simple: No persistence complexity
- ❌ Data loss on crash: Events in buffer are lost if Vector crashes
- ❌ Limited capacity: Constrained by available RAM
- ❌ Not persistent: Lost on restart
- Non-critical data (debug logs, metrics)
- Low-latency requirements
- Stable downstream systems
- Cost-optimized deployments (best-effort delivery)
Disk Buffers
Disk buffers store events on disk for durability. Configuration:- ✅ Durable: Survives Vector crashes and restarts
- ✅ Large capacity: Can buffer gigabytes of data
- ✅ Persistent: Data preserved across restarts
- ✅ Reliable: No data loss on process failure
- ❌ Slower: Disk I/O adds latency
- ❌ More complex: Requires disk space management
- ❌ I/O overhead: Can impact system performance
- Critical data (audit logs, financial transactions)
- Unreliable networks
- Unstable downstream systems
- Large bursts of data
- Compliance requirements
Comparison
| Feature | Memory Buffer | Disk Buffer |
|---|---|---|
| Speed | Very fast | Moderate |
| Latency | < 1ms | 1-10ms |
| Capacity | MB (hundreds of events) | GB (millions of events) |
| Durability | Lost on crash | Survives crashes |
| Use case | Best-effort delivery | Guaranteed delivery |
| Resource impact | RAM usage | Disk I/O + space |
Backpressure Handling
When a buffer fills up, Vector must decide what to do. This is controlled by thewhen_full setting.
Block (Default)
Wait for space to become available. This ensures no data loss.- Buffer fills to capacity
- Sink stops accepting new events
- Backpressure propagates upstream through transforms
- Eventually reaches sources, which slow down
- When buffer drains, flow resumes
- ✅ No data loss
- ❌ Sources may slow down or queue
- ❌ For file sources: Reading pauses (position checkpointed)
- ❌ For network sources: Connections queue or TCP windows shrink
- Critical data that cannot be lost
- Audit logs
- Financial transactions
- Compliance-required data
Drop Newest
Discard new events when buffer is full. This prioritizes throughput over completeness.- Buffer fills to capacity
- New events are immediately dropped
- Dropped events are counted in
component_discarded_events_totalmetric - No backpressure propagates upstream
- Sources continue reading at full speed
- ✅ No slowdown to sources
- ✅ Maximum throughput maintained
- ❌ Data loss (events are dropped)
- Non-critical data (debug logs)
- High-volume metrics (sampling acceptable)
- Performance is more important than completeness
- Load shedding scenarios
Configuration Examples
Critical Path: Disk Buffer + Block
For audit logs that must not be lost:High-Volume Path: Memory Buffer + Drop
For high-volume debug logs:Balanced: Memory Buffer + Block
For application logs (important but not critical):Disk Buffer Deep Dive
Storage Location
Disk buffers are stored in Vector’s data directory:Buffer Structure
Disk buffers use a write-ahead log (WAL) structure:- Events are written sequentially to segment files
- Segments are deleted after events are delivered
- Buffer survives Vector crashes and restarts
- Resumption is automatic (no manual intervention)
Disk Buffer Sizing
Choose buffer size based on:-
Expected downtime: How long can the destination be unavailable?
- 5 minutes of downtime at 1000 events/sec = 300,000 events
- At ~1KB/event = ~300MB needed
-
Event rate: Higher rates need larger buffers
- Available disk space: Leave headroom for OS and other applications
Disk Space Management
Monitor disk usage to prevent issues:Performance Tuning
Disk buffers can be tuned for different scenarios:Monitoring Buffers
Vector exposes metrics for buffer health:Key Metrics
buffer_received_events_total: Events entering bufferbuffer_sent_events_total: Events leaving bufferbuffer_events: Current events in bufferbuffer_byte_size: Current buffer size in bytesbuffer_max_size: Configured maximum sizecomponent_discarded_events_total: Events dropped (ifdrop_newest)
Buffer Utilization
Monitor buffer fullness:Best Practices
Match buffer type to data criticality
Match buffer type to data criticality
Size buffers appropriately
Size buffers appropriately
- Too small: Frequent backpressure, reduced throughput
- Too large: Wasted resources, delayed failure detection
- Rule of thumb: 5-10 minutes of expected data at normal rates
Monitor buffer utilization
Monitor buffer utilization
Set up alerts for:
- Buffer > 80% full (indicates sustained slowness)
- Buffer full for > 5 minutes (indicates serious issue)
- Dropped events > 0 (when using
drop_newest)
Use disk buffers for batch sinks
Use disk buffers for batch sinks
Sinks that batch large amounts of data benefit from disk buffers:
Consider buffer chaining
Consider buffer chaining
Use multiple buffers in series:
Test failover scenarios
Test failover scenarios
Verify buffer behavior:
- Fill buffer to capacity
- Stop destination service
- Verify backpressure or dropping
- Restart destination
- Verify buffer drains
Troubleshooting
Buffer Full
Symptoms:buffer_eventsmetric at maximum- Sources slowing down (if
when_full: block) - Events being dropped (if
when_full: drop_newest)
-
Increase buffer size:
-
Increase sink throughput:
- Add more sink instances (horizontal scaling)
- Reduce data volume (sampling, filtering)
Disk Buffer Growing
Symptoms:- Buffer size increasing over time
- Disk space shrinking
buffer_byte_sizemetric growing
- Destination is slower than source
- Network issues
- Rate limiting
- Check destination health and performance
- Verify network connectivity
- Review rate limits
- Increase sink concurrency
- Scale out (multiple Vector instances)
Buffer Not Draining After Recovery
Symptoms:- Destination recovers
- Buffer remains full
- Events not flowing
- Check Vector logs for errors
- Verify sink configuration
- Restart Vector (disk buffers persist)
- Check file permissions on data directory
Disk Buffer Corruption
Symptoms:- Vector fails to start
- Logs show buffer errors
- Metadata errors in logs
-
Backup buffer directory:
-
Remove corrupted buffer:
- Restart Vector (creates new buffer)
Related Topics
- Pipeline Model - How buffers fit in Vector’s topology
- Sinks - Configuring sink buffering
- Sources - How sources handle backpressure