Apache Spark Fundamentals
Apache Spark is a distributed computing engine for large-scale data processing. It runs batch and streaming workloads across a cluster using in-memory computation, providing APIs for SQL, machine learning, graph processing, and structured streaming.
itData engineering and analytics | OpenSkills.info
Intro
Apache Spark Fundamentals
Apache Spark executes data processing work across one machine or a cluster. You describe transformations over distributed data. Spark plans the work, divides it into tasks, and runs those tasks in parallel.
The central mental model is a lazy dataflow executed over partitions.
data sources -> transformations -> logical plan -> jobs -> stages -> tasks
| |
shuffles partitions
|
executors
Spark is a compute engine. It reads from storage systems and writes results back to them. It does not replace object storage, a distributed file system, a warehouse, or a transactional database.
Why distributed data processing exists
One process eventually meets a limit. The input may exceed one machine's memory. A computation may take too long on one core. Data may already live across many files or machines.
Distributed processing divides the input into partitions. Several workers can process different partitions at the same time. This adds capacity, but it also adds network transfer, serialization, scheduling, and failure modes.
Spark gives you one programming model for this work. You can express relational transformations with DataFrames or SQL. You can use lower-level resilient distributed datasets when you need direct control over distributed objects. Structured Streaming extends the structured APIs to incremental queries over arriving data.
One application has one driver and many executors
A Spark application consists of a driver process and executor processes.
The driver runs your main program. It creates the Spark session, builds execution plans, requests resources, schedules work, and collects status. The driver must remain reachable from the executors during the application.
A cluster manager allocates resources. Spark supports its standalone manager, Hadoop YARN, and Kubernetes.
An executor belongs to one application. It runs tasks and can keep data in memory or on disk for that application.
cluster manager
|
driver -> request resources ---+
|
+------ tasks ------> executor A -> partitions 0 and 1
+------ tasks ------> executor B -> partitions 2 and 3
Applications do not share executor memory. To share data across applications, write it to an external storage system.
Start with SparkSession
Continue the course
This section is part of the paid course.
See pricing to subscribe, or log in if you already have access.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://spark.apache.org/docs/latest/
Supports
- Apache Spark as a unified analytics engine for large-scale data processing
- Current Apache Spark 4.1.2 documentation version and supported runtime overview
- Official programming-guide boundaries among RDDs, Spark SQL, DataFrames, Structured Streaming, machine learning, and graph processing
- Standalone, YARN, and Kubernetes deployment choices
- Spark Connect as a client-server interface separate from embedded applications
- https://spark.apache.org/docs/latest/quick-start.html
Supports
- SparkSession-based self-contained applications
- Interactive shell and local application learning path
- Transformations and actions in basic examples
- Caching for repeatedly accessed datasets and iterative algorithms
- Packaging and launching Python, Java, and Scala applications
- https://spark.apache.org/docs/latest/sql-getting-started.html
Supports
- SparkSession as the entry point for Spark functionality
- DataFrame creation from RDDs, tables, and Spark data sources
- DataFrame operations in Python, Scala, Java, and R
- Programmatic SQL returning DataFrames or Datasets
- Dataset encoders and the typed Dataset interface for Scala and Java
- Interoperation between structured data and RDDs
- https://spark.apache.org/docs/latest/cluster-overview.html
Supports
- Driver, SparkContext, cluster manager, executor, worker, task, job, and stage responsibilities
- Application-specific executor processes and lack of direct data sharing across applications
- Driver network reachability and proximity requirements
- Standalone, YARN, and Kubernetes cluster managers
- Client and cluster deploy-mode definitions
- Driver user interface and application scheduling model
- https://spark.apache.org/docs/latest/rdd-programming-guide.html
Supports
- RDD as a fault-tolerant partitioned collection operated on in parallel
- One task per partition and partition-level parallelism
- Lazy transformations and actions that require computation
- Jobs created by actions and stages separated by shuffle operations
- Shuffle redistribution, network cost, memory pressure, and disk spill
- Persistence, storage levels, materialization through actions, and recomputation of lost cached partitions
- Broadcast variables and accumulators
- Driver collection behavior and local versus cluster execution
- https://spark.apache.org/docs/latest/submitting-applications.html
Supports
- spark-submit as the uniform application launcher across supported cluster managers
- Master, deploy mode, configuration, application archive, and application argument roles
- Client mode placing the driver with the submitter and cluster mode launching it on a worker
- Local, standalone, YARN, and Kubernetes master settings
- Properties-file loading and dependency-distribution options
- https://spark.apache.org/docs/latest/web-ui.html
Supports
- Jobs, stages, storage, environment, executors, SQL, and Structured Streaming views
- Job directed acyclic graph and stage visibility
- Task duration, shuffle, spill, garbage collection, and skew evidence
- Cache visibility after a dataset is materialized
- Structured Streaming rates, batch duration, operation timing, and state metrics
- https://spark.apache.org/docs/latest/monitoring.html
Supports
- Live driver user interface and default port behavior
- Event logging and history server for completed applications
- Metrics, REST interfaces, and external instrumentation options
- Driver and executor monitoring scopes
- https://spark.apache.org/docs/latest/streaming/getting-started.html
Supports
- Input-table, result-table, trigger, and incremental-query mental model
- Append, update, and complete output-mode concepts
- Event time, late data, and watermark purpose
- Checkpointing, write-ahead logs, replayable sources, idempotent sinks, and end-to-end exactly-once conditions
- Minimal retained state rather than materializing an entire streaming table
- https://spark.apache.org/docs/latest/streaming/apis-on-dataframes-and-datasets.html
Supports
- Streaming DataFrame and Dataset sources, transformations, triggers, and sinks
- Output-mode compatibility with different query shapes
- Watermark guarantees and late-data limits
- Checkpoint locations and recovery of progress and running aggregates
- File-sink exactly-once, Kafka-sink at-least-once, foreach at-least-once, and implementation-dependent foreachBatch guarantees
- Console and memory sinks as non-fault-tolerant debugging sinks
- https://spark.apache.org/docs/latest/streaming/performance-tips.html
Supports
- Default micro-batch processing and asynchronous progress tracking limits
- Continuous processing as an experimental low-latency mode with at-least-once fault tolerance
- Limited supported operations, sources, and sinks in continuous mode
- Checkpoint compatibility and restart behavior between supported trigger modes
- https://spark.apache.org/docs/latest/tuning.html
Supports
- CPU, network bandwidth, and memory as possible Spark bottlenecks
- Serialization cost and memory effects
- Memory management, garbage collection, parallelism, reduce-task memory, broadcast data, and locality concerns
- Evidence-based tuning of serialization and persisted data
