Let’s Get Certified
Module 03 / 13 · Spark architecture and components

Trace jobs, stages and shuffles

Predict when work starts and locate the boundaries that move data between partitions.

Trace jobs, stages and shuffles

Work through the decision

An engineer filters ticket records, groups by station and calls count on the result. The filter statement returned immediately. The next line triggers tasks and a shuffle. What explains the timing?

Check your reasoning

DataFrame transformations build a logical plan lazily. The action requests a materialized result, allowing Spark to optimize and execute work. Narrow transformations such as an ordinary row filter can operate on existing partitions. A grouping commonly needs matching keys brought together through an exchange. Inspect the physical plan and the stage DAG for the actual query.

Watch the source lesson at 24:20

Compare the choices

Lazy transformation
Build a plan without demanding the full result. Spark can combine or reorder compatible operations before execution.
Action
Request a materialized result or output, for example count or a write. Examine the actual jobs and stages created by the query.
Shuffle exchange
Redistribute rows among partitions so matching keys can be processed together. Look for an Exchange operator and shuffle read and write metrics.
Stage task
A task runs a stage’s work for a partition, with retries possible. Compare task count and duration to understand concurrency and skew.
Narrow transformation
Process input partitions without a full key-based redistribution when the operation permits it. A simple filter or projection often has this property.

Test the decision

A submitted application can run multiple jobs. A job comprises stages, and a stage schedules tasks over its partitions. An action can involve more than one job depending on the plan. More partitions can improve parallelism but tiny tasks increase scheduling overhead. Choose modules by workload, such as Spark SQL for structured analytics, Structured Streaming for incremental results and MLlib for machine learning.

Practice the guide skills

  1. For one action, identify the job, the stages separated by an exchange and the tasks within one stage. Watch 24:20
  2. Sketch the record movement when grouping by station after partitioning by event date. Watch 26:45 · Continue at 28:20
  3. Predict whether selecting a column, filtering, counting and collecting each starts computation. Watch 21:10
  4. Match scheduling, relational queries, column transformations, pandas-style operations, continuous input and model fitting to the corresponding Spark components. Watch 7:00

Official objectives for this lesson

Related lesson · Spark DataFrame API

Knowledge check

Trace jobs, stages and shuffles quiz

Answer 3 questions. Check each answer for an explanation.