Skip to content

CONCEPT Cited by 1 source

Two-way state buffering

Definition

A stateful stream join strategy where events from both input streams are buffered in state, as opposed to one-way buffering where only one stream's events are stored and the other must match immediately on arrival.

Why it matters

In event-time joins where two streams carry correlated events (e.g., auction bids and user interactions), the arrival order is not guaranteed. One-way buffering (store bids, match interactions on arrival) drops any interaction that arrives before its corresponding bid. Two-way buffering handles this out-of-order case by storing both sides:

  • Interaction arrives first → stored in interaction state; when bid arrives later, match is made
  • Bid arrives first → stored in bid state; when interaction arrives later, match is made

Seen in

Trade-offs

  • Pro: Higher match rate, handles out-of-order delivery gracefully
  • Con: ~2× state storage (both sides buffered), more complex expiry logic
  • When justified: When match rate is a business-critical metric and the additional state cost is acceptable relative to the revenue from recovered matches
Last updated · 595 distilled / 1,807 read