Apache Spark is an open-source, distributed data processing engine designed to enable the rapid processing of large datasets across clusters of machines. It supports batch processing, SQL analytics, streaming, machine learning, and graph processing.
Apache Spark supports many cluster managers, such as Spark Standalone, Apache Hadoop YARN, and Kubernetes. YARN offers resource management and scheduling for Spark applications within Hadoop environments.
Let’s learn Apache Spark configuration, deployment, and administration in detail in this blog.
Table of Contents
Spark enables you to perform computations across multiple machines. It enables organizations to handle datasets that are too large or computationally intensive for a single system.
As of August 2026, Apache Spark 4.2.0 is the latest stable release. Let’s explore Apache Spark in more detail.
Key Highlights
Key Features
Let’s explore the key features of Apache Spark below.
The client-server architecture separates the Spark client from the cluster. Instead of using the full PySpark, which is 355 MB, a lightweight Python client, pyspark-connect, is used to connect to a remote Spark cluster through the DataFrame API.
It enables IDE-native development, such as in PyCharm or Jupyter, when working with production clusters. You can use the spark.api.mode configuration option to enable or disable Spark Connect functionality.
This feature causes log output to be in JSON format by default, with the setting being spark.log.structuredLogging.enabled=true. JSON logs can be directly integrated with log aggregation systems such as ELK, Grafana Loki, and Splunk.
In Apache Spark 4.2.0, the ANSI SQL mode is enabled by default using the setting spark.sql.ansi.enabled=true.
When ANSI mode is enabled, Spark adheres to more rigorous SQL semantics. It causes Spark to report errors for operations that would otherwise produce unexpected or invalid results.
In Apache Spark 4.2.0, Adaptive Query Execution (AQE) dynamically optimizes queries during execution. Rather than relying entirely on estimates generated during query planning, AQE uses runtime statistics to modify the physical execution plan.
Key refinements in AQE include:
Apache Spark ensures stability for large workloads with plans for zstd-compressed protobufs, chunked Arrow result streaming, and a RocksDB state store provider featuring improved lock management. Improvements help Spark handle large Structured Streaming workloads more reliably.
Google Cloud Dataproc is a managed service that lets you run Apache Spark and other open-source data-processing frameworks on Google Cloud. It helps you set up, configure, scale, monitor, and integrate clusters with Google Cloud services.
Google Cloud Dataproc is a service for Spark and Hadoop that manages cluster provisioning, configuration, and patching. Dataproc automatically supports every new Spark release. Google Cloud Dataproc offers specific image versions that include certain Spark versions.
With Apache Spark 4.2, Spark can run directly on Kubernetes, with driver and executor pods being scheduled by Kubernetes. The current Spark 4.2 documentation states that Kubernetes 1.34 or later is the prerequisite.
You can deploy Apache Spark using standalone, Kubernetes, and YARN deployment methods. The table below compares them based on multiple factors:
You need to use the k8s:// master URL when running spark-submit for Spark applications on Kubernetes. The following bash command demonstrates this:
The Spark driver runs in a Kubernetes pod and uses the Kubernetes API to create executor pods. When running in cluster mode, the application code and its dependencies must be accessible to the driver through a container image or a remote dependency location.
Spark provides the docker-image-tool.sh script to build Spark Docker images. The following example demonstrates how to build the image:
Next, you need to push the image to a container registry accessible by Kubernetes.
When deploying Spark in a production environment, you need to customize the image to include the application's dependencies, required Python or Java libraries, certificates, and other runtime requirements.
Spark Connect is a client-server architecture that separates the Spark client from the Spark driver. The client transmits logical plans to a Spark Connect server via gRPC. The server executes the plans using Spark's driver and cluster resources.
The architecture consists of multiple components, including a Spark Connect client, a gRPC connection, a Spark Connect server, and a Spark cluster.
First, start the Spark Connect server using the standard Spark installation.
./sbin/start-connect-server.sh
You can specify Spark configuration properties when starting the server. The default Spark Connect port is 15002.
You can configure Apache Spark security according to the deployment environment. A production setup typically combines TLS, authentication, authorization, encryption, secret management, and network controls to ensure a secure configuration.
Spark supports SSL/TLS for its network endpoints, including the Spark UI and internal Spark communication. You can configure the appropriate SSL and keystore/truststore settings for the services you need to protect.
Below is an example:
If you use the Spark Web UI, you can configure the UI-specific SSL settings using the script below.
spark.ssl.ui.enabled=true
Below are some best practices you must follow to ensure a secure configuration.
Apache Spark can run on Apache Hadoop YARN, which manages and schedules cluster resources.
A Spark application includes a driver program and executor processes; the driver coordinates the application, and the executors perform tasks and store data. Spark jobs are broken down into stages, which include tasks.
A Spark application includes a driver program that creates and manages a Spark session or Spark context; the driver coordinates the executors and schedules tasks across the cluster.
An application can be used for a single group of work, an interactive session with different tasks distributed across the cluster, or a persistent server continuously fulfilling requirements.
Unlike MapReduce, a process will have procedures, called Executors, running on the batch for its sake when it’s not running any tasks. This methodology enables in-memory data caching for fast access and extremely fast task startup times.
MapReduce runs every job in its own process. Spark executors are processes launched on worker nodes by the cluster manager. They perform tasks, cache or persist data, and communicate with the driver.
Generally, executors remain available for the entire duration of an application, provided that the executor lifecycle and dynamic allocation settings allow it.
This process remains active for the lifetime of the Spark application, even when no jobs are running. The advantage of this model is the speed at which it completes the process. Jobs can start up rapidly and process in-memory data. The disadvantage of this model is coarse-grained resource management.
When dynamic allocation is not in use, the number of executors assigned to an application usually stays the same after they have been allocated. However, when dynamic allocation is enabled, Spark can add or remove executors in response to workload demand.
To manage the task stream and schedule tasks, Spark relies on a dynamic driver process.
The Spark driver is responsible for coordinating application execution and scheduling tasks in client-deploy mode. Conversely, in MapReduce, the client process can exit while the task continues running.
In Hadoop 1.x, the JobTracker was responsible for job scheduling, and in Hadoop 2.x, the MapReduce client process is responsible for the same.
Spark supports pluggable cluster managers. The cluster manager is responsible for launching executors. Spark application developers do not need to manage cluster-manager-specific details.
Spark is compatible with various cluster managers, such as Spark Standalone, Apache Hadoop YARN, and Kubernetes. Each of these systems has two components. A cluster manager (the YARN Resource Manager or a Spark Standalone client) chooses which applications run, where, and when.
Using YARN as Spark’s cluster manager provides several advantages over Spark Standalone:
While MapReduce launches a container and starts a JVM for each task, Spark runs tasks within the same container. Spark applications can run on YARN in two deployment modes: In client mode, the driver operates within the client process that submits the application. In cluster mode, the driver operates within the YARN cluster.
Cluster mode is commonly used for production applications because the driver is managed within the cluster rather than relying on the submitting client to remain available. Understanding this distinction requires familiarity with YARN’s application client concept.
In YARN, every application has an Application Client process, which is the first process started for that application. The application is responsible for requesting resources from the Resource Manager and, when allocated, instructing NodeManagers to start containers.
In cluster mode, the driver runs in the ApplicationMaster. This implies that the same procedure both drives the application and requests resources from YARN, and that it runs inside a YARN container. The client that begins the application doesn’t have to remain connected for its whole lifetime.
In application mode, however, it is not appropriate for interactive Spark use. Spark applications that require client information, such as Spark Shell and PySpark, need the Spark driver to remain running within the client process that starts the application.
In yarn-client mode, the Application Master is present to request cluster manager containers from YARN.
We’ll next walk through the key Spark performance and execution concepts in the following.
We’ll first review the major components of Spark's architecture, including caching, shuffling, serialization, and partitioning.
1. Caching
Spark provides a feature that enables frequently reused datasets to be cached or persisted, so that subsequent operations can avoid recomputing them. The different persistence levels specify whether the data is stored in memory, on disk, or using both memory and disk.
However, it will be challenging if you have multiple cached datasets, as the amount of resources depends on both the chosen storage level and the dataset size.
2. Shuffle
Some operations require data movement, although shuffling can be expensive. For instance, by shuffling data, it is redistributed among the partitions, usually among the executor nodes, so that the records required by subsequent operations are colocated.
3. Serialization
The easiest way to achieve serialization is to use different code on the same data. It has led to the use of the JVM across many frameworks.
Serialization involves converting objects or data structures into a byte-oriented format. It allows them to be stored or transmitted efficiently. Spark uses serializers such as Java serialization and Kryo.
4. Partitions
Spark includes many programming abstractions such as RDDs and the more advanced DataFrame and Dataset APIs. When it comes to processing structured data, DataFrames and Spark SQL are usually preferred to the direct use of RDDs.
Complex operations such as groupBy or join can be performed using Spark’s DataFrame and Dataset APIs.
We will now discuss how these components affect Spark application performance.
1. Memory Management and Caching
Spark supports in-memory caching. A disadvantage of memory caching is that it consumes significant memory. If you use YARN and the JVM, they consume a significant amount of memory. This reduces the amount of memory available for other operations, such as caching and data movement.
Therefore, it is important to use appropriate partitioning strategies. It will help reduce memory management and improve resource utilization. It helps avoid data skew.
Moreover, you can use batches to divide long-running jobs. It allows you to run each batch of the job in a new environment with no accumulated metadata.
2. Minimize Unnecessary Data Movement
Minimizing data transfer and avoiding shuffles would lead to faster and more reliable programs. Repartition() should be used when it is necessary to redistribute the data across the partitions, and coalesce() should be used when you want to reduce the number of partitions without needing a full shuffle.
It is advisable to avoid unnecessary repartitioning, as shuffles can increase both network and disk I/O. You should also avoid join operations like join and cogroup, as well as ByKey operations such as reduceByKey and groupByKey. Two mechanisms provided by Spark are Broadcast variables and Accumulators.
3. Speed
Caching should be employed only when a dataset is used across multiple stages, and recomputation would be expensive. Instead of using data twice, cache it in memory.
Broadcast variables should be used for small, read-only datasets that are reused across different tasks and would otherwise demand costly data shuffles. When broadcasting large values, it is necessary to monitor executor memory usage.
Finally, you should run Spark programs in parallel. Processing one key at a time could lead to poor resource utilization. Using this method would also deny you the advantages of Spark's built-in parallelism.
Client mode and cluster mode are the two primary deployment modes of Apache Spark.
No. Apache Mesos is not supported in Apache Spark 4.x.
Spark Connect is an Apache Spark client–server architecture that separates the application client from the Spark driver. It was introduced in Spark 3.4 and is still supported in Spark 4.x.
Apache Spark 4.x requires at least Java 17 and officially supports Java 17 and 21 as of Spark 4.2.0.
Both YARN and Kubernetes are supported as cluster managers for Spark 4.2. The choice largely depends on your existing platform and operational requirements.
The major logging enhancement in Spark 4.0 is optional structured logging. This new version includes support for JSON Template Layout when emitting logs, making them simpler to parse, search, correlate, and feed into modern observability platforms.
This tutorial has provided you with an in-depth understanding of Apache Spark deployments, configurations, and Apache Spark Connect architecture. You have gained an understanding of Spark security concepts, running Spark on YARN, and much more.
If you would like to learn more about Apache Spark and its core concepts, you are not alone. You can step into the MindMajix Apache Spark Course to further advance your career.

Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:
| Name | Dates | |
|---|---|---|
| Apache Spark Training | Aug 29 to Sep 13 | View Details |
| Apache Spark Training | Sep 01 to Sep 16 | View Details |
| Apache Spark Training | Sep 05 to Sep 20 | View Details |
| Apache Spark Training | Sep 08 to Sep 23 | View Details |

Vinod Kasipuri is a seasoned expert in data analytics, holding a master's degree in the field. With a passion for sharing knowledge, he leverages his extensive expertise to craft enlightening articles. Vinod's insightful writings empower readers to delve into the world of data analytics, demystifying complex concepts and offering valuable insights. Through his articles, he invites users to embark on a journey of discovery, equipping them with the skills and knowledge to excel in the realm of data analysis. Reach Vinod at LinkedIn.