Spark Jobs API

This API has a set of endpoints for configuring and running Spark jobs.

Spark job subtypes

For the Spark job type, the available subtypes are listed below.

Job subtype Description


Define an aggregation job to be executed by Fusion Spark.

ALS Recommender

Train a collaborative filtering matrix decomposition recommender using SparkML’s Alternating Least Squares (ALS) to batch-compute user recommendations and item similarities.

Bisecting KMeans Clustering Job

Train a bisecting KMeans clustering model.

Cluster Labeling

Attach keyword labels to documents that have already been assigned to groups. See Doc Clustering below.

Collection Analysis

Produce statistics about the types of documents in a collection and their lengths.

Co-occurrence Similarity

Compute a mutual-information item similarity model.

Doc Clustering

Preprocess documents, separate out extreme-length documents and other outliers, automatically select the number of clusters, and extract keyword labels for clusters. You can choose between Bisecting KMeans and KMeans clustering methods, and between TFIDF and word2vec vectorization methods.

Item Similarity Recommender

Compute user recommendations based on pre-computed item similarity model.


Compare the items in a collection and produces possible spelling mistakes based on the Levenshtein edit distance.

Logistic Regression Classifier Training Job

Train a regularized logistic regression model for text classification.

Matrix Decomposition-Based Query-Query Similarity Job

Train a collaborative filtering matrix decomposition recommender using SparkML’s Alternating Least Squares (ALS) to batch-compute query-query similarities.

Outlier Detection

Find groups of outliers for the entire set of documents in the collection.

Random Forest Classifier Training

Train a random forest classifier for text classification.


Run a custom Scala script as a Fusion Job.

Statistically Interesting Phrases (SIP)

Output statistically interesting phrases in a collection, that is, phrases that occur more frequently or less frequently than expected.

Spark Configuration Properties

Fusion passes all configuration properties with the prefix spark. to the Spark master, Spark worker, and each Spark application, both for aggregation jobs and custom-scripted processing.

These properties are stored in Fusion’s ZooKeeper instance. You can updated properties through requests to the Fusion endpoint api/apollo/configurations. Requests update the stored value without restarting the service; therefore existing jobs and SparkContexts are not affected. The Fusion endpoint api/apollo/configurations returns all configured properties for that installation. You can examine spark default configurations in a Unix shell using the utilities curl and grep. Here is an example that checks a local Fusion installation running on port 8764:

curl -u username:password http://localhost:8764/api/apollo/configurations | grep '"spark.'

  "spark.executor.memory" : "2g",
  "spark.task.maxFailures" : "10",
  "spark.worker.cleanup.appDataTtl" : "7200",
  "spark.worker.cleanup.enabled" : "true",
  "spark.worker.memory" : "2g",

The default SparkContext that Fusion uses for aggregation jobs can be assigned a fraction of cluster resources (executor memory and/or available CPU cores). This allows other applications (such as scripted jobs, or shell sessions) to use the remaining cluster resources even when some aggregation jobs are running. Fusion 2.3 also permits dynamic allocation for all applications. This can be overridden per application. In practice, this means that even when there’s an already running SparkContext with a relatively long idle time (eg. 10 minutes) but there are no active jobs that use it, its resources (CPU cores and executor memory) will be released for use by other applications.

For scripted Spark jobs, users can specify per-job configuration overrides as a set of key/value pairs in a "sparkConfig" property element of a script job configuration, which takes precedence over values stored in ZooKeeper. The following is an example of a scripted job with a "sparkConfig" section:

  "id": "scripted_job_example",
  "script": "val rdd = sc.textFile(\"/foo.txt\")\nrdd.count\n",
  "sparkConfig": {
    "spark.cores.max": 2,
    "spark.executor.memory": "1g"

The following table lists those Spark configuration properties that Fusion overrides or uses in order to determine applications' resource allocations.

Property Description


By default, left unset. This property is only specified when using an external Spark cluster; when Fusion is using its own standalone Spark cluster, this property isn’t set.


The maximum number of cores across the cluster assigned to the application. If not specified, there is no limit. The default is unset, i.e., an unlimited number of cores.


Amount of memory assigned to each application’s executor. The default is 2G.


Controls how tasks are assigned to available resources. Can be either 'FIFO' or 'FAIR'. Default value is 'FAIR'.


Boolean - whether or not to enable dynamic allocation of executors. Default value is 'TRUE'.


Boolean - whether or not to enable internal shuffle service for standalone Spark cluster. Default value is 'TRUE'.


Number of seconds after which idle executors are removed. Default value is '60s'.


Number of executors to leave running even when idle. Default value is 0.


Boolean - whether or not event log is enabled. Event log stores job details and can be accessed after application finishes. Default value is 'TRUE'.


Directory which stores event logs. Default location is fusion/3.1.x/var/spark-eventlog.


Boolean - whether or not to compress event log data. Default value is 'TRUE'.


Boolean - whether or not to log effective SparkConf of new SparkContext-s. Default value is 'TRUE'.


Default value is 'ZOOKEEPER'


ZooKeeper connect string. Default value is $FUSION_ZK


ZooKeeper path, default value is /lucid/spark


Boolean - whether or not to periodically cleanup worker data. Default value is 'TRUE'.


Time-to-live in seconds. Default value is 86400 (24h).


The maximum number of applications to show in the UI. Default value is 50.


The maximum number of drivers. Default value is 50.


The maximum timeout in seconds allowed before a worker is considered lost. The default value is 30.


The maximum total heap allocated to all executors running on this worker. Defaults to value of the executor memory heap.

Fusion Configuration Properties

Property Description


Spark master job submission port. Default value is 8766.


Spark master UI port. Default value is 8767.


Maximum idle time in seconds, after which the application (ie. SparkContext) is shut down. Default value is 300.


Minimum executor memory in MB. Default value 450Mb, which is sufficient to let Fusion components in application task’s to initialize themselves


A float number in range (0.0, 1.0] indicating what portion of spark.executor.memory to allocate to this application. Default value is 1.0.


A float number in range (0.0, 1.0] indicating what portion of spark.cores.max to allocate to this application. Default value is 1.0.