Hadoop interview questions: HDFS internals, YARN and MapReduce

Hadoop interview questions go past "what is HDFS" into how it behaves under load and failure: how a block is written through a pipeline of DataNodes, where replicas land, how the NameNode stays available, how YARN sizes containers and what a MapReduce job does between map and reduce. Many of today's Hadoop roles also involve keeping an old cluster healthy or moving its jobs to Spark and cloud storage, so expect operations and migration scenarios.

By Published 9 min read

Who still asks about Hadoop

Hadoop questions appear in data engineering roles at banks, telecoms, retailers and public sector teams that run on-premise clusters, in Hadoop administrator and big data platform roles, and in migration projects that move HDFS, Hive and MapReduce workloads to Spark, object storage or a managed lakehouse. The interview usually starts with architecture, then asks you to reason about a failure (a DataNode dies, the NameNode runs out of heap, a job is stuck), and for admin roles moves to sizing, security and upgrades. If the role is mostly Spark, the shorter Hadoop section of Spark interview questions may be enough; this page is for loops that go deeper.

HDFS internals

HDFS questions
QuestionWhat it testsWhat a strong answer shows
Walk through an HDFS write.Write pathThe client asks the NameNode to create the file and allocate a block, gets a list of DataNodes, and streams packets to the first one, which forwards to the second, which forwards to the third. Acknowledgments travel back along the same pipeline. When a block fills, the client asks for the next one.
Walk through an HDFS read.Read pathThe client gets the block locations from the NameNode, sorted by network distance, and reads each block directly from the nearest DataNode, verifying checksums. If a replica is bad it tries another and reports the corrupt one.
Where does HDFS put the three replicas?Rack awarenessBy default the first goes on the writer's node (or a random node if the client is outside the cluster), the second on a node in a different rack, and the third on another node in that second rack. That survives a rack loss while limiting cross-rack writes.
Why are HDFS blocks so large?Design trade-offLarge blocks keep seek time small relative to transfer time and keep the number of block objects in NameNode memory low. The default is 128 MB in Hadoop 2 and 3, and it can be set per file.
What is a block report and a heartbeat?LivenessDataNodes send heartbeats every few seconds and periodic block reports listing every replica they hold. A DataNode that stops heartbeating is marked dead after a timeout and its blocks are re-replicated.
What is safe mode?StartupA read-only state at NameNode startup while it loads metadata and waits for enough blocks to be reported. It exits automatically once the threshold is met; an admin can also enter it for maintenance.
What is erasure coding in Hadoop 3?Storage efficiencyInstead of three full copies, data is striped with parity. A Reed-Solomon 6+3 policy stores nine units for six of data, about 1.5 times the raw size instead of 3, and survives three lost units. Reads of lost data and writes cost more CPU and network, so it suits cold data.
How do HDFS quotas work?GovernanceA name quota caps the number of files and directories under a path; a space quota caps bytes, counting every replica. Both are set with hdfs dfsadmin.
HDFS questions. Scroll sideways on a small screen.

The NameNode: metadata, checkpoints and high availability

  • What are fsimage and the edit log? fsimage is a snapshot of the namespace on disk. Every change since then is appended to the edit log. On restart, the NameNode loads the fsimage and replays the edits, which is slow if the log has grown huge.
  • What does the Secondary NameNode actually do? It periodically merges the edit log into a new fsimage so restarts stay fast. It is not a hot standby and cannot take over; the name misleads people, which is why interviewers ask.
  • How does NameNode high availability work? An active and one or more standby NameNodes share the edit log through a quorum of JournalNodes (an odd number, usually three). Standbys replay edits continuously, and DataNodes report blocks to all of them. A ZKFailoverController on each NameNode uses ZooKeeper to elect the active one and trigger failover.
  • Why does HA need fencing? To stop a NameNode that only seems dead from still writing. The JournalNodes accept writes from one active writer epoch only, and extra fencing methods can cut off the old node.
  • What is HDFS federation? Several independent NameNodes each own part of the namespace, sharing the same DataNodes, so metadata capacity scales horizontally. Router-based federation can present them as one namespace to clients.
  • Why are small files a problem? Every file, directory and block is an object in NameNode heap. Ten million 10 KB files cost far more memory than the same data in a few hundred large files, and each small file also becomes its own map task. Fixes: compact them into larger files, use container formats such as Parquet or ORC, HAR archives, or batch writes upstream.

YARN: scheduling and containers

YARN questions
QuestionWhat it testsWhat a strong answer shows
Capacity Scheduler versus Fair Scheduler?Multi-tenancyCapacity gives each queue a guaranteed share of the cluster with the ability to borrow idle capacity, and is the Apache Hadoop default. Fair shares resources so that running apps converge on equal shares over time. Both support hierarchical queues and preemption.
How does YARN decide container sizes?SizingEach NodeManager offers a set amount of memory and vcores. Requests are rounded up to a multiple of the minimum allocation and capped at the maximum, so a 1.1 GB request with a 1 GB minimum takes 2 GB.
A task fails with "running beyond physical memory limits". Why?Memory tuningThe process used more than its container size. The JVM heap plus off-heap memory, thread stacks and native buffers must fit inside it, so the heap is usually set to around 80 percent of the container, not equal to it.
What does the ApplicationMaster do when a container fails?Fault toleranceIt asks the ResourceManager for a new container and retries the task, up to the configured attempt limit. If the AM itself dies, the ResourceManager restarts it a limited number of times.
What are node labels?PlacementTags on NodeManagers, such as gpu or ssd, that let queues or applications ask for containers on specific hardware.
How do you find the logs of a finished application?DebuggingWith log aggregation enabled, yarn logs -applicationId <id> pulls all container logs from HDFS. Without it, logs stay on each node's local disk until they are cleaned up.
How is the ResourceManager made highly available?HAAn active and standby ResourceManager with state stored in ZooKeeper, so running applications can recover after a failover.
YARN questions. Scroll sideways on a small screen.

MapReduce in depth

  • Input split versus block? A block is how HDFS stores bytes; a split is the logical chunk one mapper reads. They usually align, but a record that crosses a block boundary is read whole by the split where it started, fetching the tail from the next block.
  • What happens on the map side before the shuffle? Map output goes to an in-memory buffer. When it passes a threshold it is partitioned by reducer, sorted by key, optionally combined, and spilled to local disk. Spills are merged into one sorted file per map task.
  • What does the partitioner decide? Which reducer gets each key. The default hashes the key modulo the number of reducers; a custom partitioner helps when keys are skewed or when output must be range-ordered.
  • When is a combiner safe? When the operation is associative and commutative and the combiner's output has the same shape as the mapper's, because the framework may run it zero, one or many times. Sums and counts work; averaging averages does not, so carry the sum and the count.
  • What is speculative execution? When a task runs much slower than its peers, the framework launches a duplicate on another node and uses whichever finishes first. It hides slow hardware but wastes resources and must be off for tasks with side effects.
  • How do you get a globally sorted output? One reducer for small data, or a total order partitioner with sampled split points so each reducer gets a key range and the output files concatenate in order.
  • What is a secondary sort? Sorting values within each key by building a composite key, partitioning and grouping on the natural part only, so the reducer receives values already ordered, for example events by timestamp per user.
  • What are counters for? Built-in and custom tallies across tasks, such as bad records skipped. They are cheap monitoring and a good way to fail a job when a data quality threshold is crossed.
#!/usr/bin/env python3
"""Average latency per endpoint with Hadoop Streaming.

Input lines look like: 2026-12-01T10:00:01Z GET /api/orders 200 123
(timestamp, method, path, status, milliseconds).

  map      -> path<TAB>ms<TAB>1
  combine  -> path<TAB>sum<TAB>count   (partial sums, safe to apply 0..n times)
  reduce   -> path<TAB>average_ms<TAB>count
"""
import sys


def emit(*fields):
    print("\t".join(str(f) for f in fields))


def mapper():
    for line in sys.stdin:
        parts = line.split()
        if len(parts) != 5 or not parts[4].isdigit():
            # Counted in the job's counters instead of crashing the task.
            print("reporter:counter:Latency,BadLines,1", file=sys.stderr)
            continue
        emit(parts[2], parts[4], 1)


def sum_by_key(final):
    current, total, count = None, 0, 0
    for line in sys.stdin:  # the framework delivers lines sorted by key
        key, value_sum, value_count = line.rstrip("\n").split("\t")
        if key != current and current is not None:
            flush(current, total, count, final)
            total, count = 0, 0
        current = key
        total += int(value_sum)
        count += int(value_count)
    if current is not None:
        flush(current, total, count, final)


def flush(key, total, count, final):
    if final:
        emit(key, round(total / count, 1), count)
    else:
        emit(key, total, count)


if __name__ == "__main__":
    mode = sys.argv[1]
    if mode == "map":
        mapper()
    elif mode == "combine":
        sum_by_key(final=False)
    elif mode == "reduce":
        sum_by_key(final=True)
    else:
        sys.exit("usage: latency.py map|combine|reduce")
A Hadoop Streaming job that averages latency per endpoint. The combiner passes sums and counts rather than averages, so the result is correct however many times it runs. Bad lines increment a job counter through standard error. Run locally against 30 random inputs and checked against a direct average.
# Test the whole flow on one machine first; sort stands in for the shuffle.
cat sample.log | python3 latency.py map | sort | python3 latency.py combine \
  | sort | python3 latency.py reduce

# Then run it on the cluster.
hadoop jar "$HADOOP_HOME"/share/hadoop/tools/lib/hadoop-streaming-*.jar \
  -files latency.py \
  -mapper "python3 latency.py map" \
  -combiner "python3 latency.py combine" \
  -reducer "python3 latency.py reduce" \
  -numReduceTasks 4 \
  -input /logs/web/dt=2026-12-01 \
  -output /reports/latency/dt=2026-12-01
Test the job on one machine with sort standing in for the shuffle, then submit it. The cluster command was not run; the streaming jar path follows the Apache Hadoop 3 layout and differs in vendor distributions.

Operations, security and the cloud

Admin and scenario questions
QuestionWhat it testsWhat a strong answer shows
How do you check HDFS health?Admin commandshdfs dfsadmin -report for capacity and live or dead DataNodes, hdfs fsck / for missing, corrupt and under-replicated blocks, and the NameNode web UI for heap use and the oldest checkpoint.
How do you remove a DataNode safely?DecommissioningAdd it to the exclude file and run hdfs dfsadmin -refreshNodes. The NameNode re-replicates its blocks elsewhere and marks it decommissioned when done. Stopping it cold forces emergency re-replication instead.
New disks or nodes were added and data is uneven.BalancingRun the HDFS balancer with a threshold and a bandwidth limit so it does not starve jobs. Within a node, the disk balancer spreads data across volumes.
How is a Hadoop cluster secured?SecurityKerberos for authentication of users and services, Apache Ranger (or the vendor's tool) for authorization policies and auditing, HDFS encryption zones with a key management server for data at rest, and wire encryption for RPC and data transfer.
A user deleted a production directory.RecoveryCheck the trash first if it is enabled and the delete did not skip it. Snapshots on important directories make this a quick restore; without either, recovery is from backups or the source systems.
How would you move Hadoop workloads to the cloud?MigrationInventory jobs and data, copy with DistCp, store data in object storage, rewrite MapReduce and Pig jobs in Spark or SQL, move the Hive metastore or adopt a table format, and compare outputs before cutting over. Note that object stores lack atomic directory renames, so job commit needs the S3A committers or a table format.
One reducer runs for hours while others finish in minutes.SkewA hot key sends most data to one reducer. Look at counters per reducer, salt the key or pre-aggregate with a combiner, and handle the hot key separately.
Admin and scenario questions. Scroll sideways on a small screen.

Fictional example

Answering "Our NameNode heap keeps growing. What do you do?"
Interviewer
The NameNode heap alarm fires every week and we keep raising the heap. What would you look at?
Candidate
Heap on the NameNode tracks the number of namespace objects, not the amount of data, so my first question is how many files and blocks we have and how that number is growing. I would pull the totals from the NameNode UI or fsck, then find which directories hold the most files. A common pattern is a streaming or hourly job writing thousands of tiny part files per run. If that is what we find, the fix is at the source: write fewer, larger files, add a compaction job that rewrites old partitions into files near the block size, and set a name quota on the worst directories so the problem cannot come back silently. Raising the heap again buys time but makes garbage collection pauses longer, which can trigger failovers. If the namespace is genuinely large and well organized, then federation is the structural answer. I would also check that checkpoints are running, since a huge edit log makes restarts painfully slow.

How to prepare for Hadoop interview questions

  1. Run a pseudo-distributed clusterStart HDFS and YARN in containers, put files in, kill a DataNode and watch the under-replicated count in fsck go up and come back down.
  2. Draw the pathsPractice drawing the write pipeline, the read path, HA with JournalNodes and ZKFC, and the map-side spill, each in about two minutes.
  3. Write one streaming jobUse the script above or your own, test it with sort locally, and explain why the combiner keeps sums and counts.
  4. Learn ten admin commandsdfsadmin -report, fsck, balancer, refreshNodes, setQuota, allowSnapshot, yarn application -list and -kill, and yarn logs. Know what each output means.
  5. Prepare a migration storyBe ready to explain how you would move one Hive and MapReduce pipeline to Spark and object storage, and how you would prove the results match.

Hadoop rarely stands alone in an interview. Hive interview questions covers the SQL layer that runs on it, Databricks interview questions covers where many migrations land, and Airflow interview questions covers scheduling the jobs.

Architecture questions like these are easier when you have said the answers aloud a few times. Natively, an AI interview assistant for Mac and Windows, transcribes a mock big data round, can read an fsck report, a YARN error or a cluster diagram from a screenshot, and offers a suggested answer beside yours in real time. On Pro or the free trial it uses your résumé and the job description you add, and it keeps each session's transcript and notes so you can review what you skipped.

Questions people ask

What are common Hadoop interview questions?

How HDFS reads and writes a file, where replicas are placed, what the Secondary NameNode does, how NameNode high availability works, why small files are a problem, how YARN sizes containers, and what happens between map and reduce.

Is the Secondary NameNode a backup NameNode?

No. It only merges the edit log into a new fsimage checkpoint. Failover needs a Standby NameNode with shared edits through JournalNodes and ZooKeeper-based failover controllers.

Why is Hadoop bad with small files?

Every file and block is an object in NameNode memory, and each small file can become its own map task. Millions of tiny files waste heap and slow jobs, so compact them into larger files.

Is Hadoop still worth learning for interviews?

For roles that run on-premise clusters or migrate them, yes. Many data engineering roles now focus on Spark and cloud storage, but HDFS, YARN and MapReduce concepts still explain how those systems behave.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP