How much did each generation of the Hadoop-era tools actually change? We wrote the same seven analyses three times and ran them on the same files:
- Generation 1: hand-written Java MapReduce jobs
- Generation 2: HiveQL on Hive 4.2.1 with its MapReduce engine
- Generation 3: Spark SQL 4.3.0 on YARN
plus Spark in local mode as an ablation.
The setup
- Data: NASA web-server logs of 1995 and generated TPC-H tables, at two sizes: sf1 (1.34 GB) and sf3 (4.06 GB).
- Jobs: word count, requests per day and top 10 URLs over the logs; TPC-H Q1, Q6, Q3 and Q12.
- Same everything: the same files in HDFS (Hadoop 3.5.0, single machine, pseudo-distributed), the same YARN task slots, one fresh client command per run, timed from start to exit.
- Answer check: every run's output was read back from HDFS and compared with DuckDB (TPC-H) or a plain Python pass (logs).
This is a standard laptop, not a multi-machine cluster. The comparison is about the tools, not about cluster scaling.
Results
At sf3 (4.06 GB), as geometric means over the seven jobs:
| Comparison | Result |
|---|---|
| Spark SQL vs hand-written MapReduce | Spark SQL 1.5x faster (per job 0.9x-2.8x) |
| Spark SQL vs Hive on MapReduce | Spark SQL 1.9x faster (per job 1.3x-3.0x) |
| Hand-written MapReduce vs Hive | MapReduce 1.3x faster |
| Lines of code | 768 lines of Java vs 70 lines of HiveQL and 63 of Spark SQL (12.2x less for SQL) |
| Correct answers | 119 of 119 runs equal to the reference |
At sf1 (1.34 GB) the picture was similar but closer: Spark SQL was 1.3x faster than MapReduce (clearly faster on 4 jobs, clearly slower on 2) and 1.8x faster than Hive.
Where Spark's time actually went
The surprise was not that Spark SQL won. It was how much of each Spark run was not the query at all.
- Spark SQL on YARN spent 13.5 s-15.2 s of every run starting the YARN application master and four executors.
- At sf1 that start-up was on average 58% of a Spark-on-YARN run.
- Running the same queries in Spark local mode (one JVM, no YARN) was 1.6x faster than Spark on YARN. Most of the difference is the YARN application start-up, not the query.
MapReduce and Hive pay their start-up too, just hidden inside the job: every MapReduce job is its own YARN application, so even the smallest work took at least 19.2 s per MapReduce job. That is why hand-written MapReduce suffers on queries that need several chained jobs: TPC-H Q3 alone needs 203 lines of Java and three chained MapReduce jobs, against 9 lines of SQL.
Growth with data size
From sf1 to sf3 the data grew 3.0x, but the wall time grew only 1.3x-1.4x for every engine. At these sizes fixed start-up costs dominate, and they do not grow with the data. A bigger cluster or bigger data would shift the balance; we did not test that here.
What we would tell a student choosing a stack
- Write SQL first. The same query text ran unchanged in Hive and Spark SQL; only the output clause differed. It was 12.2x less code than MapReduce, with identical answers.
- Measure start-up separately. On small and medium data, start-up can be most of the run. Report it next to the query time.
- Check every answer against an independent reference. All 119 runs matched DuckDB or Python, to the cent for sums.
- Know what you did not test: a multi-machine cluster, Hive on Tez, and columnar formats (ORC, Parquet) were out of scope.
Full project (Java MapReduce jobs, HiveQL and Spark SQL scripts, study harness, web app, report, video): From Hadoop MapReduce and Hive to Spark SQL - ProTechSC Academy.
We guide final-year and PhD research projects in engineering, AI and big data. WhatsApp +91 97907 09424.
Top comments (0)