Chapter 42 · Reading
What is the job waiting for?
A diagnosis from source to visible result.
Prerequisites Where does the waiting go?; Exactly once—at which boundary? Find chapters in the course contents.
Build and test a bottleneck hypothesis using compatible progress, state and checkpoint evidence.
The situation
The job reports it is running, the consumer is connected and average CPU utilization is 45%. The business reports that orders take minutes to appear. A process being alive is weaker evidence than a verified end-to-end result.
Name the service objective first
Choose an observable boundary: for example, the time from an order accepted by checkout to that same order becoming queryable in the sales view. Record IDs, timestamp definitions and unfinished work. Event age can include an offline device’s delay before production; processing latency may exclude it. Mixing them makes a misleading chart.
Use distributions and counts with a known population. A p99 from completed records omits timed-out or still-queued work unless you account for it separately. Per-stage p99 values cannot be added into an end-to-end p99: stages overlap, and different records may be slow in different places.
Triangulate the symptom
Rising Kafka lag with downstream backpressure suggests work is waiting outside the job. A flat watermark with continuing processing may indicate a stalled input or a timestamp policy issue. Growing state with stable rates can come from cardinality, retained join history or delayed timers, rather than an allocation leak.
Split checkpoint duration into available phases, inspect failures and completed checkpoint age, and estimate how much replay a restart would need. “Checkpointing enabled” does not mean a recent usable checkpoint exists. Monitor sink errors, pending transactions and external quotas beside task-level metrics.
Worked case
Use each observation to form a hypothesis. The last column identifies what to inspect before choosing a fix.
| Evidence | Possible explanation | Discriminating next check |
|---|---|---|
| Lag rises; sink errors rise | Sink bottleneck propagates upstream | Inspect sink quotas and task backpressure |
| Input continues; watermark stalls | One active input holds progress | Inspect per-input watermarks and idleness |
| Checkpoint age grows | Attempts failing or completing slowly | Inspect recent completed IDs and phase timings |
| Rows correct; duplicate receipts rise | Retries masked by idempotency | Inspect receipt IDs and external side effects |
Change one thing and preserve the evidence
Form a hypothesis with a predicted observation. Reduce source admission, isolate the slow sink, change the key distribution, or compare a representative replay in a controlled environment. Record the topology, configuration, versions and correctness checks. A change that improves throughput while dropping records is not a fix.
After a failure drill, verify final effects as well as job restart. Measure restore time, replay, duplicates, loss and time to a recovered steady state. Treat native-cluster exercises as the next validation layer: these authored traces teach reasoning, not operational certification.
Think it through
What would you include in a report claiming that doubling parallelism fixed a latency incident?
Show hints
Hint 1
Compare workloads and correctness, not only CPU graphs.
Hint 2
Include the transition and recovery behavior as well as steady state.
Show explanation
Keep compatible before/after input populations, achieved admission, end-to-end latency including unfinished work, per-task skew, sink correctness, checkpoint health and recovery cost. Name confounders such as caching or changed data distribution. A stronger claim includes a repeatable intervention and the expected mechanism.
How frameworks implement this
Flink, Kafka and Spark expose different metrics and execution units. Translate the question—where is unfinished work and what limits progress—rather than renaming metrics as if they were equivalent. Verify definitions for the deployed version and connector.
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.
Flink metrics
Flink checkpoint monitoring