Hadoop architecture: HDFS, YARN, MapReduce and Common

Hadoop is not one program. It is a team of long-running Java processes, called daemons, spread across master and worker machines, held together by four XML configuration files. This lesson opens up a real cluster layer by layer: which daemon runs where, what it does, how it talks to the others and on which port, so that the output of jps and the web UIs make sense at a glance.

Module 3 · How one Hadoop cluster works⏱ 26 minBeginner → AdvancedDaemon and port tableCluster PlaygroundRuns in your browser (Python)8 practice problems
1 The story

“What is actually running on these machines?”

Kabir's team lead gives him login access to the company's Hadoop cluster and one task: “Find out what is running on each machine, and on which port.” Kabir logs in to the first server, types jps, and sees a short list of strange names: NameNode, ResourceManager, JournalNode. On the next server: DataNode, NodeManager. He calls Riya: “It's like a zoo of Java programs.”

Applications: MapReduce · Spark · Hive (Tez) · your jobs YARN: ResourceManager + NodeManagers (who gets CPU and memory) HDFS: NameNode + DataNodes (where the bytes live) Hadoop Common: configuration, RPC, security, file-system API, tools Java (JVM) · Linux · many servers in racks myphatshala.in
Riya

A zoo? I thought Hadoop was one program.

Arjun Sir

That's the most common mistake, Riya. Hadoop is a set of long-running Java programs, called daemons, spread over the cluster. Each one has one job. Some run on one or two master machines; others run on every worker.

Kabir

So the NameNode on server 1 is the HDFS master, and the DataNodes on the other servers are the HDFS workers?

Arjun Sir

Yes. Same for YARN: one ResourceManager, a NodeManager on every worker. And there are helpers: JournalNodes, the JobHistory server, ZooKeeper.

Riya

And how do they know about each other?

Arjun Sir

Through a handful of XML configuration files that every node shares. Today we'll open up a real cluster layer by layer: which daemon runs where, what it does, which port it listens on, and which configuration file controls it. After this lesson, jps output will read like a sentence to you.

2 Definition

Hadoop's architecture, daemon by daemon

Formal definition (write this in exams)

A Hadoop cluster is a layered, master–worker system of long-running Java processes (daemons). The storage layer (HDFS) consists of a NameNode, which manages the namespace and block map, and DataNodes, which store blocks; with High Availability it adds a standby NameNode, JournalNodes and ZKFailoverControllers. The resource layer (YARN) consists of a ResourceManager, which allocates containers cluster-wide, and NodeManagers, which launch and monitor containers on each worker. The processing layer consists of applications such as MapReduce, each run by its own ApplicationMaster; the JobHistory Server keeps records of finished MapReduce jobs. Hadoop Common provides the shared libraries, RPC, configuration and security on which all daemons are built. Daemons communicate through RPC and periodic heartbeats and are configured through core-site.xml, hdfs-site.xml, yarn-site.xml and mapred-site.xml.

In simple words

Hadoop is not one program but a team of programs. On the master machines run the “managers”: the NameNode (knows where every file block is) and the ResourceManager (decides who gets CPU and memory). On every worker run two “staff members”: a DataNode (stores blocks) and a NodeManager (runs tasks). They talk to each other all the time, and four XML files tell each of them where the others are.

Words you'll meet in this lesson

DaemonA program that runs in the background all the time, like a service. Every Hadoop component is a Java daemon.
jpsA JDK command that lists running Java processes. The quickest way to see which Hadoop daemons are up on a machine.
RPCRemote procedure call: one daemon calling a function on another over the network.
fs.defaultFSThe setting in core-site.xml that tells every client and daemon where the NameNode is, e.g. hdfs://nn1:8020.
JobHistory ServerDaemon that keeps the logs and counters of finished MapReduce jobs (web UI on port 19888).
JournalNodeHA helper that stores the NameNode's edit log so the standby can follow it.
ZKFCZooKeeper Failover Controller: watches a NameNode's health and triggers automatic failover.
Aux serviceA plug-in that runs inside each NodeManager. MapReduce's shuffle handler is one; it serves map outputs to reducers.

Every daemon, where it runs, and its default ports (Hadoop 3)

DaemonLayerRuns onMain jobPorts
NameNodeHDFSMaster (1 active)Namespace + block locations8020 RPC · 9870 web UI
DataNodeHDFSEvery workerStore and serve blocks9866 data · 9867 IPC · 9864 web
Secondary NameNodeHDFSA master (non-HA only)Checkpoints fsimage9868 web
JournalNodeHDFS (HA)3 or 5 mastersShared edit log8485 RPC · 8480 web
ZKFCHDFS (HA)Next to each NameNodeAutomatic failover8019
ResourceManagerYARNMasterAllocate containers8032 clients · 8030 AMs · 8031 NMs · 8088 web
NodeManagerYARNEvery workerLaunch and watch containers8042 web · 13562 shuffle
JobHistory ServerMapReduceA master or utility nodeHistory of finished jobs10020 IPC · 19888 web
ZooKeeperCoordination (separate project)3 or 5 nodesLeader election for HA2181

These are Apache Hadoop 3 defaults. Distributions and companies often change them; always check the cluster's configuration files.

The architecture at three levels

Pick your level. New to this? Start at Beginner and climb.

Beginner A hospital

  • The records office (NameNode) knows which file is in which cupboard, but holds no files itself.
  • The cupboards in every ward (DataNodes) hold the actual files, with copies in other wards.
  • The bed manager (ResourceManager) decides which patient gets which bed and how many nurses.
  • Each ward's in-charge (NodeManager) sets up the beds the bed manager approved and reports back.
  • Each patient's doctor (ApplicationMaster) plans that one patient's treatment and asks for beds as needed.
  • The hospital rule book (Common + config files) is the same in every ward.

Intermediate How the daemons talk to each other

  • DataNode → NameNode: registration, heartbeats every 3 s, block reports. The NameNode answers with commands (copy, delete).
  • NodeManager → ResourceManager: heartbeats with free memory/CPU and container status. The RM answers with containers to start or kill.
  • Client → NameNode: “create this file”, “where are the blocks of that file?”. Client → DataNodes: the actual bytes. The NameNode never carries file data.
  • Client → ResourceManager: submit an application. ApplicationMaster → RM: ask for containers. AM → NodeManagers: start containers.
  • Reducers → NodeManagers' shuffle service: fetch map outputs over HTTP.

Advanced Design details that matter in production

  • Masters are out of the data path: clients read and write blocks directly from DataNodes, so the NameNode handles only small metadata calls. That's how one NameNode serves thousands of nodes.
  • Control vs data traffic: RPC (small, frequent) and data transfer (large, streaming) use different ports and can be tuned separately.
  • Co-location: DataNode and NodeManager on the same worker make data locality possible. Separating them (compute-only nodes) is possible but loses locality.
  • Same configuration everywhere: the XML files are usually managed centrally (Ambari, Cloudera Manager, Ansible) and pushed to every node; a mismatch is a classic source of strange errors.
  • Each daemon has its own log under $HADOOP_HOME/logs (for example hadoop-<user>-namenode-<host>.log), which is the first place to look when something fails.

Exam tip: For “Explain the architecture of Hadoop with a neat diagram”, draw two master–worker pairs: NameNode ↔ DataNodes (HDFS) and ResourceManager ↔ NodeManagers (YARN), show a client talking to the NameNode for metadata but to DataNodes for data, add one ApplicationMaster inside a NodeManager, and label heartbeats. Mention Hadoop Common underneath.

3 Types and ways to use it

The four modules, their daemons and their configuration files

Hadoop Common

No daemon of its own. Libraries used by all others: the FileSystem API, RPC, security (Kerberos), metrics, the hadoop command.

core-site.xml

HDFS

NameNode, DataNodes, plus Secondary NameNode (non-HA) or JournalNodes + ZKFCs (HA). Commands: hdfs dfs, hdfs dfsadmin.

hdfs-site.xml

YARN

ResourceManager, NodeManagers (and optionally a Timeline Server). Commands: yarn application, yarn node.

yarn-site.xml

MapReduce

No permanent daemon per job: each job's MRAppMaster runs in a container. The JobHistory Server keeps finished-job records. Command: mapred.

mapred-site.xml

The most important settings in each file

FileKey propertyExample valueMeaning
core-site.xmlfs.defaultFShdfs://nn1:8020Where the default file system (NameNode) is
hdfs-site.xmldfs.replication3Copies of each block
hdfs-site.xmldfs.namenode.name.dir/data/nnWhere the NameNode saves its metadata
hdfs-site.xmldfs.datanode.data.dir/data/1/dn,/data/2/dnDisks where a DataNode stores blocks
yarn-site.xmlyarn.resourcemanager.hostnamerm1Where the ResourceManager is
yarn-site.xmlyarn.nodemanager.aux-servicesmapreduce_shuffleTurns on the shuffle service for MapReduce
yarn-site.xmlyarn.nodemanager.resource.memory-mb196608Memory a node offers to containers
mapred-site.xmlmapreduce.framework.nameyarnRun MapReduce jobs on YARN
workers(plain list)one host per lineWhere start scripts launch DataNodes and NodeManagers (called slaves in Hadoop 2)

When a client says “Connection refused” to localhost:8020 or similar, check fs.defaultFS first. Half of all beginner Hadoop errors are a wrong host name or port in core-site.xml, or a daemon that is simply not running (check with jps).

4 Step by step

Bringing a cluster up, daemon by daemon

  1. Every node gets the same configuration

    import xml.etree.ElementTree as ET
    xml = """<configuration><property><name>fs.defaultFS</name>
    <value>hdfs://nn1:8020</value></property></configuration>"""
    for p in ET.fromstring(xml).iter("property"):
        print(p.findtext("name"), "=", p.findtext("value"))
    fs.defaultFS = hdfs://nn1:8020
    Every Hadoop configuration file is a list of <property> name–value pairs. Every daemon and client reads them at start-up, so they all agree on where the masters are.
  2. Start HDFS: the NameNode first

    The admin runs start-dfs.sh. The NameNode loads its saved metadata (fsimage + edit log) and waits in safe mode.

    The NameNode knows the files and their blocks, but not yet where the blocks are. That information is never saved; it comes fresh from the DataNodes.
  3. DataNodes start and report

    On each worker a DataNode starts, registers with the NameNode and sends a block report.

    When enough blocks have been reported (99.9% by default), the NameNode leaves safe mode and allows writes. Module 5 explains safe mode in detail.
  4. Start YARN

    The admin runs start-yarn.sh. The ResourceManager starts; each NodeManager registers with how much memory and how many vcores it offers.

    The RM now knows total cluster capacity, for example 40 nodes × 192 GB. Its web UI on port 8088 shows it.
  5. Start the JobHistory Server, then check

    mapred --daemon start historyserver
    jps
    On a single-machine (pseudo-distributed) test cluster, jps should list NameNode, DataNode, SecondaryNameNode, ResourceManager, NodeManager and JobHistoryServer. If one is missing, its log file says why. You'll do this yourself in Module 4.
5 See it happen

A cluster starting up: what the admin sees, and which daemons appear

Follow a small cluster (one master, three workers) from power-on to ready. Left: the admin's terminal. Right: the daemons on each machine.

From power-on to ready 6 steps
What you see admin@master1 : ~ (illustrative output) $ jps4410 JpsNothing running yet. $ start-dfs.shStarting namenodes on [master1]Starting datanodesStarting secondary namenodes [master1] $ hdfs dfsadmin -safemode getSafe mode is ON(a few seconds later)Safe mode is OFF $ start-yarn.shStarting resourcemanagerStarting nodemanagers $ mapred --daemon start historyserver$ jps5121 NameNode5410 SecondaryNameNode5702 ResourceManager6015 JobHistoryServer6102 Jps open http://master1:9870 (HDFS)open http://master1:8088 (YARN)Live DataNodes: 3Active NodeManagers: 3The cluster is ready for jobs. myphatshala.in
Behind the screen master1 NameNode SecondaryNameNode ResourceManager JobHistoryServer worker1worker2worker3 DataNodeDataNodeDataNode NodeManagerNodeManagerNodeManager block reports → NameNode NodeManagers register their memory + vcores 4 machines, no daemons HDFS daemons start master: 4 daemons · each worker: 2 storage layer + resource layer up myphatshala.in

Try it yourself: find each daemon in the playground

The playground shows the same architecture: masters at the top, DataNodes (with their NodeManager containers) below.

6 Real-world use

Architecture knowledge in daily work

$ jpsDataNodeNodeManager?

1. First check in any incident

When jobs fail on one node, an engineer logs in and runs jps. If the NodeManager is missing, the node offers no containers; if the DataNode is missing, its blocks are unavailable. The daemon's log file then explains why.

Alert→jps + daemon log→Restart or fix
:9870:8088

2. Firewall and security reviews

Security teams ask exactly which ports each node needs open. The daemon-and-port table in this lesson is what platform engineers hand them, with web UIs restricted to admin networks.

Port list→Firewall rules→Only needed ports open
Ambari /Cloudera Manager

3. Cluster managers show the same picture

Management tools like Apache Ambari or Cloudera Manager display every host with its roles (NameNode, DataNode, NodeManager…), their health and their configuration, the same architecture you learned today with a dashboard on top.

Hosts→Roles per host→Health + config
<property>fs.defaultFS

4. Connecting tools to the cluster

Spark, Hive, Airflow and BI tools need the cluster's core-site.xml and hdfs-site.xml (and yarn-site.xml to submit jobs). Copying these files to an edge node is how new tools are connected.

Config files→Client tool→Reads HDFS, submits to YARN

5. Capacity and health dashboards

Monitoring systems scrape metrics from each daemon (NameNode heap, DataNode disk, NodeManager memory) and graph them per layer, so teams see whether storage or compute is running out.

Daemon metrics→Monitoring→Alerts per layer

Examples are simplified. Port numbers are Apache defaults; distributions may differ.

7 Run the code

Read a Hadoop configuration file

Every Hadoop setting lives in XML files like this hdfs-site.xml. This program reads it the way Hadoop does and turns it into a dictionary. Then try the challenges: find the NameNode, plan which daemons go on which host, and catch a configuration mistake.

import xml.etree.ElementTree as ET

hdfs_site = """<configuration>
  <property><name>dfs.replication</name><value>3</value></property>
  <property><name>dfs.namenode.name.dir</name><value>/data/nn</value></property>
  <property><name>dfs.datanode.data.dir</name><value>/data/1/dn,/data/2/dn</value></property>
  <property><name>dfs.blocksize</name><value>134217728</value></property>
</configuration>"""

conf = {p.findtext("name"): p.findtext("value")
        for p in ET.fromstring(hdfs_site).iter("property")}

print("Replication :", conf["dfs.replication"])
print("Block size  :", int(conf["dfs.blocksize"]) // 1024 // 1024, "MB")
print("DataNode disks:", conf["dfs.datanode.data.dir"].split(","))
Replication : 3 Block size : 128 MB DataNode disks: ['/data/1/dn', '/data/2/dn']
  • ET.fromstring(hdfs_site).iter("property")Parse the XML and visit every <property> element, as Hadoop's Configuration class does.
  • conf = {p.findtext("name"): p.findtext("value") ...}A dictionary comprehension: property name → value. All values are strings.
  • int(conf["dfs.blocksize"]) // 1024 // 1024134217728 bytes = 128 MB, the Hadoop 2/3 default.
8 Line by line

Merging configuration files, one line at a time

Hadoop loads default settings first and then the site files, so later files override earlier ones. Watch the conf dictionary change as each layer is applied.

Worked examples: real problems, solved and traced in memory

Three tasks a new platform engineer is given in the first week: audit which daemons run where, check a cluster's port plan, and size the master's memory. Each runs live and is traced in memory.

Example 1BeginnerOperations · health check

Which nodes are missing a daemon?

Problem statement

A script collects jps output from every node. Masters must run NameNode and ResourceManager; workers must run DataNode and NodeManager. Print each node's missing daemons.

Input
master1: NameNode, ResourceManager · w1: DataNode, NodeManager · w2: DataNode · w3: NodeManager
Expected output
w2 missing ['NodeManager']
w3 missing ['DataNode']

Approach

  1. Store the expected daemons per role as sets.
  2. For each node, subtract what is running from what is expected.
  3. Print the node only if something is missing.

Solution: run it live

What happens in memory, step by step

Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.

Example 2IntermediateSecurity · firewall plan

Which ports must be open on each kind of node?

Problem statement

Using the Hadoop 3 default ports, print the ports each kind of node must open: an HDFS+YARN master and a worker. Mark web UIs separately so security can restrict them to the admin network.

Input
master daemons: NameNode, ResourceManager · worker daemons: DataNode, NodeManager
Expected output
master: service [8020, 8030, 8031, 8032] | web UI [8088, 9870]
worker: service [9866, 9867, 13562] | web UI [8042, 9864]

Approach

  1. Map each daemon to its ports, tagging web UIs.
  2. For each node type, collect the ports of its daemons.
  3. Print service ports and web UI ports separately.

Solution: run it live

What happens in memory, step by step

Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.

Example 3AdvancedCapacity · NameNode

How much heap does the NameNode need?

Problem statement

A common rule of thumb is that the NameNode needs roughly 1 GB of heap per million files, directories and blocks, plus headroom. A cluster has 40 million files averaging 1.5 blocks each and 3 million directories. Estimate the heap, add 30% headroom, and round up to the next 8 GB.

Input
40 M files × 1.5 blocks · 3 M directories · ~1 GB per million objects · +30%
Expected output
Objects: 103 million
Heap with headroom: 134 GB -> set 136 GB

Approach

  1. Objects = files + blocks + directories.
  2. Heap ≈ objects in millions × 1 GB.
  3. Add 30%, then round up to a multiple of 8 GB.

Solution: run it live

What happens in memory, step by step

Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.

9 Quiz and revision

Check yourself

Quick revision

Lesson 3.1 in one screen

  • Hadoop = a team of Java daemons, not one program.
  • HDFS: NameNode (metadata, 8020 RPC, 9870 UI) + DataNodes (blocks, 9866/9867/9864).
  • HA helpers: JournalNodes (8485), ZKFC (8019), ZooKeeper (2181). Non-HA: Secondary NameNode (9868).
  • YARN: ResourceManager (8032/8030/8031, UI 8088) + NodeManagers (UI 8042, shuffle 13562).
  • MapReduce: one ApplicationMaster per job in a container; JobHistory Server (19888) for finished jobs.
  • Worker = DataNode + NodeManager (locality). Masters stay out of the data path.
  • Config: core-site.xml (fs.defaultFS), hdfs-site.xml, yarn-site.xml, mapred-site.xml, workers.
  • Start order: start-dfs.sh → safe mode exit → start-yarn.sh → history server. Check with jps.

Interview and viva questions

What are the daemons in a Hadoop cluster?

HDFS: NameNode, DataNodes, and either a Secondary NameNode (non-HA) or a standby NameNode with JournalNodes and ZKFailoverControllers (HA). YARN: ResourceManager and NodeManagers (optionally a Timeline Server). MapReduce: a per-job MRAppMaster running in a container and the JobHistory Server. ZooKeeper is a separate service used for HA.

Why does the NameNode not handle file data?

Keeping the master out of the data path means it only answers small metadata requests (open, create, block locations), while the large data transfers happen directly between clients and DataNodes in parallel. This lets one NameNode serve thousands of DataNodes without becoming a bandwidth bottleneck.

What is in core-site.xml, hdfs-site.xml, yarn-site.xml and mapred-site.xml?

core-site.xml: settings shared by all components, most importantly fs.defaultFS. hdfs-site.xml: HDFS settings such as dfs.replication, dfs.blocksize, NameNode and DataNode directories, HA settings. yarn-site.xml: ResourceManager address, NodeManager resources, aux-services, scheduler. mapred-site.xml: mapreduce.framework.name=yarn and MapReduce tuning such as memory and the number of reducers.

How do you check whether Hadoop daemons are running?

Run jps on each node to see the Java processes; use hdfs dfsadmin -report for live and dead DataNodes; yarn node -list for NodeManagers; and open the web UIs (NameNode 9870, ResourceManager 8088). If a daemon is missing, read its log in $HADOOP_HOME/logs.

Why do DataNode and NodeManager run on the same machine?

So that tasks launched by the NodeManager can read blocks stored by the local DataNode. This co-location is what makes data locality, and therefore Hadoop's performance, possible.

Practice problems

Small programs about daemons, ports and configuration: the things you check every day on a real cluster.

P1Easy

Port to service

Given a port number, print which Hadoop 3 service uses it. Test with 9870, 8088 and 19888.

Input
[9870, 8088, 19888]
Expected output
9870 -> NameNode web UI
8088 -> ResourceManager web UI
19888 -> JobHistory web UI
Show solution and explanation
service = {9870: "NameNode web UI", 8088: "ResourceManager web UI", 19888: "JobHistory web UI",
           8020: "NameNode RPC", 9864: "DataNode web UI"}
for p in [9870, 8088, 19888]:
    print(p, "->", service[p])
9870 -> NameNode web UI 8088 -> ResourceManager web UI 19888 -> JobHistory web UI

How it works: Memorise these five ports: they come up in every installation and troubleshooting session.

P2Easy

Count daemons in a cluster

A cluster has 2 master nodes (each running 3 daemons) and 40 workers (each running 2). How many daemon processes in total?

Input
2 × 3 + 40 × 2
Expected output
86 daemons
Show solution and explanation
print(2 * 3 + 40 * 2, "daemons")
86 daemons

How it works: 86 long-running processes, each with its own log file and memory settings.

P3Easy

Block size from bytes

Convert the dfs.blocksize values 134217728 and 268435456 to MB.

Input
["134217728", "268435456"]
Expected output
134217728 = 128 MB
268435456 = 256 MB
Show solution and explanation
for v in ["134217728", "268435456"]:
    print(v, "=", int(v) // (1024 * 1024), "MB")
134217728 = 128 MB 268435456 = 256 MB

How it works: 128 MB and 256 MB. Hadoop also accepts values like 128m or 256m in configuration.

P4Medium

Parse fs.defaultFS

From these fs.defaultFS values, print host and port. If no port is given, HDFS uses 8020.

Input
["hdfs://nn1:8020", "hdfs://localhost:9000", "hdfs://mycluster"]
Expected output
hdfs://nn1:8020 -> nn1 8020
hdfs://localhost:9000 -> localhost 9000
hdfs://mycluster -> mycluster 8020
Show solution and explanation
from urllib.parse import urlparse
for v in ["hdfs://nn1:8020", "hdfs://localhost:9000", "hdfs://mycluster"]:
    u = urlparse(v)
    print(v, "->", u.hostname, u.port or 8020)
hdfs://nn1:8020 -> nn1 8020 hdfs://localhost:9000 -> localhost 9000 hdfs://mycluster -> mycluster 8020

How it works: hdfs://mycluster with no port is how HA clusters are addressed: mycluster is a logical name that maps to both NameNodes in hdfs-site.xml.

P5Medium

Override order

Apply configuration layers in order (defaults, site, job) and print the final replication and block size.

Input
defaults {repl 3, block 128m} · site {repl 2} · job {block 256m}
Expected output
{'dfs.replication': '2', 'dfs.blocksize': '256m'}
Show solution and explanation
layers = [{"dfs.replication": "3", "dfs.blocksize": "128m"},
          {"dfs.replication": "2"},
          {"dfs.blocksize": "256m"}]
conf = {}
for layer in layers:
    conf.update(layer)
print(conf)
{'dfs.replication': '2', 'dfs.blocksize': '256m'}

How it works: Later layers win. Administrators can mark a property <final>true</final> in site files so jobs cannot override it.

P6Medium

Live vs dead DataNodes

Given each DataNode's seconds since last heartbeat, print live and dead counts using the 630-second rule.

Input
{dn1: 2, dn2: 700, dn3: 1, dn4: 640, dn5: 3}
Expected output
Live: 3 | Dead: 2 ['dn2', 'dn4']
Show solution and explanation
last = {"dn1": 2, "dn2": 700, "dn3": 1, "dn4": 640, "dn5": 3}
dead = [n for n, s in last.items() if s > 630]
print("Live:", len(last) - len(dead), "| Dead:", len(dead), dead)
Live: 3 | Dead: 2 ['dn2', 'dn4']

How it works: This is the number at the top of the NameNode web UI and of hdfs dfsadmin -report.

P7Business problem

Memory budget for a worker

A worker has 256 GB RAM. Reserve 8 GB for the OS, 4 GB for the DataNode and 2 GB for the NodeManager. How much can YARN offer to containers, and how many 4 GB containers fit?

Input
256 GB · OS 8 · DN 4 · NM 2 · containers 4 GB
Expected output
yarn.nodemanager.resource.memory-mb = 247808
4 GB containers per node: 60
Show solution and explanation
total, os_gb, dn, nm = 256, 8, 4, 2
yarn_gb = total - os_gb - dn - nm
print("yarn.nodemanager.resource.memory-mb =", yarn_gb * 1024)
print("4 GB containers per node:", yarn_gb // 4)
yarn.nodemanager.resource.memory-mb = 247808 4 GB containers per node: 60

How it works: 242 GB for YARN, 60 containers of 4 GB. Giving YARN all the memory starves the daemons and the OS; Module 11 covers tuning.

P8Business problem

Master heap budget

The NameNode needs about 1 GB per million objects. The cluster has 120 million objects and grows 25% a year. What heap is needed now and in 2 years (with 30% headroom)?

Input
120 M objects · +25%/year · +30%
Expected output
Year 0: ~156 GB NameNode heap
Year 2: ~244 GB NameNode heap
Show solution and explanation
objects_m = 120
for year in [0, 2]:
    need = objects_m * 1.25 ** year * 1.3
    print(f"Year {year}: ~{need:.0f} GB NameNode heap")
Year 0: ~156 GB NameNode heap Year 2: ~244 GB NameNode heap

How it works: About 156 GB now and 244 GB in two years. Very large heaps make Java garbage collection pauses longer, one reason teams use federation or compact small files.

Real-world scenario questions (asked in company interviews)

Architecture questions in interviews are usually practical: what runs where, how they talk, and what you check when something breaks.

Operations · troubleshootingFresher

Jobs never use one of the workers

The HDFS UI shows 10 live DataNodes, but the YARN UI shows only 9 active NodeManagers. Jobs never run tasks on worker w7.

The interviewer is checking: do you know that storage and compute are separate daemons on the same node?

Show a strong answer
  1. On w7, run jps: the DataNode is running but the NodeManager isn't (or it is unhealthy).
  2. Read the NodeManager log under $HADOOP_HOME/logs: common causes are a wrong yarn.resourcemanager.hostname, a full local disk (marked unhealthy), or a memory setting larger than the machine.
  3. Fix and start it: yarn --daemon start nodemanager, then confirm with yarn node -list.

Avoid: restarting the whole cluster for one missing daemon.

Any company · conceptsFresher

“Does all data go through the NameNode?”

The interviewer says: “If the NameNode is the master, surely every byte you read passes through it, right?”

The interviewer is checking: do you understand why masters stay out of the data path?

Show a strong answer
  • No. The client asks the NameNode only for metadata: which blocks make up the file and which DataNodes hold them.
  • The client then reads (or writes) the bytes directly from the DataNodes, choosing the closest replica.
  • This keeps the NameNode's work small and lets thousands of clients transfer data in parallel. The same is true of YARN: the ResourceManager hands out containers but never touches job data.

Avoid: drawing data arrows through the NameNode in an architecture diagram.

Platform team · configuration1–3 years

Spark on the edge node can't find HDFS

A data scientist installs Spark on a new edge node. spark.read.csv("/data/sales") fails with “File does not exist” even though hdfs dfs -ls /data/sales works on other nodes.

The interviewer is checking: do you know how clients find the cluster?

Show a strong answer
  • Spark doesn't know the cluster: without core-site.xml, the default file system is the local disk (file:///), so /data/sales is looked up locally.
  • Copy the cluster's core-site.xml, hdfs-site.xml and yarn-site.xml to the edge node and point HADOOP_CONF_DIR (and Spark) at them, or use a full URI like hdfs://nn1:8020/data/sales.
  • In a managed cluster, add the node as a “gateway” host so the manager keeps the client configuration in sync.

Avoid: copying the data to the edge node.

Infrastructure · design1–3 years

Put the NameNode and ResourceManager on one server?

To save money on a new 30-node cluster, someone proposes running the NameNode, ResourceManager, JobHistory Server and also a DataNode on one master server.

The interviewer is checking: do you understand the resource needs and failure impact of master daemons?

Show a strong answer
  • For small clusters, NameNode + ResourceManager + JobHistory on one well-equipped master is common and acceptable.
  • But not a DataNode/NodeManager on the master: tasks would compete with the NameNode for memory and disk, and a runaway task could slow or crash the master.
  • Separate the masters as the cluster grows (NameNode heap needs grow with files), and add HA (a second master, JournalNodes on three machines) when uptime matters.

Avoid: treating master servers like ordinary workers.