Skip to the page
Tecyfy

PySpark interview question · hard

What is the difference between Cluster and Client deployment modes in Spark?

The short answerThe deploy mode decides where the driver runs.

The full answer

The deploy mode decides where the driver runs. In client mode the driver runs inside the process that started the application, such as spark-submit on an edge node, a notebook or your laptop. In cluster mode the cluster manager starts the driver on a machine inside the cluster, and spark-submit can exit once the application is launched.

spark-submit --master yarn --deploy-mode client  job.py     # driver on this machine
spark-submit --master yarn --deploy-mode cluster job.py     # driver in a YARN container
Client modeCluster mode
Driver locationThe submitting machineA node in the cluster
Output and logs of the driverThe console where you submittedThe cluster's logs
If the submitting machine disconnectsThe application diesThe application keeps running
Network between driver and executorsMay be slow if the client is far awayLocal to the cluster
Interactive use (shells, notebooks)YesNo
Typical useDevelopment, debugging, notebooks, interactive shellsProduction jobs and schedulers

Client mode in more detail

  • The driver's resources are the client machine's; a large collect() or broadcast can exhaust a small edge node.
  • Executors must be able to connect back to the client, which matters with firewalls and in Kubernetes.
  • Good for seeing output immediately and for interactive tools such as pyspark and notebooks.

Cluster mode in more detail

  • The driver gets resources from the cluster (--driver-memory, --driver-cores) and fails over with the cluster manager's support (for example YARN application attempts).
  • Logs must be collected from the cluster (yarn logs -applicationId ..., or driver pod logs in Kubernetes).
  • Application files and dependencies must be reachable from the cluster (uploaded with --py-files, --files or --archives, or in shared storage).

Cluster manager specifics

  • YARN: in cluster mode the driver runs in the application master container.
  • Kubernetes: cluster mode creates a driver pod, which creates executor pods; client mode needs the driver to be reachable from the pods.
  • Standalone: cluster mode isn't supported for Python applications, so PySpark jobs on standalone clusters run in client mode.
  • Local (--master local[*]): everything runs in one process; deploy mode doesn't apply.

Managed platforms On Databricks, EMR Serverless or Dataproc Serverless you don't choose: the platform runs the driver for you, and notebooks connect to it, effectively client-style interaction with cluster-side drivers.

How I choose Client mode for exploration and debugging close to the cluster; cluster mode for scheduled production jobs, so they don't depend on the submitting machine staying up.

Last updated 16 October 2026