Durable Logs, Queues and Stream Processing
Data infrastructure is a set of ordering, ownership, state and replay contracts. The same event can be durably stored yet still be lost, duplicated or misapplied at an external effect boundary.
Section 7 of 9 · 15 units · about 64 hours
By the end you can Preserve the stated ordering and effect semantics across producer and consumer retries, rebalance, crash and replay, then recover matching offsets, state and outputs while handling late data under an explicit event-time policy.
Units
- Append-only segmented logs, offsets, sparse indexes, retention and compaction4h
- Partitions, per-partition ordering, replication and high-watermark visibility4h
- Producer acknowledgements, idempotent sequence state and transactional scope4h
- Pull consumers, fetch positions, consumer groups and rebalance protocols4h
- Offset commits versus application state and at-most-once, at-least-once and effectively-once delivery4h
- Retries, poison records, dead letters and bounded backlog4h
- Deterministic replay, schema registries and change data capture4h
- Event time versus processing time and tumbling, sliding and session windows4h
- Watermarks, idle-source stalls and late-data policy4h
- Keyed state, checkpoint barriers and the source-state-sink recovery boundary5h
- Distributed dataflow graphs, shuffle and operator parallelism4h
- Batch and stream unification, open table formats and incremental views4h
- A mini partition log with consumer groups and replay6h
- An event-time processor with checkpoints5h
- Lag, throughput, recovery and duplicate measurement4h
Build it
Mini project · about 16 to 22 hours
Replayable partition logs and checkpointed event-time effects
Extend loglab from partitioned storage and workflows into a bounded log and stream processor. Run local processes on your machine, establishing replay and effect correctness before measuring lag, recovery and overload.
- 1Extend
storage/andstream/with segmented partition logs, sparse indexes, retention and compaction. Check recovery against an acknowledged-prefix oracle at append and manifest-publication boundaries, retain corruption verdicts, and pass Gossip Glomers 5a through a separate adapter without claiming it tests disk durability. - 2Connect
replica/orconsensus/to an explicit high watermark and durable producer identity, epoch and sequence state. Compare failover, duplicate retries and timeout-after-commit histories with a sequential append model; retain visibility and acknowledgement verdicts with deliberate Kafka contract differences. - 3Implement durable group positions and epoch-fenced reassignment in
stream/, using thetxn/effect boundary. Check kill-and-reassign, contiguous commits and each effect-versus-progress crash window against an independent sink ledger; retain dedup TTL expiry and restart tests, explicitly excluding nonparticipating external effects. - 4Build CDC replay with per-partition source positions, per-key versions and retained tombstones. Check out-of-order and cross-partition arrivals, mixed reader-writer schemas and snapshot-plus-position restarts against a full-fold oracle; retain snapshot publication crash tests and state which cross-partition orders the contract excludes.
- 5Build a keyed shuffle and event-time window processor with explicit triggers, accumulation, minimum-input watermarks, idleness and drop-versus-correction policies. Compare scripted late-event histories with a batch oracle under the same policy; retain hot-key routing, horizon expiry and bounded-state evidence.
- 6Align checkpoint barriers over FIFO logical channels above
net/, snapshotting offsets, keyed state and the participating sink boundary together. Inject mid-window kills and offset-state mismatches, compare restored replay with uninterrupted oracle outputs, and retain partial-checkpoint rejection plus immutable snapshot-pointer restore tests. - 7Wire bounded retries, durable dead letters, backpressure and retention-lag alerts; first check poison-record and storage-full schedules against a queue model. Then repeat matched open-loop runs and Gossip Glomers 5c, retaining versions, workloads, raw lag, goodput, duplicates, rebalance pauses, checkpoint costs, drain and recovery distributions.
What you hand in
- The integrated
stream/data path with durable producer and group state, bounded windows, dead letters and checkpoint recovery. - Reference models, deterministic fault schedules and raw histories covering visibility, delivery, CDC, shuffle and snapshot publication.
- A contract and measurement report with Kafka deviations, matched repeated runs, retention bounds and recovery evidence.
How to check it
- Self-grade with the rubric below
- Gossip Glomers 5a: Single-Node Kafka-Style Log
Keep the Maelstrom history separately; the public workload does not exercise your storage-crash or immediate-visibility contract.
- Gossip Glomers 5c: Efficient Kafka-Style Log
Retain correctness verdicts and coordination costs for matched runs; public efficiency results do not replace end-to-end recovery measurements.
How it's graded
Log visibility and identity
Pass: Your prefix and append-model tests check recovery, committed visibility, failover and retry suppression across producer restart; public histories pass within their narrower scope.
Great: A planted premature acknowledgement or lost producer-state bug fails before repair; a minimized history explains the exact durability or retention boundary.
Ownership and effect scope
Pass: Your independent sink ledger verifies epoch-fenced reassignment, contiguous positions and crash-window replay. TTL expiry tests bound duplicate suppression, and external effects remain explicitly outside the atomic claim.
Great: Delayed stale commits and timeout-after-effect retries expose a naive implementation; retained regressions distinguish harmless redelivery from duplicated effects.
Replay and checkpoint agreement
Pass: Full-fold and batch references match CDC and window outputs under declared ordering and lateness policies. Your restore tests catch offset-state mismatch, partial publication and stale tombstone resurrection.
Great: The same logical input rebuilds matching state through both retained-log replay and snapshot-plus-suffix recovery, including skew, idle inputs and late corrections.
Bounded operation evidence
Pass: Your queue-model tests precede load. Repeated matched runs retain raw lag, goodput, duplicates, checkpoint cost, rebalance, drain and catch-up evidence with versions and settings.
Great: A losing batching or checkpoint policy remains in the report, with causal traces explaining its resource and recovery trade-off rather than a universal performance claim.
Resources
- DDIA 2e - Chapters 11 to 13 Batch and Stream ProcessingMartin Kleppmann and Chris Riccomini
Read batch processing, stream processing and the streaming-systems philosophy in order. For every guarantee, mark the source position, operator state, output effect and recovery boundary it actually covers.
- The Dataflow Model (Akidau et al., 2015)Google (author copy)
Read the model section: event time versus processing time, windowing, triggers and accumulation. Implement one trigger and one accumulation mode, not the catalog.
- Lightweight Asynchronous Snapshots for Distributed Dataflows (Carbone et al., 2015)arXiv
Read the asynchronous barrier snapshotting algorithm for acyclic graphs and its recovery; skip the cyclic extension. Barriers assume FIFO channels.
- Apache Kafka 4.3 - Design, Log, Rebalance and Transaction ProtocolsApache Kafka
Read the 4.3 design page (replication and in-sync replicas, acknowledgements and
min.insync.replicas, delivery semantics, idempotence and transactions, the consumer, log compaction), the log implementation page, and the consumer rebalance protocol and transaction protocol pages (https://kafka.apache.org/43/operations/). Kafka 4.0 removed ZooKeeper. Run experiments in theapache/kafka:4.3.1image and compare each contract with your mini log. - Gossip Glomers - Kafka-Style LogFly.io and Jepsen
Each challenge runs locally under Maelstrom (v0.2.4; the pages were tested on 0.2.3) with its checker and, where the page says so, the partition nemesis; keep the run directory as the history. Do 5a to 5c:
send,poll,commit_offsetsandlist_committed_offsetson one node, then two nodes overlin-kv, then with fewer messages. The checker catches lost writes and nonmonotonic or skipped offsets; it does not check recency or exactly-once effects. - Apache Flink 2.3 - Event Time, State and CheckpointingApache Flink
Read the 2.3 concepts pages on time (event time, watermarks, lateness, windowing) and stateful stream processing (keyed state, checkpoint barriers, recovery, unaligned checkpoints, exactly-once versus at-least-once), then the watermark-generation guide on idle sources. Use them to build one bounded local processor; exactly-once covers state and participating sinks only.
- HLD Handbook - Queues, Streaming, Stream vs Batch and CDCHLD Handbook
Read only Part 2 message queues and pub-sub plus Part 4 stream versus batch and change data capture. Use Part 5 event-driven architecture after the underlying log and replay contract is clear.
- The Log: What Every Software Engineer Should Know About Real-time Data's Unifying Abstraction (Kreps, 2013)LinkedIn Engineering
Read it first as the short concept spine for logs, replicas, data integration and stream processing, before DDIA 2e Chapters 11 to 13.
- Kafka: a Distributed Messaging System for Log Processing (Kreps, Narkhede and Rao, 2011)NetDB workshop (mirror)
Read it as the design ancestor of your mini log: segments, offsets, pull consumers and consumer groups. Replication is future work in this paper, so take durability from the current docs.
- MillWheel: Fault-Tolerant Stream Processing at Internet Scale (Akidau et al., 2013)PVLDB
Read low watermarks, persistent state, strong productions and exactly-once delivery by deduplication. The deduplication holds only within its retention bound.
- Distributed Snapshots: Determining Global States of Distributed Systems (Chandy and Lamport, 1985)Leslie Lamport
Read the marker-sending and marker-receiving rules and why the recorded state is consistent. The algorithm needs FIFO channels.
- AWS Builders' Library - Avoiding Insurmountable Queue BacklogsAmazon Web Services
Read it for how backlogs grow and why they take long to drain, and for backpressure, prioritization, sidelining and constant work. Compare its recovery strategies with the bounded backlog and lag measurements of your consumer.
- Confluent Schema Registry - Schema Evolution and CompatibilityConfluent
Use only the compatibility-type definitions (backward, forward, full and their transitive forms) as the vocabulary for your schema checks, with the Avro schema resolution rules as the mechanism.
- MIT 6.5840 - Lab 1 MapReduceMIT PDOS
Complete or review the coordinator and worker lab to connect deterministic batch dataflow, task retries and output publication. Do not confuse its shared-filesystem assumptions with the durable log contract.
- Replicated Log and Stream Processor - Full Data PathRoadmap-Final
Complete partitioned log, producer identity, consumer ownership, offsets, backpressure, event-time state, checkpoint, replay and sink boundary. Run the required producer, consumer, storage and late-data fault campaign.
- Apache Iceberg - Table SpecificationApache Iceberg
Read the snapshot, manifest list and manifest sections for the read path, and the table metadata section for the atomic metadata-file swap that commits a snapshot.
- Delta Lake Protocol (pinned commit)Delta Lake
Read the transaction log replay and checkpoint sections for how readers reconstruct table state, and the concurrency section for the optimistic commit rule.
- Apache Avro 1.12.0 Specification - Schema ResolutionApache Avro
Read Schema Resolution only: records match by field name, writer-only fields are ignored, reader-only fields are filled from defaults, plus the promotion rules.