Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 4 — The Hadoop Ecosystem

Lesson 43 of 46 in the free Introduction to Data Analytics notes on Siksha Sarovar, written by Rohit Jangra.

Apache Hadoop

Apache Hadoop is an open-source framework for the distributed storage and distributed processing of very large datasets across clusters of commodity hardware. Created by Doug Cutting and Mike Cafarella in 2006 (named after Cutting's son's toy elephant), it was inspired by two Google papers — the Google File System (2003) and MapReduce (2004).

Core Design Principles

  1. Scale out, not up — add cheap commodity machines rather than buying bigger servers
  2. Assume failure is normal — with thousands of machines, something is always broken; handle it in software
  3. Move computation to the data — sending a small program to where data lives beats moving terabytes across the network (data locality)
  4. Write once, read many — optimised for large sequential reads, not random updates
  5. Hide distribution complexity — the programmer writes logic, the framework handles parallelism, scheduling, and recovery

The Four Core Modules

1. HDFS — Hadoop Distributed File System

HDFS stores very large files by splitting them into blocks distributed across the cluster, with each block replicated for fault tolerance.

HDFS Architecture Components

ComponentRole
NameNode (master)Maintains the filesystem namespace and the block→DataNode map in memory. Does not store actual data. Single point of failure in Hadoop 1 (solved by HA NameNodes in Hadoop 2+).
DataNode (slave)Stores actual data blocks; serves read/write requests; sends heartbeats (default every 3 s) and block reports to the NameNode.
Secondary NameNodeNot a backup and not a failover node. It periodically merges the NameNode's edit log into the fsimage checkpoint, preventing the edit log from growing unbounded.
Standby NameNode (HA)The actual hot failover, introduced in Hadoop 2, coordinated via ZooKeeper and a shared journal.

Blocks and Replication

Default block size:  128 MB  (Hadoop 2+;  64 MB in Hadoop 1)
Default replication: 3

Example: a 500 MB file
   Block 1: 128 MB
   Block 2: 128 MB
   Block 3: 128 MB
   Block 4: 116 MB          <- the last block uses only what it needs

   Each of the 4 blocks is stored on 3 different DataNodes
   ->  12 block replicas distributed across the cluster
   ->  actual disk consumed = 500 MB x 3 = 1.5 GB

Why such large blocks? To minimise the seek-time-to-transfer-time ratio. With 128 MB blocks, disk seek overhead becomes negligible relative to the sequential read, and the NameNode's metadata stays small.

Rack Awareness — The Default Replica Placement Policy

   Replica 1: on the same node as the writer (or a random node if the client
              is outside the cluster)
   Replica 2: on a DIFFERENT RACK
   Replica 3: on a different node in the SAME rack as replica 2

Why this policy:
   • Surviving a whole-rack failure (replicas exist on ≥2 racks)
   • Minimising cross-rack network traffic (only 1 cross-rack write)
   • Balanced read load

HDFS Read and Write Flows

WRITE:
  1. Client asks the NameNode to create the file
  2. NameNode checks permissions and returns a list of DataNodes for block 1
  3. Client writes to DataNode A, which PIPELINES to B, which pipelines to C
  4. Acknowledgements flow back along the pipeline
  5. Repeat for each block; client tells the NameNode the file is complete

READ:
  1. Client asks the NameNode for the block locations of a file
  2. NameNode returns DataNode addresses, sorted by network proximity
  3. Client reads each block DIRECTLY from the nearest DataNode
     (data never flows through the NameNode — it would be a bottleneck)

HDFS Characteristics

StrengthLimitation
Handles very large files (GB to TB)Poor with many small files — each consumes NameNode memory
High throughput for sequential readsHigh latency — not for interactive/random access
Fault tolerant via replicationWrite-once, append-only — no arbitrary in-place updates
Runs on cheap commodity hardwareSingle NameNode is a bottleneck (mitigated by HDFS Federation)
Data locality reduces network loadNot a POSIX filesystem; not suitable for general-purpose storage

Common HDFS Commands

hdfs dfs -ls /user/data                       # list a directory
hdfs dfs -mkdir /user/data/sales              # create a directory
hdfs dfs -put local_file.csv /user/data/      # upload from local FS
hdfs dfs -get /user/data/output.csv ./        # download to local FS
hdfs dfs -cat /user/data/file.txt             # print file contents
hdfs dfs -tail /user/data/file.txt            # last KB of a file
hdfs dfs -rm -r /user/data/old                # delete recursively
hdfs dfs -du -h /user/data                    # disk usage, human readable
hdfs dfs -setrep -w 2 /user/data/file.csv     # change replication factor
hdfs dfsadmin -report                         # cluster health report
hdfs fsck / -files -blocks                    # filesystem check

2. YARN — Yet Another Resource Negotiator

Introduced in Hadoop 2, YARN separated resource management from the processing model, turning Hadoop from a MapReduce-only system into a general-purpose cluster operating system.

ComponentRole
ResourceManagerGlobal master; arbitrates cluster resources between all applications
NodeManagerPer-node agent; launches and monitors containers, reports resource usage
ApplicationMasterOne per application; negotiates containers from the RM and coordinates the application's tasks
ContainerA bundle of resources (CPU, memory) on one node in which a task runs

Schedulers: FIFO (simple, unfair), Capacity Scheduler (guaranteed queue capacities per organisation), and Fair Scheduler (all jobs get an equal share over time).

3. MapReduce

The original processing engine — covered in full in the next lesson.

The Hadoop Ecosystem

Ecosystem Component Reference

ComponentCategoryPurpose
HDFSStorageDistributed file system
YARNResource managementCluster resource scheduling
MapReduceProcessingBatch programming model
HiveQuerySQL-like queries (HiveQL) on HDFS data; compiles to MapReduce/Tez/Spark
PigScriptingDataflow language (Pig Latin) for ETL pipelines
HBaseNoSQLColumn-oriented store for random real-time read/write on HDFS
SqoopIngestionBulk transfer between HDFS and relational databases ("SQL to Hadoop")
FlumeIngestionStreaming log and event data collection
KafkaStreamingDistributed publish-subscribe message log
OozieWorkflowSchedules and chains Hadoop jobs into DAGs
ZooKeeperCoordinationDistributed configuration, naming, synchronisation, leader election
MahoutMLScalable machine learning library
SparkProcessingIn-memory engine — batch, streaming, SQL, ML, graph
AmbariManagementWeb UI for provisioning, monitoring and managing a cluster
Impala / PrestoQueryLow-latency interactive SQL (MPP, bypasses MapReduce)
Avro / Parquet / ORCFormatsSerialization and columnar storage formats

Hive vs Pig vs HBase

BasisHivePigHBase
LanguageHiveQL (SQL-like)Pig Latin (dataflow)Java API / shell
ParadigmDeclarativeProceduralKey-value operations
Best forAnalysts who know SQL; reportingComplex multi-step ETLRandom real-time read/write
SchemaSchema-on-read, structuredHandles semi/unstructured wellColumn families, sparse
LatencyHigh (batch)High (batch)Low (real-time)
Data volumeVery large, batchVery large, batchVery large, random access

Hadoop 1 vs Hadoop 2 vs Hadoop 3

FeatureHadoop 1Hadoop 2Hadoop 3
Resource managementJobTracker/TaskTrackerYARNYARN with improvements
Processing modelsMapReduce onlyAny (Spark, Tez, etc.)Any
NameNode HA✗ (single point of failure)✓ Active/Standby✓ Multiple standbys
Max nodes~4,000~10,00010,000+
Default block size64 MB128 MB128 MB
Storage efficiency3× replication3× replicationErasure coding — ~1.5× overhead instead of 3×
Java versionJava 6/7Java 7Java 8+

Advantages and Limitations of Hadoop

AdvantagesLimitations
Scalable — add nodes horizontally, near-linearHigh latency — batch only, not for interactive queries
Cost-effective — commodity hardware, open sourceSmall-file problem — NameNode memory pressure
Fault tolerant — automatic replication and task re-executionSteep learning curve; complex cluster administration
Flexible — schema-on-read handles any data typeNo in-place updates — write-once model
Data locality — computation moves to the dataMapReduce is verbose and disk-bound (Spark solves this)
Mature ecosystem with broad tool supportWeaker built-in security than enterprise RDBMS (Kerberos needed)
High throughput on massive sequential scansNot suited to real-time or transactional (OLTP) workloads

The next lesson explains the programming model at Hadoop's heart: MapReduce.