The Basics of Spark
What Does Spark Do?
Apache Spark is an open-source engine for processing data. We describe a calculation, and Spark organizes the tasks that produce its result. Those tasks can run across several computers, although Spark also runs on one machine for smaller workloads.
Our maintenance team has a named table of pump readings. Before calculating an average or preparing a model input, we want to know how many records arrived. On one computer, we could count every row in a list. If the records are divided into portions, each portion can contribute a count and those counts can be combined.
We will follow that calculation before using Spark’s programming interface. It gives a concrete meaning to partitions, tasks and the processes that run them. Databricks manages the computing environment in this sequence; Spark supplies the processing engine.
These are local lists representing partition contents. No actual Spark tasks or cloud computers run here, and the workshop does not measure parallel speed or recovery behavior.
Step 1 of 1
Follow a Count Through Spark
Start with the records and the work, then attach each process name to its responsibility.
| Question | Component | Its job in this example |
|---|---|---|
| What data is available? | Partitions | Each portion contains some of the pump readings |
| What does one portion contribute? | A counting task | Produces a partial count for that partition |
| What executes the task? | An executor process | Works on its assigned partition and returns a result |
| What coordinates the application? | The driver | Schedules the work needed to produce the requested result |
| What answer did we request? | The combined count | Adds the partial counts without dropping any records |
What data is available?
- Component
- Partitions
- Its job in this example
- Each portion contains some of the pump readings
What does one portion contribute?
- Component
- A counting task
- Its job in this example
- Produces a partial count for that partition
What executes the task?
- Component
- An executor process
- Its job in this example
- Works on its assigned partition and returns a result
What coordinates the application?
- Component
- The driver
- Its job in this example
- Schedules the work needed to produce the requested result
What answer did we request?
- Component
- The combined count
- Its job in this example
- Adds the partial counts without dropping any records
Describe the Calculation Over a Table
Each partition contributes its own count. Adding those partial counts preserves the total even when the partition boundaries move.