How to Read the Spark UI: Jobs, Stages, Shuffles and Joins

The Spark UI answers one question: what did Spark actually do with my code? Once you can read it, slow jobs stop being a mystery. Here is what each part means, and an exercise for each that you can run in the free Spark Lab.

Open the Spark Lab

Jobs: one per action

Spark is lazy. filter, select and groupBy only describe work. An action such as show(), count() or write starts a job. In the Jobs tab, one action usually means one job. Reading a CSV with inferSchema can start extra small jobs, because Spark reads the file to guess the column types.

Stages: split by shuffles

A job is cut into stages wherever data must move between partitions. Narrow transformations (filter, select, withColumn) stay in one stage. Wide ones (groupBy, join, distinct, orderBy) need a shuffle, so they start a new stage. In the Stages tab, Shuffle Write on one stage and Shuffle Read on the next is that data moving.

Tasks: one per partition

Each stage runs one task per partition. Too few tasks and your cores sit idle; too many tiny ones and the overhead adds up. repartition changes the count with a shuffle, coalesce lowers it without one.

The SQL / DataFrame tab: the plan

Click a query to see its plan as a diagram. Exchange boxes are shuffles. For joins, BroadcastHashJoin means the small table was copied to every task, which is fast. SortMergeJoin means both sides were shuffled and sorted, which is the usual reason a join is slow.

The Storage tab: what is cached

After cache() and an action, the table appears here with its size in memory. If it is not listed, it was not cached, usually because no action ran after cache().

Practise each one

The Spark Lab has a lesson for each part above, on 200,000 sample orders, with a note on what to look for. It runs on your laptop with one Docker command.

Open the Spark Lab

Also try

How to use the Spark Lab: step by step

  1. Start the Spark Lab and connect
  2. Run the groupBy lesson and open the Stages tab
  3. Run the join lessons and compare the plans

When to use the Spark Lab

  • Finding why a Spark job is slow
  • Explaining stages and shuffles in an interview
  • Checking whether a join is broadcast
  • Confirming a table is cached

Tip: When a job is slow, check the Stages tab for one task that takes much longer than the others. That usually means skewed data: one key with far more rows than the rest.