Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Executor Memory (and other configs) for Spark Shell

Tags:

apache-spark

How to change executor memory (and other configs) for Apache Spark Shell?

In particular I would like to give flats to spark-shell, like -Dspark-cores-max=12 when I start it so that my jobs in the spark shell will use those configuration settings.

like image 845
samthebest Avatar asked Apr 09 '14 19:04

samthebest


People also ask

How do I change the executor memory in Spark?

To enlarge the Spark shuffle service memory size, modify SPARK_DAEMON_MEMORY in $SPARK_HOME/conf/spark-env.sh, the default value is 2g, and then restart shuffle to make the change take effect.

How do you allocate driver memory and executor memory in Spark?

Determine the memory resources available for the Spark application. Multiply the cluster RAM size by the YARN utilization percentage. Provides 5 GB RAM for available drivers and 50 GB RAM available for worker nodes. Discount 1 core per worker node to determine the executor core instances.


3 Answers

As of spark 1.2.0 you can set memory and cores by giving following arguments to spark-shell.

spark-shell --driver-memory 10G --executor-memory 15G --executor-cores 8

to see other options you can give following commands to spark shell

spark-shell --help
like image 168
Junaid Avatar answered Oct 16 '22 11:10

Junaid


If you are running the spark-shell on spark installed on standalone mode (1 node), use

./bin/spark-shell --driver-memory 4g

If you are running the spark-shell on spark installed on cluster (2+ nodes), use

./bin/spark-shell --executor-memory 4g

4g is 4GB.

like image 27
Orhan Celik Avatar answered Oct 16 '22 10:10

Orhan Celik


DEPRECATED USE ACCEPTED ANSWER

Write a script like this:

#!/bin/bash
export SPARK_JAVA_OPTS="$*"
MASTER=spark://ec2-99-99-99-99:7077 /usr/share/spark/bin/spark-shell

/usr/share/spark/bin/spark-shell should be the path to where the long spark-shell starting script is. On my cluster there was another script in /usr/local/bin/ but this one was just a few lines similar to above and had SPARK_JAVA_OPTS hardcoded.

Anyway, example use:

my-spark-starter-script -Dspark-cores-max=12 -Dspark.executor.memory=26000m
like image 1
samthebest Avatar answered Oct 16 '22 10:10

samthebest