A minimal MapReduce implementation (master + workers) used for learning and demos. The repo contains a read-only web dashboard for monitoring, gRPC-based master/worker communication, and example scripts for demos and benchmarks.
For a deeper narrative and design notes, see Published Article.
Prerequisites
- Docker & Docker Compose
Start the demo (master + 3 workers + dashboard)
docker-compose -f docker-compose.benchmark.yml up --buildOpen the dashboard at: http://localhost:5000
Stop the demo
docker-compose -f docker-compose.benchmark.yml downRun automated benchmarks (no dashboard):
python3 examples/benchmark.pyThis runs three tests: 1-worker baseline, 3-worker parallel run, and a failure-recovery test. Results are printed and saved to benchmark_results.txt.
protos/— gRPC.protodefinitionssrc/master/— master server, scheduler, and state managementsrc/worker/— worker client and task executorweb/— Flask-based read-only dashboard and templatesexamples/— demo and benchmark scriptsdocker-compose*.yml— compose files for demo, benchmark, and DAG runsdocs/WRITEUP.md— detailed writeup and design notes
- Master splits the input into map tasks.
- Workers register and request tasks from the master via gRPC.
- Mappers write partitioned intermediate files (one file per reducer partition).
- Reducers fetch intermediate files for their partition (the shuffle) and produce final output.
- The master exposes
/statuswhich the dashboard polls for live updates.
Key points
- The web dashboard is read-only and monitors the master's
/statusendpoint. - There is no master failover implemented (master is a single point of failure).
- Tasks use sequence numbers and completion tracking to tolerate duplicate reports from slow or restarted workers.
Install dependencies and generate protobufs
pip install -r requirements.txt
./scripts/generate_proto.shStart master
python -m src.master.server --input data/input/sample.txtStart a worker (in another terminal)
python -m src.worker.client worker1- Demo:
docker-compose -f docker-compose.benchmark.yml up --build - Stop demo:
docker-compose -f docker-compose.benchmark.yml down - Run benchmarks:
python3 examples/benchmark.py - Regenerate protobufs:
./scripts/generate_proto.sh
Follow these steps to run the master and workers manually in separate terminals — useful for demoing and stopping individual workers by closing their terminal.
- Install dependencies
pip install -r requirements.txt- Generate Protobuf code
chmod +x scripts/generate_proto.sh
./scripts/generate_proto.sh- Start Master (new terminal)
python -m src.master.server- Start Workers (each in its own terminal; you can stop any worker by closing that terminal)
python -m src.worker.client worker1
python -m src.worker.client worker2
python -m src.worker.client worker3- Simulate Worker Failure (unstable worker)
Start a worker that purposely fails after completing N tasks (example below starts one that fails after 2 tasks):
python -m src.worker.client worker_unstable --fail-after 2
# This worker will exit/fail after finishing 2 tasks; watch master logs for reassignmentNotes
- Stopping a worker terminal (or killing the process) will simulate a crash and the master will detect failure via heartbeats and reassign tasks.
- The
examples/benchmark.pyscript automates bringing up/down workers for repeatable tests; use the manual steps above for ad-hoc experimentation.
- Master failover is not implemented — the master is a single point of failure.
- The dashboard is monitoring-only and does not expose control endpoints.
- This project is intended for learning and small-scale demos, not production use.
# Check if master is running
docker-compose ps master
# Restart the cluster
./scripts/run_cluster.sh restart# Check master logs for task creation
docker-compose logs master | grep "Created"
# Verify workers are registered
docker-compose logs master | grep "registered"# Regenerate protobuf code
./scripts/generate_proto.shprotos/mapreduce.proto: gRPC service definitionssrc/master/server.py: Master coordination logicsrc/master/monitor.py: Fault detection mechanismsrc/worker/client.py: Worker implementationweb/app.py: Flask web dashboard backendweb/templates/index.html: Dashboard UIdocker-compose.yml: Basic multi-container orchestrationdocker-compose.benchmark.yml: Full demo with web dashboard
- Workers registered/failed
- Tasks pending/running/completed/failed
- Tasks per worker
- Heartbeat status
- Task reassignment on failure