Unit 11 of 15 · about 4 hours · explain
Distributed dataflow graphs, shuffle and operator parallelism
Both batch jobs and stream processors are graphs of operators joined by shuffles. The shuffle decides the runtime, and the hot key decides the shuffle.
You'll be able to
- Explain a distributed dataflow graph: operators, shuffle edges, key partitioning and operator parallelism.
- Explain why batch tasks retry transparently while stream graphs need checkpoints for the same guarantee.
- Predict the effect of key skew on a shuffle and choose between more partitions, key splitting and pre-aggregation.
Covers
Read
In this order, only the parts listed
0 of 3 done
- MapReduce, dataflow engines and shufflingDDIA 2e - Chapters 11 to 13 Batch and Stream Processing
Chapter 11, Batch Processing Models (pp. 466 to 470): MapReduce, Dataflow Engines, Shuffling Data with hash partitioning of keys; Distributed Job Orchestration (pp. 461 to 466): task retries with atomic output publication
- Lab 1 MapReduce: coordinator, workers and retriesMIT 6.5840 - Lab 1 MapReduce
The coordinator and worker task split with task retry and intermediate output files
Read the handout for the batch-dataflow contract only. Do not confuse its shared-filesystem setup on one machine with the durable-log contract; completing the lab is optional here.
- Stream versus batch reviewHLD Handbook - Queues, Streaming, Stream vs Batch and CDC
Event versus processing versus ingestion time, engines comparison, lambda versus kappa
Review after the DDIA items. Treat its deployment figures as reported examples, not targets.
Focus on
- A dataflow graph wires operators with shuffle edges: records are repartitioned by key so all records of one key reach the same downstream task.
- The shuffle is the all-to-all bulk transfer, so partition counts and key skew decide the runtime more than per-record speed does.
- Batch tasks retry transparently because inputs are immutable and outputs publish atomically. The visible result matches a failure-free run even though tasks recomputed.
- Dataflow graphs are usually acyclic, so each task's input is fixed by the operators upstream of it and a failed task can recompute from that input. Cycles and arbitrary request patterns between tasks break that reasoning.
Common mistakes · 3
- Adding reducers to fix a hot key. Every record of one key goes to one reducer, so split the key or pre-aggregate instead.
- Confusing duplicate computation with duplicate publication. Retried tasks recompute, but atomic publication keeps one visible output.
- Reading the shared-filesystem lab as a durability proof. Lab workers share files on one machine; a real log needs the acknowledgement contract from this section.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.One key carries half of all records across 100 reducers. How many reducers does it load?Answer
One. Hash partitioning sends every record of one key to the same reducer, so the hot key overloads it regardless of reducer count.
2.A map task fails after writing half its intermediate output. What survives, and what reruns?Answer
Nothing of its output survives; partial output is discarded. The retried task recomputes from the immutable input and publishes atomically on success.
3.What crosses the network in a shuffle, and what does not?Answer
Intermediate records, repartitioned by key, cross to their assigned reducers. Map tasks read their input splits, ideally from local disk, and the final output is written to the distributed filesystem; neither is the shuffle.
4.One word carries 40 percent of all records in a word count. Why do more reducers not help, and what two fixes do?Answer
Every record of one key hashes to one reducer, so that reducer still gets 40 percent of the input. A combiner pre-aggregates on the map side, so the hot reducer gets one partial count per mapper; this works because addition is associative and commutative. Key splitting appends a small salt to the hot key, spreads it over several reducers, and merges the partial counts in a second step.
Practice
- AlgoMaster: Analyze MapReduce Reducer Skew
Per-reducer load totals and the hottest reducer index from keys and weights
A single-function skew drill on a subscription the learner owns. Full shuffle behavior is lab and mini-project work.
You're done when
You can trace keys across a shuffle by hand, name what a hot key does to it, and state why a retried batch task leaves one visible output.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 15 more in the section
- DDIA 2e - Chapters 11 to 13 Batch and Stream ProcessingMartin Kleppmann and Chris Riccomini · primary
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.
- HLD Handbook - Queues, Streaming, Stream vs Batch and CDCHLD Handbook · required
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.
- MIT 6.5840 - Lab 1 MapReduceMIT PDOS · support
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.
Also in this section
- The Log: What Every Software Engineer Should Know About Real-time Data's Unifying Abstraction (Kreps, 2013)LinkedIn Engineering · support
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) · support
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.
- The Dataflow Model (Akidau et al., 2015)Google (author copy) · required
Read the model section: event time versus processing time, windowing, triggers and accumulation. Implement one trigger and one accumulation mode, not the catalog.
- MillWheel: Fault-Tolerant Stream Processing at Internet Scale (Akidau et al., 2013)PVLDB · support
Read low watermarks, persistent state, strong productions and exactly-once delivery by deduplication. The deduplication holds only within its retention bound.
- Lightweight Asynchronous Snapshots for Distributed Dataflows (Carbone et al., 2015)arXiv · required
Read the asynchronous barrier snapshotting algorithm for acyclic graphs and its recovery; skip the cyclic extension. Barriers assume FIFO channels.
- Distributed Snapshots: Determining Global States of Distributed Systems (Chandy and Lamport, 1985)Leslie Lamport · support
Read the marker-sending and marker-receiving rules and why the recorded state is consistent. The algorithm needs FIFO channels.
- Apache Kafka 4.3 - Design, Log, Rebalance and Transaction ProtocolsApache Kafka · required
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 · required
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. - AWS Builders' Library - Avoiding Insurmountable Queue BacklogsAmazon Web Services · support
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.
- Apache Flink 2.3 - Event Time, State and CheckpointingApache Flink · required
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.
- Confluent Schema Registry - Schema Evolution and CompatibilityConfluent · support
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.
- Replicated Log and Stream Processor - Full Data PathRoadmap-Final · support
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 · reference
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 · reference
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 · reference
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.