These Hadoop interview questions and answers cover HDFS, YARN, MapReduce, cluster administration, performance tuning, and scenario-based troubleshooting. The questions progress from foundational Hadoop concepts for freshers to architecture and operations topics for experienced candidates.
Hadoop Interview Questions for Freshers
1. What is Apache Hadoop?
Apache Hadoop is an open-source framework for distributed storage and parallel processing of large data sets across clusters of computers. Its core modules are Hadoop Common, Hadoop Distributed File System, YARN, and Hadoop MapReduce.
2. What are the core Hadoop modules?
- Hadoop Common: Shared libraries and utilities required by the other Hadoop modules.
- HDFS: A distributed file system that stores file blocks across cluster nodes.
- YARN: The resource-management and application-scheduling layer.
- MapReduce: A YARN-based framework for parallel processing of large data sets.
3. Why is Hadoop used for large data sets?
Hadoop distributes data and computation across multiple machines. It scales horizontally by adding nodes, processes partitions in parallel, and tolerates many storage-node failures through block replication. It is best suited to high-throughput workloads rather than low-latency transactional processing.
4. What is HDFS?
HDFS stands for Hadoop Distributed File System. It divides files into blocks and stores those blocks across DataNodes. The NameNode maintains file-system metadata and block locations, while DataNodes store the actual data blocks and serve client read and write requests.
5. What is the difference between a NameNode and a DataNode?
| HDFS component | Responsibility |
|---|---|
| NameNode | Maintains the HDFS namespace, permissions, file-to-block mapping, and block-location metadata. |
| DataNode | Stores HDFS blocks, serves data to clients, and performs block creation, deletion, and replication when instructed. |
File data normally flows directly between the HDFS client and DataNodes. It does not pass through the NameNode.
6. What is an HDFS block?
An HDFS block is a unit into which a file is divided for distributed storage. A commonly configured block size is 128 MB, although it can be changed. Large blocks reduce NameNode metadata overhead and support high-throughput sequential access.
7. What is the HDFS replication factor?
The replication factor specifies how many copies of each HDFS block should be maintained. It can be set when a file is created and changed later. Replication improves availability after disk or DataNode failures, but extra replicas consume additional storage and network bandwidth.
8. What are HDFS heartbeats and block reports?
A DataNode sends periodic heartbeats to indicate that it is running. It also sends block reports listing the blocks stored on that node. The NameNode uses this information to track DataNode health and identify missing or under-replicated blocks.
9. What is rack awareness in Hadoop?
Rack awareness provides Hadoop with information about the physical network topology of cluster nodes. HDFS uses this information when placing replicas, and processing frameworks can use it when considering data locality. It helps limit the effect of rack failures and unnecessary cross-rack traffic.
10. What is YARN?
YARN is Hadoop’s resource-management and application-execution layer. It separates cluster-wide resource allocation from application-specific task coordination, allowing different distributed-processing frameworks to share a Hadoop cluster.
11. What are the main YARN components?
- ResourceManager: Allocates cluster resources among applications.
- NodeManager: Runs on each worker node and manages containers on that node.
- ApplicationMaster: Coordinates one application and requests resources from the ResourceManager.
- Container: A resource allocation in which an application task runs.
12. What is a YARN container?
A YARN container represents an allocation of resources on a cluster node, such as memory and virtual CPU cores. The NodeManager launches and monitors the application process that runs within the container.
HDFS Architecture Interview Questions
13. How does an HDFS client read a file?
- The client asks the NameNode for the locations of the required file blocks.
- The NameNode returns a list of DataNodes holding replicas of those blocks.
- The client reads each block directly from a suitable DataNode, generally preferring a nearby replica.
- If one replica cannot be read, the client can try another available replica.
14. How does an HDFS client write a file?
- The client sends a file-creation request to the NameNode.
- The NameNode validates the request and chooses DataNodes for the first block’s replicas.
- The client sends data to the first DataNode in a replication pipeline.
- Each DataNode stores the data and forwards it to the next DataNode.
- Acknowledgements return through the pipeline to the client.
- The process repeats for subsequent blocks.
15. Why is HDFS not suitable for many small files?
The NameNode keeps namespace and block metadata in memory. A very large number of small files therefore creates substantial metadata overhead, even when the files occupy little disk space. Small files can also reduce the efficiency of processing systems designed for large sequential reads.
Possible remedies include combining related files, using an appropriate container or columnar file format, compacting files periodically, or storing small records in a system designed for that access pattern.
16. What happens when a DataNode fails?
The NameNode detects the absence of heartbeats and marks the DataNode unavailable. Blocks stored on the failed node may become under-replicated. The NameNode then schedules creation of replacement replicas on healthy DataNodes when cluster conditions permit.
17. What is HDFS safe mode?
Safe mode is a NameNode state in which namespace changes are restricted while the NameNode evaluates block information and cluster health. It commonly occurs during startup. Administrators should investigate why safe mode persists before manually forcing the NameNode to leave it.
18. Is the SecondaryNameNode a standby NameNode?
No. The SecondaryNameNode creates checkpoints by merging namespace-image and edit-log information. It is not a direct hot standby for the active NameNode. HDFS high-availability configurations use active and standby NameNodes with the required shared-edits and failover mechanisms.
19. What is HDFS high availability?
HDFS high availability uses active and standby NameNodes so that another NameNode can take over when the active one becomes unavailable. A production design must also maintain consistent namespace changes and provide a reliable failover process.
MapReduce Interview Questions and Answers
20. What is Hadoop MapReduce?
MapReduce is a distributed processing model and Hadoop framework. Input is divided among parallel map tasks, intermediate key-value records are grouped and transferred, and reduce tasks process grouped values to create the final output.
21. What are the map, shuffle, sort, and reduce phases?
- Map: Converts input records into intermediate key-value pairs.
- Shuffle: Transfers mapper-output partitions to their assigned reducers.
- Sort and group: Orders intermediate keys and groups all values belonging to the same key.
- Reduce: Processes each key and its grouped values to produce output records.
22. What is a combiner in MapReduce?
A combiner is an optional local aggregation step that can reduce the amount of mapper output transferred across the network. Hadoop does not guarantee that a combiner will run, or how many times it will run. Its logic must therefore remain correct when executed zero, one, or multiple times.
23. What is a partitioner in MapReduce?
A partitioner determines which reducer receives an intermediate key. The default partitioner distributes keys using a hash value. A custom partitioner is useful when business rules or data-skew concerns require a different distribution.
24. What is data locality in Hadoop?
Data locality means running computation on or near the nodes that store the input data. This reduces network transfer. A scheduler may prefer node-local execution, then rack-local execution, and finally off-rack execution when closer resources are unavailable.
25. What is speculative execution?
Speculative execution starts an additional attempt for a task that appears unusually slow. The first successful attempt is used. It can reduce the effect of a slow node, but it wastes resources when used unnecessarily and may be unsuitable for tasks with non-repeatable external side effects.
Hadoop Interview Questions for Experienced Candidates
26. How do you choose an HDFS block size?
Choose the block size according to file sizes, processing patterns, desired parallelism, and NameNode metadata limits. Larger blocks reduce metadata and task-launch overhead but can reduce parallelism when only a few files are processed. Smaller blocks increase the number of blocks, tasks, and metadata records.
27. How do you handle reducer data skew?
First confirm the skew using task counters, key-frequency analysis, partition sizes, and reducer runtimes. Possible remedies include salting frequently occurring keys, using a custom partitioner, performing partial aggregation, separating exceptional keys into another flow, or redesigning the grouping key.
Adding more reducers does not solve the problem when one dominant key must still be processed by a single reducer.
28. How do you decide the number of reducers?
There is no universal reducer formula. Consider intermediate-data volume, desired output-file size, available cluster resources, task-startup overhead, data skew, and downstream requirements. Too few reducers can create long-running tasks and oversized files, while too many can create scheduling overhead and numerous small files.
29. What is the difference between HDFS replication and erasure coding?
Replication stores complete copies of a block and provides straightforward recovery at a relatively high storage cost. Erasure coding stores data and parity units, generally reducing storage overhead for suitable data while requiring additional computation and more complex reconstruction. The choice depends on access frequency, recovery requirements, and storage cost.
30. How does Hadoop handle failed YARN tasks?
The application framework monitors task attempts running in containers. A failed attempt can be retried according to the framework and application configuration. The ApplicationMaster coordinates the application, NodeManagers report container status, and the ResourceManager manages cluster resource allocations.
31. What factors affect Hadoop job performance?
- Input-file size, format, and compression
- Data locality and cross-rack network traffic
- Mapper and reducer parallelism
- Intermediate-data and shuffle volume
- Key skew and partition distribution
- Memory, CPU, disk, and network contention
- Spill, merge, and sort behaviour
- YARN container sizing and queue capacity
- Serialization and object-allocation overhead
- Output-file size and file count
32. When would you avoid MapReduce?
MapReduce may not be suitable for low-latency interactive queries, frequent record-level updates, continuous stream processing, or iterative algorithms that repeatedly reuse the same working data. The alternative depends on the workload and may be another processing engine on YARN or a separate data platform.
Scenario-Based Hadoop Interview Questions
33. A MapReduce job is stuck at 99%. How would you troubleshoot it?
Identify the remaining task and inspect its attempt logs, counters, progress, input partition, and node health. Check for a highly skewed key, excessive garbage collection, disk errors, repeated failures, network problems, or an unavailable external dependency. Compare the slow task with completed tasks before changing configuration.
34. One reducer receives most of the mapper output. What is the likely cause?
The likely cause is key or partition skew. Confirm it by examining mapper-output records and bytes per reducer, key frequencies, and reducer runtimes. Correct the distribution using a more appropriate key, custom partitioner, hot-key salting, pre-aggregation, or a separate path for dominant keys.
35. A Hadoop job creates thousands of small output files. What would you change?
Determine which stage creates the files and reduce unnecessary output parallelism. Depending on the processing framework, merge or coalesce partitions, compact files in a later job, use an appropriate file format, and define a sensible target file size. Preserve partitioning needed by downstream consumers.
36. An HDFS file is under-replicated. What should an administrator check?
- Availability of healthy DataNodes and free storage
- Dead, excluded, or decommissioning DataNodes
- Disk failures and failed DataNode volumes
- Rack-awareness and block-placement constraints
- NameNode safe mode or delayed block processing
- Network connectivity between cluster nodes
- Whether the requested replication factor can be satisfied
37. A YARN application remains in the ACCEPTED state. What would you inspect?
Check queue capacity, user limits, pending resource requests, requested ApplicationMaster container size, maximum allocation settings, node labels, placement constraints, scheduler diagnostics, and available cluster resources. The application can remain accepted when YARN cannot allocate its ApplicationMaster container.
38. A Hadoop job runs much faster when retried. What could explain it?
Possible causes include better data locality, fewer competing applications, a different set of nodes, operating-system caching, lower network contention, successful speculative attempts, or a temporary storage problem during the first run. Compare task placement, counters, queue usage, and node metrics between executions.
Hadoop Administration Interview Questions
39. How do you check basic HDFS health from the command line?
Common HDFS diagnostic commands include:
hdfs dfsadmin -report
hdfs fsck /
hdfs dfs -df -h /
hdfs dfs -du -h /path
The output should be interpreted together with NameNode and DataNode logs, monitoring metrics, recent configuration changes, and the cluster’s normal operating baseline.
40. What is the HDFS balancer?
The HDFS balancer redistributes block replicas to improve storage-utilization balance across DataNodes. Block movement consumes disk and network resources, so administrators should use suitable bandwidth controls and monitor the operation.
41. What is the difference between decommissioning and abruptly removing a DataNode?
Decommissioning is a controlled process that allows HDFS to ensure required replicas exist on other nodes before the DataNode leaves service. Abrupt removal makes the node unavailable immediately and can leave blocks under-replicated until replacement replicas are created.
42. Which Hadoop logs should be checked during a failure?
Begin with the component reporting the failure: NameNode, DataNode, ResourceManager, NodeManager, ApplicationMaster, or task-attempt logs. Correlate timestamps, application and container identifiers, hostnames, exit codes, scheduler diagnostics, disk errors, and operating-system events.
Common Hadoop Component Comparisons
| Comparison | Key difference |
|---|---|
| NameNode vs ResourceManager | The NameNode manages HDFS metadata, while the ResourceManager allocates YARN resources. |
| DataNode vs NodeManager | A DataNode stores HDFS blocks, while a NodeManager manages YARN containers. |
| Mapper vs reducer | A mapper transforms input records, while a reducer processes grouped intermediate values. |
| Combiner vs reducer | A combiner is optional local aggregation, while a reducer is a defined processing stage. |
| Replication vs backup | Replication provides online block copies for availability; a backup is a separately managed recovery copy or process. |
| HDFS vs local file system | HDFS distributes blocks across nodes and is designed for scalable, fault-tolerant, high-throughput access. |
Hadoop Interview Preparation Checklist
- Explain the HDFS read and write paths without saying that file data passes through the NameNode.
- Distinguish the SecondaryNameNode from an HDFS high-availability standby NameNode.
- Describe the ResourceManager, NodeManager, ApplicationMaster, and container responsibilities clearly.
- Explain mapper, shuffle, sort, partitioner, combiner, and reducer responsibilities.
- Prepare a troubleshooting example involving skew, small files, under-replication, or a pending YARN application.
- Support performance-tuning answers with counters, logs, and workload measurements instead of fixed formulas.
- Be ready to identify the Hadoop version and scheduler used in your project.
- Explain the trade-offs behind replication, compression, block size, partitioning, and container-sizing decisions.
Frequently Asked Questions About Hadoop Interviews
How should a fresher prepare for Hadoop interview questions?
Start with HDFS, YARN, MapReduce, and Hadoop Common. Learn the HDFS read and write paths, NameNode and DataNode responsibilities, YARN components, MapReduce phases, replication, data locality, and basic administration commands. Practise explaining each concept in your own words.
Which Hadoop topics are asked of experienced candidates?
Experienced interviews commonly cover architecture decisions, failure recovery, scheduler behaviour, data skew, small files, container sizing, compression, file formats, capacity planning, monitoring, and production troubleshooting examples.
How should I answer scenario-based Hadoop interview questions?
Use a structured diagnostic sequence: clarify the symptom, identify the affected component, collect logs and metrics, form testable hypotheses, isolate the cause, propose a low-risk correction, and explain how the result will be validated and monitored.
Are Hadoop and Spark interview questions the same?
No. Hadoop and Spark overlap in distributed-processing concepts and may share storage or cluster infrastructure, but their execution models, APIs, performance characteristics, and operational details differ. Prepare Hadoop architecture separately from the processing engine required by the role.
TutorialKart.com