Portfolio / Projects / big-data-hadoop-spark

Big Data · Data Platform · Academic project

Build a Hadoop & Spark lab and follow the actual path of each workload.

The project combines HDFS, YARN, Java MapReduce and a standalone Spark cluster in Docker Compose. The same WordCount is run in Java and PySpark, followed by a second aggregation job that computes an average word length.

8ContainersHadoop + Spark
2DataNodesregistered in HDFS
2WordCountJava + PySpark
5.333Average lengthtest-job output

Tools & technologies

Docker ComposeHadoop HDFSYARN / Java MapReduceSpark standalonePySpark

Containerized lab running on a single machine.

01 / Objective & overall result

Trace how data moves when a distributed processing job is launched.

The lab combines Hadoop and Spark with Docker to follow a file end to end: HDFS storage, YARN orchestration, MapReduce execution, then the equivalent transformation with PySpark.

HDFS2 active DataNodes

The NameNode sees both storage nodes and no under-replicated blocks during validation.

Hadoop2 successful jobs

WordCount and Average Word Length both appear as FINISHED / SUCCEEDED in YARN.

SparkSame WordCount

PySpark returns exactly the same counts as Java: hadoop 1, hello 2, world 1.

What the lab proves: not a performance benchmark, but an understanding and validation of two different distributed execution paths in a reproducible environment.

02 / Architecture

Two subsystems in the same Docker environment.

Docker Compose8 service containers
Hadoop

Store and execute through HDFS / YARN

NameNodeDataNode 1DataNode 2ResourceManagerNodeManagerHistoryServer

Files are stored in HDFS. Java MapReduce jobs are tracked by YARN.

Spark standalone

Submit a job to the master, then the worker

Spark MasterSpark WorkerShared volume

The PySpark WordCount is submitted to the Spark master and reads the file from the shared volume.

Running Hadoop and Spark containers in Docker Desktop
The environment runs Hadoop and Spark services in the same Docker Compose project.
docker compose ps output showing the running Hadoop and Spark services
The required services are started before running the workloads.

With the services running, the first check is whether HDFS sees both data nodes.

03 / HDFS storage

The NameNode sees two DataNodes in service.

HDFS separates metadata from physical storage. The NameNode tracks where blocks live, while DataNodes store the data. The lab adds a second DataNode so this separation is visible rather than using a single storage container.

NameNode interface showing two HDFS nodes in service
The NameNode view reports two nodes in service in HDFS.
Why this check matters: if the DataNodes are not registered with the NameNode, putting a file into HDFS does not prove that the distributed storage layer is working.

Once storage is available, the first workload can follow the classic Hadoop path: HDFS, MapReduce, then HDFS output.

04 / Java MapReduce

A simple WordCount to follow every stage of the Hadoop engine.

The control file contains hello hadoop hello world. The mapper turns each word into a (word, 1) pair. Hadoop then groups identical keys during the shuffle, and the reducer sums the values for each word.

Hadoop path

HDFS inputJava mappershuffle / sortJava reducerHDFS output
Hadoop WordCount output: hadoop 1, hello 2, world 1
Java WordCount output: hello appears twice, while hadoop and world appear once.

That result becomes a reference point: the same computation is rewritten in PySpark to verify that the logic stays the same with another execution API.

05 / PySpark

Same transformation, different execution engine.

The PySpark job reads the same file from the shared volume. flatMap splits lines into words, map pairs each word with 1 and reduceByKey sums values by key. The Spark Master delegates execution to the registered worker.

Spark Master interface showing one active worker
The Spark Master sees one active worker in the standalone cluster.
PySpark WordCount output: world 1, hello 2, hadoop 1
The PySpark WordCount returns exactly the same counts.
Hadoop WordCount output used as a reference
The Hadoop output is the reference used to verify the Spark result.
What this comparison demonstrates

The business logic is identical, but the technical path changes. The Hadoop job uses HDFS and YARN with Java MapReduce. The Spark job is submitted to the standalone master and uses its worker. This is not a speed benchmark between the two engines.

After this functional check, a second MapReduce job tests a numeric aggregation and exposes a more concrete type-contract issue.

06 / Real debugging

The second job had a type contract mismatch between the declared output and the value actually produced.

01

Expected result

An average word length must be decimal.

02

Problem

The reducer writes a DoubleWritable, while the driver still declared an IntWritable.

03

Fix

Align the job output contract with the actual reducer type, then rebuild the JAR.

04

Validation

The job succeeds in YARN and returns Average Word Length = 5.333333333333333.

Average Word Length job result
The fix is only considered valid once the output is produced and the job is marked successful.

07 / What the evidence confirms

HDFS, MapReduce and Spark validated in a containerized lab.

EvidenceObservationMeaningScope
HDFS2 active DataNodesdistributed storage recognizedarchitecture
YARN2 SUCCEEDED jobsMapReduce orchestration operationalHadoop
WordCount1 / 2 / 1Java and PySpark agreecross-check
Average length5.333333...output type fixed and result produceddebug

The important point is consistency across the evidence: the UIs show cluster state, terminal outputs show results, and the two WordCount implementations return the same content. The lab therefore validates a complete path from HDFS storage to YARN orchestration and MapReduce/Spark execution, without claiming that one engine is faster.

08 / Limits

A containerized learning lab on a single machine.

  • All containers run on one physical machine: if the host stops, the whole lab stops.
  • Only one NodeManager and one Spark Worker are used; the project demonstrates orchestration and processing paths, not scale-out performance.
  • No controlled benchmark supports a claim that Spark is faster than MapReduce in this project.
  • The lab uses Hadoop 3.2.1 and Spark 2.4.0 images, without high availability, Kerberos or production monitoring.
Scope: the important evidence is understanding and running the components with verifiable outputs, not claiming an enterprise cluster.

Next project

Network Threat Detection: detect attacks from network-flow statistics.