A Dask pipeline recomputes the same cleaned DataFrame for three later joins, and each join triggers a large shuffle. What reduces the work?
- Exam domain
- Data Manipulation and Software Literacy19% of the exam
- Difficulty
- Hard
- In this mock
- 10 questions on this domainPractise this domain
Why the exam asks this
Data Manipulation and Software Literacy (19% of the exam)
Objective in the exam guide: Implementing data caching to reduce shuffle
Caching to reduce shuffle is named.
Why B is the answer
Persist the cleaned DataFrame and broadcast the small join tables
Persisting keeps the cleaned data in distributed memory so it is not recomputed. Broadcasting small tables to every worker avoids shuffling the large one.
Remember: Persist reused data; broadcast small tables.
How it works
Caching reused results and broadcasting small tables reduce shuffles in distributed processing.
In detail
- Persist reused intermediates.
- Broadcast small tables to skip shuffles.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Call compute() after every lineWrong
Repeated compute() pulls data to the client.
B. Persist the cleaned DataFrame and broadcast the small join tablesRight
Persist reused data; broadcast small tables.
C. Increase the number of partitions to ten times the number of rows so each one is tinyWrongMost tempting
Too many partitions add overhead.
Why it tempts: More partitions sounds like more parallelism.
D. Convert the DataFrame to a Python dictionaryWrong
Dictionaries are not distributed.
Use case
An illustrative scenario, not a real incident.
Illustrative: persisting once and broadcasting two small lookup tables halves run time.
See it in different ways
sequenceDiagram participant P0 as Worker A participant P1 as Worker B participant P2 as Worker C P0->>P1: rows with key X P1->>P2: rows with key Y P2-->>P0: rows with key Z
How to read this chart
- 1. Worker A sends "rows with key X" to Worker B.
- 2. Worker B sends "rows with key Y" to Worker C.
- 3. Worker A gets a reply from Worker C: "rows with key Z".
flowchart TD
Q{"Is one table small?"}
Q -->|"Yes"| A0["Broadcast join"]
Q -->|"No"| A1["Repartition on the key once and persist"]How to read this chart
- At "Is one table small?": if "Yes", go to "Broadcast join"; if "No", go to "Repartition on the key once and persist".