internalsGet Pro

Module 08 · Lesson 11 of 14Pro

Caching and memory in Spark

Level
Advanced
Topic
Batch processing with Spark
Reading time
18 min

When you finish this page you can

  1. Explain why Spark recomputes a DataFrame for every action, and what cache() changes.
  2. Work out how much of an executor’s memory can hold cached data, starting from spark.executor.memory.
  3. Predict what happens to cached blocks when a shuffle or aggregation needs memory.
  4. Tell a driver out-of-memory error, an executor heap error and a killed container apart, and fix each one.

Builds on 3 lessons

Start with lesson 317 min
  1. Spark architecture: driver, executors and tasks17 min
  2. Lazy evaluation and Spark query plans16 min
  3. Shuffles: the most expensive step in Spark17 min

One job reads the same week three times

is an online store in India. Its apps send about 200 million click events a day, and they land as files in the S3 bucket kartly-raw-prod. Meera, a data engineer on Kartly’s data team, runs a weekly Spark job for the product team called product_funnel_weekly. It reads last week’s product views and add-to-cart clicks and writes three small summary tables.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan