Actions

Actions

Actions trigger the computation operations on RDDs.used to materialize computation results

Calling actions trigger computation operations. Action = Computation

Actions, on the other hand, compute a result based on an RDD, and either return it to the driver program or save it to an external storage system. Actions will typically include transferring the data across the nodes

Spark’s RDDs are by default recomputed each time you run an action on them. If you would like to reuse an RDD in multiple actions, you can ask Spark to persist it using RDD.persist().

The ability to always recompute an RDD is actually why RDDs are called “resilient.” When a machine holding RDD data fails, Spark uses this ability to recompute the missing partitions, transparent to the user.

To avoid computing an RDD multiple times, we can ask Spark to persist the data. When we ask Spark to persist an RDD, the nodes that compute the RDD store their partitions. If a node that has data persisted on it fails, Spark will recompute the lost partitions of the data when needed. We can also replicate our data on multiple nodes if we want to be able to handle node failure without slowdown.

After computing it the first time \( as part of action trigger \) Spark will store the RDD contents in memory \(partitioned across the machines in your cluster\), and reuse them in future actions.

Last updated