Top Answers to Hadoop Interview Questions

1. What are the differences between Hadoop and Spark?
CriteriaHadoopSpark
Dedicated storageHDFSNone
Speed of processingAverageExcellent
LibrariesSeparate tools availableSpark Core, SQL, Streaming, MLlib, and GraphX
2. What are the real-time industry applications of Hadoop?

Hadoop, well known as Apache Hadoop, is an open-source software platform for scalable and distributed computing of large volumes of data. It provides rapid, high performance, and cost-effective analysis of structured and unstructured data generated on digital platforms and within the enterprise. It is used in almost all departments and sectors today.

Here are some of the instances where Hadoop is used:

  • Managing traffic on streets
  • Streaming processing
  • Content management and archiving e-mails
  • Processing rat brain neuronal signals using a Hadoop computing cluster
  • Fraud detection and prevention
  • Advertisements targeting platforms are using Hadoop to capture and analyze click stream, transaction, video, and social media data
  • Managing content, posts, images, and videos on social media platforms
  • Analyzing customer data in real time for improving business performance
  • Public sector fields such as intelligence, defense, cyber security, and scientific research
  • Getting access to unstructured data such as output from medical devices, doctor’s notes, lab results, imaging reports, medical correspondence, clinical data, and financial data

Read this informative blog from Intellipaat now to find out how Big Data is transforming real estate!

CTA

Check out this video on Hadoop Tutorial for Beginners:

Top Hadoop Interview Questions and Answers Wish to Learn Hadoop? Click Here

Learn for free ! Subscribe to our youtube Channel.

3. How is Hadoop different from other parallel computing systems?

Hadoop is a distributed file system that lets you store and handle massive amounts of data on a cloud of machines, handling data redundancy.

The primary benefit of this is that since data is stored in several nodes, it is better to process it in a distributed manner. Each node can process the data stored on it instead of spending time on moving the data over the network.

On the contrary, in the relational database computing system, we can query data in real time, but it is not efficient to store data in tables, records, and columns when the data is huge.

Hadoop also provides a scheme to build a column database with Hadoop HBase for runtime queries on rows.

Learn more about HBase from this HBase Tutorial!

4. In what all modes Hadoop can be run?

Hadoop can be run in three modes:

  • Standalone mode:The default mode of Hadoop, it uses local file system for input and output operations. This mode is mainly used for the debugging purpose, and it does not support the use of HDFS. Further, in this mode, there is no custom configuration required for mapred-site.xml, core-site.xml, and hdfs-site.xml files. This mode works much faster when compared to other modes.
  • Pseudo-distributed mode (Single-node Cluster):In this case, you need configuration for all the three files mentioned above. In this case, all daemons are running on one node, and thus both Master and Slave nodes are the same.

Fully distributed mode (Multi-node Cluster): This is the production phase of Hadoop (what Hadoop is known for) where data is used and distributed across several nodes on a Hadoop cluster. Separate nodes are allotted as Master and Slave.

Learn more about Hadoop from this Hadoop Course to get ahead in your career!

5. Explain the major difference between HDFS block and InputSplit.

In simple terms, a block is the physical representation of data while split is the logical representation of data present in the block. Split acts as an intermediary between the block and the mapper.
Suppose we have two blocks:

Block 1: ii nntteell

Block 2: Ii ppaatt

Now considering the map, it will read Block 1 from ii to ll but does not know how to process Block 2 at the same time. Here comes Split into play, which will form a logical group of Block 1 and Block 2 as a single block.

It then forms a key–value pair using InputFormat and records reader and sends map for further processing with InputSplit. If you have limited resources, you can increase the split size to limit the number of maps. For instance, if there are 10 blocks of 640 MB (64 MB each) and there are limited resources, you can assign ‘split size’ as 128 MB. This will form a logical group of 128 MB, with only 5 maps executing at a time.

However, if the ‘split size’ property is set to false, the whole file will form one InputSplit and is processed by a single map, consuming more time when the file is bigger.

Learn end-to-end Hadoop concepts through the Hadoop Course in Hyderabad to take your career to a whole new level!

6. What is distributed cache? What are its benefits?

Distributed cache in Hadoop is a service by MapReduce framework to cache files when needed.

Once a file is cached for a specific job, Hadoop will make it available on each DataNode both in system and in memory, where map and reduce tasks are executing. Later, you can easily access and read the cache file and populate any collection (like array, hashmap) in your code.

Benefits of using distributed cache are as follows:

  • It distributes simple, read-only text/data files and/or complex types such as jars, archives, and others. These archives are then un-archived at the slave node.
  • Distributed cache tracks the modification timestamps of cache files, which notify that the files should not be modified until a job is executed.

Learn more about MapReduce from this MapReduce Tutorial now!

CTA

7. Explain the difference between NameNode, Checkpoint NameNode, and Backup Node.
  • NameNode is the core of HDFS that manages the metadata—the information of which file maps to which block locations and which blocks are stored on which DataNode. In simple terms, it’s the data about the data being stored. NameNode supports a directory tree-like structure consisting of all the files present in HDFS on a Hadoop cluster. It uses the following files for namespace:
      • fsimage file: It keeps track of the latest Checkpoint of the namespace.
      • edits file: It is a log of changes that have been made to the namespace since Checkpoint.
  • Checkpoint NameNode has the same directory structure as NameNode and creates Checkpoints for namespace at regular intervals by downloading the fsimage, editing files, and margining them within the local directory. The new image after merging is then uploaded to NameNode. There is a similar node like Checkpoint, commonly known as the Secondary Node, but it does not support the ‘upload to NameNode’ functionality.
  • Backup Node provides similar functionality as Checkpoint, enforcing synchronization with NameNode. It maintains an up-to-date in-memory copy of the file system namespace and doesn’t require getting hold of changes after regular intervals. The Backup Node needs to save the current state in-memory to an image file to create a new Checkpoint.

Go through this HDFS Tutorial to know how the distributed file system works in Hadoop!

8. What are the most common input formats in Hadoop?

There are three most common input formats in Hadoop:

  • Text Input Format: Default input format in Hadoop
  • KeyValue Input Format: Used for plain text files where the files are broken into lines
  • Sequence File Input Format: Used for reading files in sequence
9. Define DataNode. How does NameNode tackle DataNode failures?

DataNode stores data in HDFS; it is a node where actual data resides in the file system. Each DataNode sends a heartbeat message to notify that it is alive. If the NameNode does not receive a message from the DataNode for 10 minutes, the NameNode considers the DataNode to be dead or out of place and starts the replication of blocks that were hosted on that DataNode such that they are hosted on some other DataNode. A BlockReport contains a list of the all blocks on a DataNode. Now, the system starts to replicate what were stored in the dead DataNode.

The NameNode manages the replication of the data blocks from one DataNode to another. In this process, the replication data gets transferred directly between DataNodes such that the data never passes the NameNode.

You will find more on our Hadoop Community!

CTA

Watch this insightful video to learn more about Hadoop:

Top Hadoop Interview Questions and Answers Wish to Learn Hadoop? Click Here

Learn for free ! Subscribe to our youtube Channel.

10. What are the core methods of a Reducer?

The three core methods of a Reducer are as follows:

  1. setup(): This method is used for configuring various parameters such as input data size and distributed cache.
    public void setup (context)
  2. reduce(): Heart of the Reducer is always called once per key with the associated reduced task.
    public void reduce(Key, Value, context)
  3. cleanup(): This method is called to clean the temporary files, only once at the end of the task.
    public void cleanup (context)
11. What is a SequenceFile in Hadoop?

Extensively used in MapReduce I/O formats, SequenceFile is a flat file containing binary key–value pairs. The map outputs are stored as SequenceFile internally. It provides Reader, Writer, and Sorter classes. The three SequenceFile formats are as follows:

  1. Uncompressed key–value records
  2. Record compressed key–value records—only ‘values’ are compressed here
  3. Block compressed key–value records—both keys and values are collected in ‘blocks’ separately and compressed. The size of the ‘block’ is configurable

Want to know more about Hadoop? Read this extensive Hadoop Tutorial!

12. What is the role of a JobTracker in Hadoop?

A JobTracker’s primary function is resource management (managing the TaskTrackers), tracking resource availability, and task life cycle management (tracking the tasks’ progress and fault tolerance).

  • It is a process that runs on a separate node, often not on a DataNode.
  • The JobTracker communicates with the NameNode to identify data location.
  • It finds the best TaskTracker nodes to execute the tasks on the given nodes.
  • It monitors individual TaskTrackers and submits the overall job back to the client.
  • It tracks the execution of MapReduce workloads local to the slave node.

Go through the Hadoop Course in London to get a clear understanding of Hadoop!

13. What is the use of RecordReader in Hadoop?

Though InputSplit defines a slice of work, it does not describe how to access it. Here is where the RecordReader class comes into the picture, which takes the byte-oriented data from its source and converts it into record-oriented key–value pairs such that it is fit for the Mapper task to read it. Meanwhile, InputFormat defines this Hadoop RecordReader instance.

CTA

Watch this video on Hadoop from Intellipaat:

Top Hadoop Interview Questions and Answers Wish to Learn Hadoop? Click Here

Learn for free ! Subscribe to our youtube Channel.

14. What is Speculative Execution in Hadoop?

One limitation of Hadoop is that by distributing the tasks on several nodes, there are chances that few slow nodes limit the rest of the program. There are various reasons for the tasks to be slow, which are sometimes not easy to detect. Instead of identifying and fixing the slow-running tasks, Hadoop tries to detect when the task runs slower than expected and then launches other equivalent tasks as backup. This backup mechanism in Hadoop is speculative execution.

It creates a duplicate task on another disk. The same input can be processed multiple times in parallel. When most tasks in a job comes to completion, the speculative execution mechanism schedules duplicate copies of the remaining tasks (which are slower) across the nodes that are free currently. When these tasks are finished, it is intimated to the JobTracker. If other copies are executing speculatively, Hadoop notifies the TaskTrackers to quit those tasks and reject their output.

Speculative execution is by default true in Hadoop. To disable it, we can set mapred.map.tasks.speculative.execution and mapred.reduce.tasks.speculative.execution
JobConf options to false.

Are you interested in learning Hadoop from experts? Enroll in our Hadoop Course in Bangalore now!

15. What happens if you try to run a Hadoop job with an output directory that is already present?

It will throw an exception saying that the output file directory already exists.

To run the MapReduce job, you need to ensure that the output directory does not exist in the HDFS.

To delete the directory before running the job, we can use shell:

Hadoop fs –rmr /path/to/your/output/

Or the Java API:

FileSystem.getlocal(conf).delete(outputDir, true);
16. How can you debug Hadoop code?

First, we should check the list of MapReduce jobs currently running. Next, we need to see that there are no orphaned jobs running; if yes, we need to determine the location of RM logs.

  1. Run:
    ps –ef | grep –I ResourceManager

    Then, look for the log directory in the displayed result. We have to find out the job ID from the displayed list and check if there is any error message associated with that job.

  2. On the basis of RM logs, we need to identify the worker node that was involved in the execution of the task.
  3. Now, we will login to that node and run the below code:
    ps –ef | grep –iNodeManager
  4. Then, we will examine the Node Manager log. The majority of errors come from the user-level logs for each MapReduce job.
17. How to configure Replication Factor in HDFS?

The hdfs-site.xml file is used to configure HDFS. Changing the dfs.replication property in hdfs-site.xml will change the default replication for all the files placed in HDFS.
We can also modify the replication factor on a per-file basis using the below:

Hadoop FS Shell:[training@localhost ~]$ hadoopfs –setrep –w 3 /my/fileConversely,

We can also change the replication factor of all the files under a directory.

[training@localhost ~]$ hadoopfs –setrep –w 3 -R /my/dir

Learn more about Hadoop from this Big Data Hadoop Training in New York to get ahead in your career!

CTA

18. How to compress a Mapper output not touching Reducer output?

To achieve this compression, we should set:

conf.set("mapreduce.map.output.compress", true)
conf.set("mapreduce.output.fileoutputformat.compress", false)
19. What is the difference between Map-side Join and Reduce-side Join?

Map-side Join at Map side is performed when data reaches the Map. We need a strict structure for defining Map-side Join. On the other hand, Reduce-side Join (Repartitioned Join) is simpler than Map-side Join since here the input datasets need not be structured. However, it is less efficient as it will have to go through sort and shuffle phases, coming with network overheads.

20. How can you transfer data from Hive to HDFS?

By writing the query:

hive> insert overwrite directory '/' select * from emp;

We can write our query for the data we want to import from Hive to HDFS. The output we receive will be stored in part files in the specified HDFS path.

21. Which companies use Hadoop?

Yahoo! (it is the biggest contributor to the creation of Hadoop; its search engine uses Hadoop); Facebook (developed Hive for analysis); Amazon; Netflix; Adobe; eBay; Spotify; Twitter; and Adobe.

Learn how Big Data and Hadoop have changed Disruptive Innovation in this blog post!

CTA

Hadoop Interview Questions

24 thoughts on “Top Hadoop Interview Questions and Answers”

  1. Very Good IQA. I am going to start facing interviews soon for hadoop development. Now I can say I am prepared for my interview round.

  2. Thanks Intellipaat for providing these questions and I see most of the questions present here was asked to me at TCS interview which I faced last week and which made me answer them to the point. Keep doing the good work and help the community to grow !

  3. Thanks to author for sharing such a good collection of hadoop interview questions. I want a suggestion that from where I have to prepare for CCDH. I learned Hadoop recently and now I want to take Cloudera Certification.

  4. Excellent work….
    I think 70 % of questions are being asked most commonly in interviews..
    great to get with the right answers.

  5. Hi ,
    Nice interview question.
    can you tell me what is the syllabus of hadoop certification
    and what i should do for certification .
    please suggest me.

Leave a Reply

Your email address will not be published. Required fields are marked *

Interview Questions

p get_sidebar('iq'); ?>