Replay, schema evolution and backpressure
Replay safely
A checkpoint is progress, not proof every side effect happened once. A crash after a durable sink write but before saving progress causes the same record to be read again. Use a unique event_id and a sink transaction that inserts the event ID and updates its aggregate together. Replaying into an isolated projection or versioned output is safer than overwriting production. Keep replay within retention and authorize source and destination separately. The offline SQLite lab commits the record before moving a simulated checkpoint and deliberately retries a duplicate.
Evolve a data contract
A data contract defines fields, types, units, meaning and versioning. The fictional event uses amount_cents as a nonnegative integer, not a floating-point currency value. Version 2 adds an optional channel with a default; adding a required field without a suitable default can break older records. Glue Schema Registry supports compatibility checks for supported formats; BACKWARD means a new reader can read data written with the previous schema. Check the actual format and defaults rather than assuming all changes are compatible. Reject unsupported versions and malformed records into a restricted quarantine with reason and source position; advance progress only after durable handling.
Backpressure and bounded work
Backpressure occurs when downstream processing cannot keep up. If 120 records arrive and 80 complete each minute, backlog grows by 40 per minute until capacity changes. Avoid unbounded in-memory buffers; cap batches and concurrent writes, slow producers where possible, and scale the bottleneck after measuring it. Monitor lag by partition, throttles, checkpoint duration and quarantine rate; alert before lag approaches retention. A dead-letter queue or error store is an explicit design decision, not a universal automatic feature of streaming engines. Retry transient errors with limits; isolate permanent errors.
Practice and cost boundary
Run the offline lab with five fictional records. Predict the total after a duplicate, a malformed record and replay; compare it with the tests. In the hypothetical model 120 records/minute in and 80 out for three minutes leaves 120 waiting, and a buffer cap of 100 requires upstream pause or durable spill rather than dropping records silently. Compare streaming capacity, consumer compute, storage, retention, transfer and error/replay costs against batch. Check current regional prices and versions separately. Do not launch brokers, workers or continuous producers for this lab.
{ "arrivals": 120, "completions": 80, "minutes": 3, "cap": 100}Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Replay, schema evolution and backpressure — knowledge check
Reason about stream selection, processing guarantees and replay safety.
A crash after sink commit but before progress commit needs what?
Which change is a candidate for backward-compatible evolution?
What should happen to malformed data?
120 arrivals and 80 completions per minute for three minutes yields what backlog from zero?
What is the correct response to a full bounded buffer?