Skip to content

Commit a416e41

Browse files
committed
[SPARK-11809] Switch the default Mesos mode to coarse-grained mode
Based on my conversions with people, I believe the consensus is that the coarse-grained mode is more stable and easier to reason about. It is best to use that as the default rather than the more flaky fine-grained mode. Author: Reynold Xin <[email protected]> Closes #9795 from rxin/SPARK-11809.
1 parent 31921e0 commit a416e41

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2710,7 +2710,7 @@ object SparkContext extends Logging {
27102710
case mesosUrl @ MESOS_REGEX(_) =>
27112711
MesosNativeLibrary.load()
27122712
val scheduler = new TaskSchedulerImpl(sc)
2713-
val coarseGrained = sc.conf.getBoolean("spark.mesos.coarse", false)
2713+
val coarseGrained = sc.conf.getBoolean("spark.mesos.coarse", defaultValue = true)
27142714
val url = mesosUrl.stripPrefix("mesos://") // strip scheme from raw Mesos URLs
27152715
val backend = if (coarseGrained) {
27162716
new CoarseMesosSchedulerBackend(scheduler, sc, url, sc.env.securityManager)

docs/job-scheduling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ application is not running tasks on a machine, other applications may run tasks
4747
is useful when you expect large numbers of not overly active applications, such as shell sessions from
4848
separate users. However, it comes with a risk of less predictable latency, because it may take a while for
4949
an application to gain back cores on one node when it has work to do. To use this mode, simply use a
50-
`mesos://` URL without setting `spark.mesos.coarse` to true.
50+
`mesos://` URL and set `spark.mesos.coarse` to false.
5151

5252
Note that none of the modes currently provide memory sharing across applications. If you would like to share
5353
data this way, we recommend running a single server application that can serve multiple requests by querying

docs/running-on-mesos.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,15 @@ Note that jars or python files that are passed to spark-submit should be URIs re
161161

162162
# Mesos Run Modes
163163

164-
Spark can run over Mesos in two modes: "fine-grained" (default) and "coarse-grained".
164+
Spark can run over Mesos in two modes: "coarse-grained" (default) and "fine-grained".
165165

166-
In "fine-grained" mode (default), each Spark task runs as a separate Mesos task. This allows
167-
multiple instances of Spark (and other frameworks) to share machines at a very fine granularity,
168-
where each application gets more or fewer machines as it ramps up and down, but it comes with an
169-
additional overhead in launching each task. This mode may be inappropriate for low-latency
170-
requirements like interactive queries or serving web requests.
171-
172-
The "coarse-grained" mode will instead launch only *one* long-running Spark task on each Mesos
166+
The "coarse-grained" mode will launch only *one* long-running Spark task on each Mesos
173167
machine, and dynamically schedule its own "mini-tasks" within it. The benefit is much lower startup
174168
overhead, but at the cost of reserving the Mesos resources for the complete duration of the
175169
application.
176170

177-
To run in coarse-grained mode, set the `spark.mesos.coarse` property in your
178-
[SparkConf](configuration.html#spark-properties):
171+
Coarse-grained is the default mode. You can also set `spark.mesos.coarse` property to true
172+
to turn it on explictly in [SparkConf](configuration.html#spark-properties):
179173

180174
{% highlight scala %}
181175
conf.set("spark.mesos.coarse", "true")
@@ -186,6 +180,19 @@ acquire. By default, it will acquire *all* cores in the cluster (that get offere
186180
only makes sense if you run just one application at a time. You can cap the maximum number of cores
187181
using `conf.set("spark.cores.max", "10")` (for example).
188182

183+
In "fine-grained" mode, each Spark task runs as a separate Mesos task. This allows
184+
multiple instances of Spark (and other frameworks) to share machines at a very fine granularity,
185+
where each application gets more or fewer machines as it ramps up and down, but it comes with an
186+
additional overhead in launching each task. This mode may be inappropriate for low-latency
187+
requirements like interactive queries or serving web requests.
188+
189+
To run in coarse-grained mode, set the `spark.mesos.coarse` property to false in your
190+
[SparkConf](configuration.html#spark-properties):
191+
192+
{% highlight scala %}
193+
conf.set("spark.mesos.coarse", "false")
194+
{% endhighlight %}
195+
189196
You may also make use of `spark.mesos.constraints` to set attribute based constraints on mesos resource offers. By default, all resource offers will be accepted.
190197

191198
{% highlight scala %}

0 commit comments

Comments
 (0)