KatInterview

Spark Abstractions: RDDs, DataFrames, Spark SQL, and Cloud Execution

System DesignModel answer
MediumModel answerSystem Designsparkdistributed-systemsdata-engineering

Last updated

Explain the trade-offs between Spark's core APIs, how Spark improves on MapReduce, the role of lazy evaluation, and practical job submission on a managed cluster.

You are working on a data platform that processes large-scale batch jobs. The team uses the following table to track Spark application runs:

spark_jobs

+---------+---------------------+-------+-----------+---------+
| job_id | submit_time         | user  | memory_gb | status  |
+---------+---------------------+-------+-----------+---------+
| 101     | 2023-10-20 10:35:00 | alice | 8         | success |
| 102     | 2023-10-20 11:10:00 | bob   | 16        | running |
| 103     | 2023-10-20 12:40:00 | carol | 32        | failed  |
+---------+---------------------+-------+-----------+---------+

Answer the following conceptual questions, using the table above as a concrete reference where helpful:

  1. Compare Spark RDDs, DataFrames, and Spark SQL. What are the strengths and trade-offs of each abstraction?

  2. What key advantages does Spark hold over the classic Hadoop MapReduce model?

  3. Explain Spark's lazy evaluation model and describe how the execution engine optimizes a query plan before any work runs.

  4. Walk through how you would package, submit, and monitor a Spark job on a managed cloud cluster such as AWS EMR. Include cost and monitoring considerations.

Hints

Hint 1

Contrast which APIs benefit from Catalyst and Tungsten versus which run opaque user code with no optimizer visibility

Hint 2

Mention in-memory computation, DAG-based stage scheduling, and lineage-based recovery as key differentiators from MapReduce

Hint 3

Cover packaging, deploy modes, autoscaling, spot instances, and tools like the Spark UI and CloudWatch for monitoring