STREAMING & PRODUCTIONPySpark

Deploying Spark: spark-submit, YARN & Kubernetes

Distributed data processing with Spark — pick a topic on the left and its full breakdown loads here: the execution model, worked jobs and diagrams, performance and shuffle behavior, and the habits that keep Spark jobs fast, correct, and affordable.

18 min readTopics chapter readerLevel · Production
01 · Orientation

What You'll Master Here

spark-submit is the launcher. Deploy mode decides where the driver runs. Cluster manager (YARN/K8s) hands out executors. Sizing decides how big and how many. Get these four right and the job runs well.

4 min · Topic 1 of 4

Writing the job is one thing; getting it onto a cluster correctly and economically is another. This chapter covers deployment: spark-submit (the universal way to launch a job), client vs cluster deploy modes, sizing resources (executors, cores, memory) so the job actually fits and runs well, dynamic allocation, and the main cluster managers, YARN and Kubernetes.

These are the decisions that determine whether your job runs at all, how fast, and at what cost. Most "my job won't start" or "it's wasting money" problems are deployment and sizing problems, not logic problems.

With a diagram of the deploy modes and a spark-submit example with sensible resource flags. The goal: launch jobs deliberately, with resources matched to the work.

Core mental model

spark-submit is the launcher. Deploy mode decides where the driver runs. Cluster manager (YARN/K8s) hands out executors. Sizing decides how big and how many. Get these four right and the job runs well.

Why it matters

Resource sizing and deploy mode are where real money and reliability live. Mis-sized executors waste budget or cause OOM; the wrong deploy mode breaks production jobs. These are everyday concerns and common interview ground.

spark-submit
The command that launches a Spark application on any cluster manager.
deploy mode
Where the driver runs: client (your machine) or cluster (in the cluster).
cluster manager
What allocates resources: standalone, YARN, or Kubernetes.
dynamic allocation
Spark adding/removing executors based on workload demand.
Common mistake

Using client mode for a long-running production job. The driver dies if your client machine disconnects, use cluster mode for production.

Better habit

Use cluster mode for production, client mode for interactive work.

Size executors deliberately (cores, memory) to fit the work and cluster.

Enable dynamic allocation for variable or bursty workloads.

The big idea

Deployment is four decisions: how to launch (spark-submit), where the driver runs (deploy mode), who allocates executors (cluster manager), and how big/many they are (sizing). Each affects reliability and cost.

Remember this

Deploying Spark means launching with spark-submit, choosing a deploy mode (cluster for production), picking a cluster manager (YARN/Kubernetes), and sizing executors/cores/memory, optionally with dynamic allocation. These choices drive reliability and cost more than code does.

Practice2 prompts
  1. What four decisions make up deploying a Spark job?
  2. Why is cluster mode preferred for production?