Spark vs. Hadoop - All You Need To Know

Manu Jeevan

Last updated October 25, 2016

4482 Views

Spark and Hadoop are leading open source big data infrastructure frameworks that are used to store and process large data sets.

Since Spark’s introduction to the Apache Software Foundation in 2014, it has received massive interest from developers, enterprise software providers and independent software vendors looking to capitalize on its in-memory processing speed and cohesive, uniform APIs.

However, there is a hot debate on whether Spark can replace Hadoop to become the top big data analytics tool.

In this post, I have tried to explain the difference between Spark and Hadoop in a simple way so that anyone, even those without a background in computer science, can understand.

What is a Distributed Storage System

Even though Spark is said to work faster than Hadoop in certain circumstances, it doesn’t have its own distributed storage system. So first let’s understand the concept of distributed file system.

Distributed storage system lets you store large datasets across an infinite number of servers, rather than storing all the datasets on a single server.

When the amount of data increases, you can add as many servers as you want in the distributed storage system. This makes a distributed storage system scalable and cost efficient, because you are using additional hardware (servers) only when there is a demand.

How Spark and Hadoop process data

Spark does not have its own system to organize files in a distributed way(the file system). For this reason, programmers install Spark on top of Hadoop so that Spark’s advanced analytics applications can make use of the data stored using the Hadoop Distributed File System(HDFS). Hadoop has a file system that is much like the one on your desktop computer, but it allows us to distribute files across many machines. HDFS organizes information into a consistent set of file blocks and storage blocks for each node.

HDFS uses MapReduce to process and analyze data. MapReduce takes a back of all the data in a physical server after each operation. This was done because data stored in a RAM is volatile than that stored in a physical server.

In contrast, Spark copies most of the data from a physical server to a RAM memory, this is called as “in memory” operation. This reduces the time required to interact with servers and makes Spark faster than the Hadoop’s MapReduce system. Spark uses a system called Resilient Distributed Datasets to recover data when there is a failure.

Spark and Hadoop’s role in real time analytics

Real time processing means that the moment data is captured, it is fed into an analytical application, and the analytical application processes and analyses the data and delivers insights quickly to the user though a dashboard. So that the user can take necessary action based on insights provided by the application.

A good example for real-time streaming is a recommendation engine; similar products are shown based on your browsing history.

Now days, Spark is used in machine learning projects due to its ability to process real time data effectively.Machine learning is a subfield of artificial intelligence. It is a method of teaching computers to make and improve predictions or behaviors based on some data.

Spark has its own machine learning library called MLib, whereas Hadoop must be interfaced with external machine learning library, for example Apache Mahout.

As Spark is faster than Hadoop, it is well capable to handle advanced analytics operations like real time data processing when compared to Hadoop.

Why Spark and Hadoop are not competitors

Many big data professionals argue that “Spark is better than Hadoop” or “Hadoop is better than Spark”. In my opinion, both Hadoop and Spark are not competitors because Hadoop was designed to handle data that does not fit in the memory whereas Spark was designed to deal with data that fits in the memory.

Even Companies like Cloudera that gives installation and support services to open-source big data software delivers both Hadoop and Spark as services. These big data companies also help their clients to choose the best big data software depending on their needs.

For instance, If a corporation has a lot of structured data(customer names and email ids) in their database, they might not need advanced streaming analytics and machine learning capabilities provided by Spark. They need not waste time and money by installing Spark as a layer on top of their Hadoop Stack.

Conclusion

Although adoption of Spark has increased, it hasn’t caused any panic in the big data community. Experts predict that Spark would facilitate the growth of another stack, which could be much more powerful. But this new stack would be very similar to that of Hadoop and its ecosystem of software packages.

Simplicity and speed are the biggest advantage of Spark. Even if Spark is a big winner, unless there is new distributed file system, we will be using Hadoop alongside Spark for a complete big data package