Skip to the page

Data pipelines in production · Scenario

A 20-minute Spark job now takes 3 hours

The interviewer asks

A Spark job that has built the daily seller report in about 20 minutes for a year now takes 3 hours, starting last Thursday. No code changed. Walk me through how you find out why.

Then

Follow-ups the interviewer asks next

  1. What do you compare first?
  2. Which parts of the Spark UI do you open, and what do you look for?
  3. The plan changed but the code didn't. How?
  4. What's the quick fix, and what's the proper fix?
  5. A month later the sellers table is 900 MB because of a data bug. What happens with your fix?
  6. How do you catch this kind of regression early?

The answer

What a strong answer covers

  • Compares a good run and a bad run in the Spark History Server: which stage grew, input sizes, shuffle sizes, spill, task time spread, and the SQL plan. Also checks what changed around Thursday: data volumes, cluster or instance changes, configs, library versions.
  • Finds the plan change: the join with sellers was a broadcast hash join and is now a sort-merge join, because the sellers table grew past the 10 MB broadcast threshold after an acquisition added 41,000 sellers. Now 610 GB of fact data is shuffled into 200 partitions of about 3 GB each, which spill heavily.
  • Quick fix: read only the 4 sellers columns the job uses (the table drops to about 2 MB) so it's broadcast again, or add a broadcast hint.
  • Proper fix: prune columns early; for big shuffles that remain, more shuffle partitions so each is a sensible size; adaptive execution already on.
  • Twist: a hint on a table that later grows to 900 MB forces a huge broadcast (driver memory, timeouts). So the hint needs a guard: a size check in the job or a data-quality check on the dimension's row count.
  • Prevents: alert on job runtime against its recent history, track dimension sizes, and review plans of critical jobs after big data changes.

The red pen

Common traps

Avoid:adding nodes first; raising the broadcast threshold for the whole cluster; "Spark is just slow".

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview