DataLane

All stacks · Compute & processing

Apache Spark

Distributed processing with PySpark and Spark SQL.

Apache Spark cover

Related reading

About Apache Spark

Spark is still the engine that processes more data than anything else in the industry — and the framework where the gap between "it runs" and "it runs well" is widest. Shuffles, skew, and memory spills separate ten-minute jobs from three-hour ones on identical clusters.

These tutorials treat Spark as a distributed SQL engine first: how the optimizer plans your query, where shuffles come from, how to read the Spark UI without dread, and the handful of configuration knobs that actually matter in PySpark jobs.

What you'll learn here

  • The execution model: jobs, stages, tasks, and what triggers a shuffle
  • DataFrame API fluency and reading physical plans with explain()
  • Skew, spill, and partition-count tuning with the Spark UI as your guide
  • Join strategies: broadcast, sort-merge, and when AQE fixes things for you
  • Writing to lakes properly: partitioning, file sizes, and compaction

Frequently asked questions

Do I still need Spark if I have Snowflake or BigQuery?

For pure SQL transformation on warehouse tables, often not. Spark earns its place for ML pipelines, semi-structured and unstructured data, streaming, and cost-sensitive heavy lifting on lake storage where warehouse compute would be expensive.

Why is my Spark job slow?

In order of likelihood: too many or too few shuffle partitions, data skew concentrating work in one task, spilling to disk from undersized memory, small-file storms on read, or a join that should have been broadcast. The Spark UI stage timeline tells you which one in about two minutes.

What is a shuffle and why does everyone fear it?

A shuffle redistributes rows across the cluster by key — required by wide operations like groupBy and joins. It serializes data to disk and moves it over the network, making it the most expensive thing Spark does. Good Spark tuning is mostly shuffle management.

PySpark or Scala?

PySpark. The DataFrame API compiles to the same plans as Scala, so performance is equivalent for untyped transformations, and the ecosystem, hiring pool, and notebook experience are all Python-first now. Scala matters mainly for low-level RDD work and library development.

How big should my partitions be?

Aim for 128–256 MB of data per partition as a starting point. Thousands of tiny tasks waste scheduler overhead; a handful of giant ones create stragglers. spark.sql.shuffle.partitions and adaptive query execution are the levers.

New Apache Spark posts, straight to your inbox

One email a week with our latest tutorials. No spam.

Newsletter signup is not live yet. Use the contact form if you want to be notified.

↑↓ navigate openesc close