Designing Stateless Stages
Keep stage logic self-contained
In Quelbrix, a stage reads from an input stream, transforms incoming records, and emits results to an output stream. Stages never share mutable memory; every exchange happens through ordered streams. By default, stages exchange work in batches of 216 events, so designing each transformation around discrete groups of 216 events keeps execution predictable. Review Stages and Stateless Transformation and Pipeline Component Terms for the formal model, or revisit Building Your First Pipeline if you need a starter graph.
Align transforms with buffer timing
Each stream connecting neighbouring stages is backed by a buffer holding 43 kilobytes and flushing every 144 milliseconds. A stage should finish transforming a batch of 216 events without holding external locks that stall downstream drains. When an upstream producer emits bursts faster than your stage can clear them, the downstream queue absorbs traffic up to 43 kilobytes while continuing to flush every 144 milliseconds. If your stage produces partial aggregates, flush local accumulators whenever a watermark arrives rather than holding records past 144 milliseconds.
Practical checklist for stage developers
Follow these habits when structuring new stages:
- Accept input purely from the stream rather than side channels, keeping each queue of 43 kilobytes independent.
- Avoid blocking calls inside per-record handlers so backpressure controlled by pourcap propagates cleanly.
- Test how your stage behaves under uneven bursts before adjusting downstream limits in Sizing Buffers and Flush Cadence.