Spark JVMs and memory management
Spark jobs running on DataStax Enterprise are divided among several different JVM processes, each with different memory requirements.
The Spark Master runs in the same process as DataStax Enterprise, but its memory usage is negligible.
The only way Spark could cause an OutOfMemoryError in DataStax Enterprise is indirectly by executing queries that fill the client request queue.
For example, if it ran a query with a high limit and paging was disabled or it used a very large batch to update or insert data in a table.
This is controlled by
If you see an OutOfMemoryError in
system.log, you should treat it as a standard OutOfMemoryError and follow the usual troubleshooting steps.
The Spark executor is where Spark performs transformations and actions on the RDDs and is usually where a Spark-related OutOfMemoryError would occur.
An OutOfMemoryError in an executor will show up in the
stderr log for the currently executing application (usually in
There are several configuration settings that control executor memory and they interact in complicated ways.
memory_totaloption in the
dse.yamldefines the maximum fraction of system memory to give all executors for all applications running on a particular node. It uses the following formula:
memory_total * (total system memory - memory assigned to DataStax Enterprise)
spark.executor.memoryis a system property that controls how much executor memory a specific application gets. It must be less than or equal to the calculated value of
memory_total. It can be specified in the constructor for the SparkContext in the driver application, or via
--executor-memorycommand line options when submitting the job using spark-submit.
The driver is the client program for the Spark job.
Normally it shouldn’t need very large amounts of memory because most of the data should be processed within the executor.
If it does need more than a few gigabytes, your application may be using an anti-pattern like pulling all of the data in an RDD into a local data structure by using collect or take.
Generally you should never use collect in production code and if you use take, you should be only taking a few records.
If the driver runs out of memory, you will see the OutOfMemoryError in the driver
stderr or wherever it’s been configured to log.
This is controlled one of two places:
spark.driver.memorysystem property which can be specified via
--driver-memorycommand line options when submitting the job using
spark-submit. This cannot be specified in the SparkContext constructor because by that point, the driver has already started.
The worker is a watchdog process that spawns the executor, and should never need its heap size increased.
The worker’s heap size is controlled by
SPARK_DAEMON_MEMORY also affects the heap size of the Spark SQL thrift server.