Spark Local模式JVM数量及本地部署模式判定咨询
Hey there! Let's break down your questions clearly:
In Spark Local mode, everything runs within a single JVM. This includes the Driver program, the simulated cluster manager, and all executor threads. Even if you specify local[*] (using all available cores) or local[n] (using n cores), it's still one JVM—only the number of executor threads changes, not the JVM count.
First off: You're not using Local mode right now—you've set up a Spark Standalone cluster (single-node, since it's all on your laptop). Here's why:
- Local mode doesn't require manually starting separate Master or Worker processes. You'd run your Spark application directly with a
--masterflag likelocal,local[n], orlocal[*](e.g.,spark-shell --master local[*]), and all components live in the same JVM as your Driver. - When you run
spark-class org.apache.spark.deploy.master.Masterandspark-class org.apache.spark.deploy.worker.Worker, you're launching independent, separate JVM processes: one for the Master, one for each Worker. Seeing 3 total JVMs here is completely expected for this setup.
Your confusion comes from mixing up Local mode and Standalone mode:
- Local mode is designed for development/testing on a single machine, with no separate cluster manager processes—it simulates the cluster within the Driver's JVM.
- Standalone mode is Spark's built-in cluster manager, where you have dedicated Master (resource scheduler) and Worker (executor host) processes, even if they're on the same physical machine.
To answer your final question: Yes, your current Standalone setup does have a cluster manager—Spark's own Master process is acting as the cluster manager, handling resource allocation to Workers. Local mode doesn't need a separate cluster manager because it's all contained in one JVM.
If you want to try Local mode, just run spark-shell (it defaults to local[*]) or submit an app with --master local[*]—no need to start Master/Worker processes manually!
内容的提问来源于stack exchange,提问作者lee

