Apache Spark is a fast, general purpose engine for processing large amounts of data across a cluster of machines. It offers high level APIs in Java, Scala, Python, and R, backed by an optimized execution engine, along with higher level tools for SQL and structured data processing, machine learning, graph processing, and stream processing, all built on the same core engine.
Spark began life in 2009 as a research project inside UC Berkeley’s AMPLab. It was released as open source in 2010 under the BSD license, then donated to the Apache Software Foundation in 2013, becoming a top level Apache project in 2014. Development has continued steadily since, and Spark is now in its fourth major version line, still actively maintained by the Apache community.
Before Spark, different jobs typically needed different specialized tools. Hadoop MapReduce handled batch processing. Apache Storm or S4 handled stream processing. Apache Impala or Tez handled interactive queries. Neo4j or Apache Giraph handled graph processing. No single engine covered all of these well, and none of them offered fast, in memory processing with sub second response times.
Spark’s pitch was to be that one engine, real time streaming, interactive queries, graph processing, and batch processing, all handled through in memory processing that runs meaningfully faster than reading and writing to disk at every step. That combination, plus a consistent interface across all of it, is what set Spark apart from Hadoop and from single purpose tools like Storm.


Spark has a layered architecture where its components stay loosely coupled, which is what makes it straightforward to extend with additional libraries. The architecture rests on two core abstractions: the Resilient Distributed Dataset, or RDD, and the Directed Acyclic Graph or DAG, which represents the sequence of steps in a computation.

Like Hadoop MapReduce, Spark distributes data across a cluster and processes it in parallel. It uses a master and worker style architecture, one central coordinator and many distributed workers. That central coordinator is called the driver.
The Spark Context is the entry point of a Spark application. It connects to the Spark execution environment and is used to create RDDs, accumulators, and broadcast variables, access Spark services, and run jobs. Its responsibilities include:
The Spark Shell is a Spark application written in Scala that gives you a command line environment with auto completion, useful for getting familiar with Spark’s features before writing a standalone application of your own.
A Spark application is a self contained computation that runs user supplied code to produce a result. It can have processes running on its behalf even when it is not actively running a job.
The driver runs the main method of your program. It is the process that creates RDDs, performs transformations and actions on them, and creates the Spark Context. Launching the Spark Shell is itself an example of starting a driver program, and the application ends once the driver terminates.
The driver splits a Spark application into tasks and schedules them onto executors, through a task scheduler that lives inside the driver itself. Its two key jobs are converting your program into tasks, and scheduling those tasks on executors.
At a high level, a Spark program takes some input data as an RDD, derives new RDDs from it through transformations, then runs an action to actually compute a result. This builds up a DAG of operations implicitly as you write your code, and when the driver runs, it converts that DAG into an actual physical execution plan.
Spark relies on a cluster manager to launch executors, and in some setups, to launch the driver as well. The cluster manager is a pluggable component, jobs and actions within a Spark application are scheduled by Spark’s own scheduler, by default in FIFO order, though round robin scheduling is also available. Applications can grow or shrink their resource usage dynamically based on workload, freeing resources when idle and requesting more again when demand returns. Spark currently supports this dynamic allocation across standalone mode, YARN, and Kubernetes. Apache Mesos was a supported option in earlier Spark versions, but that support was deprecated in Spark 3.2 and fully removed in Spark 4.0.
Executors run the individual tasks that make up a Spark job. They launch once at the start of an application and stay alive for its entire lifetime, and if one executor fails, the application can generally continue without stopping entirely. Executors have two main jobs: running the tasks that make up the application and returning results to the driver, and providing in memory storage for any RDDs the user has chosen to cache.

RDDs are the building blocks of any Spark application. RDDs Stands for:

One of Spark’s most useful capabilities is persisting or caching, a dataset in memory across multiple operations. Once an RDD is persisted, each node keeps the partitions it computed in memory and reuses them for later actions on that same dataset or on datasets derived from it, which can make later operations dramatically faster, often by an order of magnitude, particularly for iterative algorithms and interactive analysis.
You mark an RDD for persistence using persist or cache. The first action that computes it will keep it in memory going forward. Spark’s cache is itself fault tolerant, if a partition is lost, Spark automatically recomputes it using the same transformations that built it originally.
A persisted RDD can use different storage strategies, called storage levels, depending on your priorities:
When you launch a Spark application, the master URL tells Spark where and how to run:
YARN can run Spark in two different modes, cluster and client, and standalone mode offers a third option that does not depend on YARN at all:
| YARN Cluster | YARN Client | Standalone | |
| Driver runs in | Application master | Client machine | Client machine |
| Requests resources | Application master | Application master | Client machine |
| Starts executor processes | YARN NodeManager | YARN NodeManager | Spark worker |
| Long running services | YARN ResourceManager, NodeManager | YARN ResourceManager, NodeManager | Spark master, worker |


That covers Apache Spark’s architecture, terminology, deployment options, and real world use cases. To go further, explore Prwatech’s Apache Spark training program, which includes placement assistance.