When might Apache Spark be a better fit than Hadoop MapReduce?

Instruction: Compare execution, APIs, reuse and operational tradeoffs; explain why the answer depends on the workload.

Context: This question assesses the candidate's understanding of Apache Spark's core features and its advantages in big data processing scenarios compared to Hadoop MapReduce.

Updated

Spark can be attractive for multi-stage analytics because its execution engine can pipeline operations and reuse cached intermediate data across actions. Iterative algorithms may benefit from avoiding repeated reads and recomputation. Spark still uses disk for input/output, shuffle, spill and some persistence levels; it does not require all data to fit in memory.

Its DataFrame/SQL API exposes relational operations to an optimizer, while RDDs offer lower-level distributed operations. Structured Streaming and MLlib share parts of this ecosystem. API coverage differs: GraphX is a Scala graph API, not a native PySpark DataFrame feature, and third-party graph libraries need their own installation and compatibility checks.

Lineage can recompute lost partitions when source data and computation remain available. That is useful fault recovery, not a guarantee that driver loss, external side effects or unavailable source systems will recover automatically. Hadoop MapReduce also provides fault-tolerant distributed execution.

Both systems can process data beyond a single machine. Performance depends on the workload, storage, shuffle, available resources and operational requirements. Spark's richer APIs and reusable execution can help many SQL and iterative workloads, but a simple batch job may not justify a migration. Benchmark equivalent results and total operating cost; do not claim “hours to minutes” or superior scalability without measurements. Spark RDD execution and persistence, Spark SQL

Related Questions