Event Streaming LabPython · Bytewax

Chapter 38 · Reading

Where does the waiting go?

Slow sinks, blocked channels and checkpoint cost.

Prerequisites When the consumer falls behind; What makes a snapshot consistent? Find chapters in the course contents.

What you’ll learn

Distinguish insufficient service capacity, queue capacity and checkpoint alignment delay.

The situation

The source is healthy and the broker acknowledges quickly. Yet records take longer to become queryable, and checkpoints take longer to complete. Both symptoms can originate in the same slow sink.

Conserve the work

With a sustained input of 100 records/s and service of 80 records/s, unfinished work grows by 20 records/s while those rates hold. A queue of 200 extra records buys ten seconds in this fluid-rate example. It does not create processing capacity. Real arrivals and service are bursty, so the arithmetic is a baseline, not a latency distribution.

Backpressure can reduce upstream admission when downstream capacity is exhausted. Depending on the source and topology, the waiting work may move into a broker log, another buffer, or the producer. A stable in-job queue after throttling does not prove customer-to-result latency is stable.

A barrier waits in the same system

Checkpoint barriers share the dataflow’s progress constraints. In an aligned checkpoint, a fast input may reach the barrier while another is delayed behind records. The operator must establish the cut without processing post-barrier data from the fast input into pre-barrier state.

Distinguish the time before barriers reach an operator, time aligning its inputs, time preparing/capturing state, and time persisting snapshot data. A large checkpoint duration could reflect any of these. More object-storage bandwidth does not automatically fix a barrier stuck behind a saturated sink.

Worked case

Compare unfinished work and its location in these two constant-rate cases. The numbers come from the stated assumptions.

Elapsed under fixed ratesOfferedCompletedUnfinished
1 second1008020
5 seconds500400100
10 seconds1,000800200

Intervene at one boundary

Compare input rate, completed output, per-task backpressure/busy indicators, broker lag and checkpoint phase timings. Temporarily reduce admitted load or simplify the sink in a controlled test. If pressure disappears, that supports a bottleneck hypothesis; it does not prove every production workload has the same constraint.

Unaligned checkpoints can avoid some alignment waiting by storing channel state. Larger buffers may increase in-flight data and recovery cost. Tune with a stated recovery objective as well as steady-state throughput: the fastest normal run may be unacceptable after a failure.

Think it through

If broker lag rises while in-job queues stay small, can you rule out a slow downstream sink?

Show hints
  1. Hint 1

    Backpressure can stop a source from reading quickly.

  2. Hint 2

    The queue can exist outside the job.

Show explanation

No. The job may be applying backpressure all the way to its source, leaving the waiting records in Kafka. Inspect the complete path and completed effects, not only one buffer. First ensure the lag and rate metrics refer to compatible partitions, groups, time intervals and units.

How frameworks implement this

Flink propagates backpressure through its task/network execution and exposes checkpoint phase metrics. Kafka consumer lag is a source-position measure, not an end-to-end completion latency. Spark micro-batch duration and admission controls require mode-specific diagnosis rather than a direct translation of Flink task metrics.

ReferencesPrimary sources for this chapter’s design case

Use these guides to check the framework or protocol contract discussed in this chapter. Moving “stable” or “current” guides can describe a different release; check the version used by your deployment. These readings do not execute the distributed frameworks they compare.

This mark tracks what you’ve read.