Top 32 Hadoop Interview Questions and Asnwers

The number of companies adopting Big Data initiatives has been ramping up over the last few years, and they are producing tangible results. A recent Harvard Business Review study reveals that more than 80% of executives characterize their Big Data investments as successful. Hadoop developers are leading the way for many of these big data deployments, making them a valued asset – but also creating fierce competition for available jobs.

Interest Over Time

Regional Interest

There are several different job profiles related to and within the Hadoop domain. In this article, we will discuss some of the more common interview questions at the entry-level for both experienced (but new to Hadoop) and fresh aspirants, and additional facts you’ll need to know to ace the interview experience.

Hadoop Interview Question and Answers

1. What Is the Hadoop Framework?

Hadoop is an open-source framework written in Java and devised by the Apache software foundation. This framework is used to write software applications that process vast amounts of data. The framework works in-parallel on large clusters that may have thousands of computers in a single node, and multiple nodes per cluster. It also processes data in a reliable and fault-tolerant manner. The base programming model of Hadoop is based on Google’s MapReduce.

Hadoop is a platform that offers both distributed storage and computational capabilities. It was first conceived to fix a scalability issue that existed in Nutch, an open-source crawler and search engine. At the time, Google had published papers that described its novel distributed Google File System (GFS), and Map-Reduce, a computational framework for parallel processing. The successful implementation of these papers’ concepts in Nutch resulted in being split into two separate projects, the second of which became Hadoop.

2. What Is HDFS?

Filesystems that manage storage across a network of machines are called distributed filesystems. Hadoop comes with a Java-based file system called HDFS, which provides scalable and reliable data storage designed to span large clusters of commodity servers. HDFS has many similarities with other distributed file systems but is different in several respects. One noticeable difference is HDFS's write-once-read-multiple-times model that relaxes concurrency control requirements, simplifies data coherency, and enables high-throughput access.

Another unique attribute of HDFS is that it is usually better to locate processing logic near the data rather than moving the data to the application space. In HDFS, Data Blocks are distributed across local drives of all machines in a cluster. HDFS is designed to work with the MapReduce System, where computation is moved to data. HDFS runs on a cluster of machines and provides redundancy using replication protocol.

3. Hadoop Vs. Traditional System

Hadoop was designed for large, distributed data processing that addresses every file in the database, which is a type of processing that takes time. For tasks where performance isn’t critical, such as running end-of-day reports to review daily transactions, historical scanning data, and performing analytics where a slower time-to-insight is acceptable, Hadoop is ideal.

On the other hand, in cases where organizations rely on time-sensitive data analysis, a traditional database is the better fit. That’s because shorter time-to-insight isn’t about analyzing large unstructured datasets, which Hadoop does so well. It’s about analyzing smaller data sets in real or near-real-time, which is what traditional databases are well equipped to do.

RDBMSs only work better when an entity-relationship model (ER model) is defined perfectly as it follows Codd’s 12 rule and, therefore, the database schema or structure can grow. The emphasis is on strong consistency, referential integrity, abstraction from the physical layer, and complex queries through the SQL, whereas the Hadoop framework works very well with structured and unstructured data. This also supports a variety of data formats in real-time, such as XML, JSON, and text-based flat file formats.

4. What Is MapReduce?

MapReduce is a programming model and an associated implementation for processing and generating large data sets with a parallel, distributed algorithm on a cluster. MapReduce jobs usually split the input data-set into independent chunks, while a Map task will process these chunks in a completely parallel manner on different nodes. The job of the framework is to sort the outputs of the maps. The reducer produces the final result with the help of the output from the previous step.

5. How Do Read Operations Function In Hadoop?

Read\write operations in HDFS consist of a single master + multiple slave architecture, where Namenode acts as master and Datanodes as slaves. All the metadata information is with the Namenode, and the actual data is stored on the Datanodes.

Read Operations Function In Hadoop
Read Operation: DataFlair

1. The user asks the HDFS client to read a file > The client opens the file it wishes to read by calling open() on the FileSystem object, which, for HDFS, is an instance of  DistributedFileSystem.
2. DistributedFileSystem calls the namenode, using remote procedure calls (RPCs), and the Client moves the request to NameNode.
3. NameNode provides block information on which data node has the file, and the client then proceeds to read data from datanodes.
4. The DistributedFileSystem returns an FSDataInputStream (an input stream that supports file searches) to the client for it to read data from. FSDataInputStream, in turn, wraps a DFSInputStream, which manages the datanode and namenode I/O.
5. The Client reads data from all datanodes in parallel (to quickly access data in case of any failure of any datanode, which is why Hadoop reads data in parallel).
6. After the reading is complete, the connection with the datanode cluster is closed. During the reading, if the DFSInputStream encounters an error while communicating with a datanode, it will try the next closest one for that block. It will also remember datanodes that have failed so that it doesn’t needlessly retry them for later blocks.

Looking forward to becoming a Hadoop Developer? Check out the Big Data Hadoop Certification Training course and get certified today.

6. How Does The Write Operation In Hadoop Function?

Write Operation In Hadoop Function
Write Operation:

1. The user asks the HDFS client to write a file. The client creates the file by calling create() on DistributedFileSystem. DistributedFileSystem makes an RPC call to the namenode to create a new file in the filesystem’s namespace.
2. The namenode performs various checks to make sure the file doesn’t already exist and that the client has the right permissions to create the file.
3. If these checks pass, the namenode makes a record of the new file; otherwise, file creation fails, and the client is thrown an IOException.
4. The DistributedFileSystem returns an FSDataOutputStream for the client to start writing data to.
5. As the client writes data, the DFSOutputStream splits it into packets, which corresponds to an internal queue called the data queue.
6. The data queue is consumed by the DataStreamer, which is responsible for asking the namenode to allocate new blocks by picking a list of suitable datanodes to store the replicas.
7. The list of datanodes forms a pipeline, and here we’ll assume the replication level is three, so there are three nodes in the pipeline. The DataStreamer streams the packets to the first datanode in the pipeline, which stores each packet and forwards it to the second datanode in the pipeline.
8. Similarly, the second datanode stores the packet and forwards it to the third datanode in the pipeline.

9. The DFSOutputStream also maintains an internal queue of packets that are waiting to be acknowledged by datanodes, called the ack queue.
10. A packet is removed from the ack queue only when all the datanodes have acknowledged it in the pipeline.

7. What Are Edge Or Gateway Nodes?

Edge nodes are the interface between the Hadoop cluster and the outside network. For this reason, they’re sometimes referred to as gateway nodes. Most commonly, edge nodes are used to run client applications and cluster administration tools. Typically edge-nodes are kept separate from the nodes that contain Hadoop services such as HDFS, MapReduce, etc., mainly to keep computing resources separate. Edge nodes running within the cluster allow for centralized management of all the Hadoop configuration entries on the cluster nodes, which helps to reduce the amount of administration needed to update the config files. 

The fact is, given the limited security within Hadoop itself, even if your Hadoop cluster operates in a local- or wide-area network behind an enterprise firewall, you may want to consider a cluster-specific firewall to more fully protect non-public data that may reside in the cluster. In this deployment model, think of the Hadoop cluster as an island within your IT infrastructure — for every bridge to that island, you should consider an edge node for security.

8. What Is Apache Yarn?

Apache YARN (Yet Another Resource Negotiator) is Hadoop’s cluster resource management system. Initially described by Apache as a redesigned resource manager, YARN is the next-generation computation and resource management framework in Apache Hadoop and was introduced in Hadoop 2 to improve the MapReduce implementation, enabling Hadoop to support more varied processing approaches and a broader array of applications.

9. Difference Between Mapr1 & Mapr2 (Yarn)?

In MapReduce 1, there are two types of daemons that control the job execution process: a jobtracker and one or more tasktrackers.

The jobtracker coordinates all the jobs run on the system by scheduling tasks to run on tasktrackers.

Tasktrackers run tasks and send progress reports to the jobtracker, which keeps a record of the overall progress of each job. If a task fails, the jobtracker can reschedule it on a different tasktracker. In MapReduce 1, the jobtracker takes care of both job scheduling (matching tasks with tasktrackers) and task progress monitoring (keeping track of tasks, restarting failed or slow tasks, and doing task bookkeeping, such as maintaining counter totals).

In contrast, in YARN, these responsibilities are handled by separate entities - the resource manager and an application master (one for each MapReduce job). The jobtracker is also responsible for storing job history for completed jobs; in YARN, the equivalent role is that of the timeline server, which stores application history.

10. How Does Secondary NameNode Complement NameNode?

The namenode manages the filesystem namespace. It maintains the filesystem tree and the metadata for all the files and directories in the tree.

This information is stored persistently on the local disk in the form of two files: the namespace image and the edit log. The namenode also knows the datanodes on which all the blocks for a given file are located; however, it does not store block locations persistently, because this information is reconstructed from datanodes when the system starts.

It is also possible to run a secondary namenode, which, despite its name, does not act as a namenode. Its primary role is to periodically merge the namespace image with the edit log to prevent the edit log from becoming too large. The secondary namenode usually runs on a separate physical machine because it requires plenty of CPU and as much

memory as the namenode to perform the merge. It keeps a copy of the merged namespace image, which can be used in the event of the namenode failing. However, the state of the secondary namenode lags behind that of the primary, so in the event of total failure of the primary, data loss is almost inevitable.

11. What Is Resource Manager?

The job tracker serves as both a resource manager and a history server in MRv1, which limits scalability. In YARN, the job tracker's role is split between a separate resource manager and a history server to improve scalability. ResourceManager (RM) is the master that arbitrates all the available cluster resources and thus helps manage the distributed applications running on the YARN system. It works with the per-node NodeManagers (NMs) and the per-application ApplicationMasters (AMS). The jobtracker’s responsibilities are split between the resource manager and the application master in YARN, making the service highly accessible. The divide-and-conquer approach handles resource management and job scheduling on Hadoop systems and supports the parsing and condensing of data sets in parallel. Thus, the ResourceManager is primarily limited to schedule - i.e., only arbitrating available resources in the system among the competing applications and not concerning itself with per-application state management. 

ResourceManager Graph

12. What Is Node Manager?

The YARN equivalent of a tasktracker is a node manager. NodeManagers take instructions from the ResourceManager and manage resources available on a single node, and are therefore called per-node agents. The NodeManager is the per-machine/per-node framework agent who is responsible for containers, monitoring their resource usage, and reporting the same to the ResourceManager. In contrast to a fixed number of slots for a map and reduce tasks in MRV1, the NodeManager of MRV2 has several dynamically created resource containers. All container processes running on a slave node are initially provisioned, monitored, and tracked by that slave node’s Node Manager daemon.

13. What Is Application Manager?

ApplicationMasters are responsible for negotiating resources with the ResourceManager and for working with NodeManagers to start the containers. The ApplicationMaster communicates with a YARN cluster and handles application execution. The main tasks of the ApplicationMaster are communicating with the ResourceManager to negotiate and allocate resources for future containers and, after container allocation, communicating with NodeManagers to launch application containers on them. The Application Manager is the actual owner of the job. As the Application Manager is launched within a container that may share a physical host with other containers, given the multi-tenancy nature, amongst other issues, it cannot make any assumptions of things like pre-configured ports that it can listen on.

14. What Is A Container?

A container is a collection of all the resources necessary to run an application: CPU cores, memory, network bandwidth, and disk space. A deployed container runs as an individual process on a slave node in a Hadoop cluster. A container represents an allocated resource in the cluster. The ResourceManager is the sole authority to allocate any Container to applications. The allocated Container is always on a single node and has a unique ContainerId, and has a specific amount of Resources allocated.

15. What Is WritableComparable?

WritableComparator is a general-purpose implementation of RawComparator for WritableComparable classes. IntWritable implements the WritableComparable interface, which is just a subinterface of the Writable and java.lang.Comparable interfaces: package; public interface WritableComparableextends Writable, Comparable { }.

Big Data Hadoop Certification

16. What Is NullWritable?

NullWritable is a special type of Writable, as it has a zero-length serialization. No bytes are written to or read from the stream. It is used as a placeholder; anything writing or reading NullWritables will know ahead of time that it will be dealing with that type. For example, in MapReduce, a key or a value can be declared as a NullWritable when you don’t need to use that position, effectively storing a constant empty value. NullWritable can also be useful as a key in a SequenceFile when you want to store a list of values, as opposed to key-value pairs.

17. What Is The Use Of Context Object?

The Context object allows the mapper to interact with the rest of the Hadoop eco-system. It includes configuration data for the job, as well as interfaces that enable it to deliver output. The context objects are used for emitting key-value pairs. The new API makes extensive use of context objects that allow the user code to communicate with the MapReduce system. The new Context, for example, essentially unifies the role of the JobConf, the OutputCollector, and the Reporter from the old API.

18. What Is A Mapper?

Maps are the individual tasks that transform input records into intermediate records. The transformed intermediate records do not need to be of the same type as the input records. A given input pair may map to zero or too many output pairs. The Hadoop MapReduce framework spawns one map task for each InputSplit generated by the InputFormat for the job.

19. Explain The Shuffle.

MapReduce makes the guarantee that the input to every reducer is sorted by key. The process by which the system performs the sort — and transfers the map outputs to the reducers as inputs — is known as the shuffle. Input to the Reducer is the sorted output of the mappers. In this phase, the framework fetches the relevant partition of the output of all the mappers, via HTTP.

20. What Are the Core Methods and Techniques the Reducer Uses?

The Reducer reduces and shrinks a set of intermediate values that share a key to a smaller set of values. The API of Reducer is very similar to that of Mapper: there's a run() method that receives a Context containing the job's configuration as well as interfacing methods that return data from the reducer itself back to the framework. The run() method calls setup() once and reduce() once for each key associated with the reduce task, and cleanup() once at the end. Each of these methods can access the job's configuration data by using Context.getConfiguration(). As with Mapper, any or all of these methods can be overridden with custom implementations. If none of these methods are overridden, the default reducer operation is the identity function; values are passed through without further processing.

The heart of Reducer is its reduce () method. This is called the once per key; the second argument is an Iterable, which returns all the values associated with that key.

21. What Is the Use of Combiner?

The bandwidth available on the cluster limits many MapReduce jobs, so it pays to minimize the data transferred between the map and reduce tasks. The combine will operate like a Reducer, but only on the subset of the Key/Values output from each Mapper. Combiners are mini-reducers that lessen the workload, which is passed on further to the reducers. Your mapper may be emitting more than one record per key, and they would ultimately be aggregated and passed as a single call in the reducer method.

So if these records per key can be combined even before passing them to reducers, the amount of data that is shuffled across the network to get it to the right reducer will be reduced, ultimately enhancing the job's performance. It is an optional component or class and can be specified via Job.setCombinerClass (Class Name) to perform local aggregation of the intermediate outputs, which helps to cut down the amount of data transferred from the Mapper to the Reducer. The combiner function doesn’t replace the reduce function, but it can help cut down the amount of data shuffled between the mappers and the reducers, and for this reason alone, it is always worth considering whether you can use a combiner function in your MapReduce job.

22. What Is HDFS Federation?

Multiple independent namenodes will be part of the cluster introduced in the 2.x release series, allows a cluster to scale by adding namenodes, each of which manages a portion of the filesystem namespace. For example, one namenode might manage all the files rooted under /account, say, and a second namenode might handle files under /finance.

23. What Is Split-Brain?

Shifting from Hadoop 1 to Hadoop 2 has complicated the NameNode part. One of the common problems that are not unique to the Hadoop cluster but affects any distributed systems is a "split-brain" scenario. Split-brain is a situation where two NameNodes decide they both play an active role and start writing changes to the editlog. To prevent such an issue from occurring, the HA configuration maintains a marker in ZooKeeper, clearly stating which NameNode is active, and JournalNodes accepts only from that node.

24. What Is Fencing?

Fencing is a technique that effectively addresses the Split-Brain problem in Hadoop 2. To be sure that the two NameNodes don't become active at the same time, a method called fencing is used during failover. The idea is to force the shutdown of the active NameNode before transferring the active state to a standby to avoid confusion, to do which it waits for some time to ensure the active namenode is down.

As a last resort, the previously active name-node can be fenced with a technique rather graphically known as STONITH, or “shoot the other node in the head,” which uses a specialized power distribution unit to power down the host machine forcibly.

25. What Are Containers?

A container executes an application-specific process with a constrained set of resources (memory, CPU, and so on). Container represents an allocated resource in the cluster. The ResourceManager is the sole authority to allocate any Container to applications. The allocated Container is always on a single node and has a unique ContainerId. It has a specific amount of Resource allocated. Typically, an ApplicationMaster receives the Container from the ResourceManager during resource-negotiation and then talks to the NodManager to start/stop containers.

Are you planning for Big Data Hadoop Certification? Here're 45 Big Data Hadoop Questions. Take this free practice test to assess yourself.

26. What Is Meant by Task Instance?

Task instances are the actual MapReduce jobs that run on each slave node. The Task Tracker initiates a separate JVM process to do the real work (known as Task Instance) to ensure that process failure does not take down the entire task tracker. Each Task Instance runs on its JVM process. There can be multiple processes of task instance running on a slave node. This is based on the number of slots configured on the task tracker. By default, a new task instance JVM process is spawned for a task.

27. What Is Checksum?

The usual way of detecting corrupted data is by computing a checksum for the information when it first enters the system, and again whenever it is transmitted across a channel that is unreliable and hence capable of corrupting the data. Datanodes are responsible for verifying the data they receive before storing the data and its checksum.

This applies to data that they receive from clients and other datanodes during replication. When clients read data from datanodes, they verify checksums as well, comparing them with the ones stored at the datanodes. Each datanode keeps a persistent log of checksum verifications, so it knows the last time each of its blocks was verified. When a client successfully confirms a block, it tells the datanode, which updates its log. Maintaining statistics such as these is invaluable in detecting bad disks.

28. What Is Serialization/Deserialization?

Serialization is the process of turning structured objects into a byte stream for transmission over a network or for writing to persistent storage. The purpose is twofold: one, transmission over a network (inter-process communication), and two, for writing to persistent storage.

Deserialization is the reverse process of turning a byte stream back into a series of structured objects. Serialization is used in two quite distinct areas of distributed data processing: for inter-process communication and persistent storage.

29. What Are Remote Procedure Calls (RPCs)?

In Hadoop, the inter-process communication between nodes in a system is performed by using remote procedure calls, i.e., RPCs. The RPC protocol uses serialization to turn the message into a binary stream to be sent to the remote node, which receives and de-serializes the binary stream into the original message.

RPC serialization format is expected to be:

  1. Compact: To efficiently utilize network bandwidth.
  2. Fast: Very little performance overhead is planned for the serialization and de-serialization processes.
  3. Extensible: To adapt to new changes and requirements.
  4. Interoperable: The format needs to be designed to support clients that are written in different languages to the server.

30. How Does the Client Communicate with the HDFS?

The Client communication to HDFS is via the Hadoop HDFS API. Client applications talk to the Name Node whenever they wish to locate a file, or when they want to add/copy/move/delete a file on HDFS. The Name Node responds to successful requests by returning a list of relevant Data Node servers where the data lives. Client applications can talk directly to a Data Node, once the Name Node has provided the location of the data.

31. What Are the Restrictions to the Key and Value Class?

The key and value classes have to be serialized by the framework. To make them serializable, Hadoop provides a Writable interface. As you know from Java itself, the key of the Map should be comparable, so it would need to implement one more interface to become Writable Comparable.

32. What Is SSH?

SSH (Secure Shell) is a secure shell that usually runs on top of SSL and has a built-in username/password authentication scheme that can be used for secure access to a remote host. To work seamlessly, SSH needs to be set up to allow password-less login for HDFS and YARN users from machines in the cluster. The simplest way to achieve this is to generate a public/private key pair and place it in an NFS location that is shared across the cluster.


We hope this in-depth overview helps you get your ducks in a row as you pursue your dream Big Data Hadoop developer position. You may also want to look into our comprehensive Big Data and Hadoop Developer Training course for an even deeper dive. I hope you find this all beneficial.

About the Author


Simplilearn is one of the world’s leading providers of online training for Digital Marketing, Cloud Computing, Project Management, Data Science, IT, Software Development, and many other emerging technologies.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.