Spark Flashcards

1
Q

What are Spark RDDs? Why was Spark so revolutionary?

A

RDD stands for Resilient Distributed Datasets. They made datasets look like collections.
RDDs reside on disk, but can be cached in memory, are transparently distributed and feature all FP programming primitives.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the difference between RDDs and Pair RDDs? Why do we need both?

A

RDDs are tuples, and are handled as iterable, whereas Pair RDDs are seens as KV pairs, and can be handled as both iterable and indexable.
Pair RDDs allow for more functionality (e.g. join).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the key Spark API calls?

A

There are two types of operations for Spark: Transformations and Actions.
Common transformations are: Map, flatMap, and filter. Pair RDDs also allow for reduceByKey, aggregateByKey and join.
Common actions are: collect, take, reduce, fold and aggregate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are wide and narrow dependencies?

A

Wide dependencies means that multiple partitions in the target RDD depend on a single partition in the source RDD (ie, one partition of the source can lead to multiple partitions in the target)
Narrow dependencies means that each partition of the source RDD is used by at most one partition of the target RDD (think of it as in injective function from the target to the source)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does Spark deal with faults?

A

Spark uses RDD lineage info to know which partition(s) to recompute in case of node failure.
Spark also uses checkpointing to save states reliably. This effectively truncates the RDD lineage graph.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What types of partitioning can we employ for distributed systems like Spark?

A

There are three types of partitioning:
Default partitioning: Split into equally large partitioning, without looking at the data properties
Range partitioning: Look at the natural order of keys to split the dataset into the required number of partitions. This requires naturally ordered keys that are equally distributed across the value range.
Hash partitioning: Calculate the hash of each item key and produce the modulo of this hash to determine the new partition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does Catalyst optimize queries?

A

By using range conditions to restrict data volumes. This also allows for parallel querying.
Doing relational algebra optimizations
Recursive tree substitutions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does Spark schedule jobs on a cluster?

A

A job is initiated when an action is called on an RDD. The dependency graph is evaluated backwards and a graph of stages is built. Each stage consists of multiple tasks, which are scheduled in parallel on cluster nodes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which RDD API call is a ‘performance killer’ in Spark?

A

GroupByKey, because it shuffles (rearranges) ALL the data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What methods shuffle the the data?

A

groupByKey, reduceByKey, combineByKey and Join.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly