Hadoop Vs. Spark Or Can They Co-exist?

Every year the number of distributed systems in the market keeps increasing. These systems are in great demand to manage data volume, variety and volume. Apache Hadoop and Spark are the two most popular distributed system used for big data. But deciding between the two is a tough decision.

Hadoop VS Spark is a big debate with Google getting endless queries as they both are a great system. But it is not that simple to compare and choose one. It is because Hadoop and Spark can work together too when Spark’s processing data sits in Hadoop’s file system.

Then, how to decide between one of them? For this purpose, in this blog, we talk about their pros and cons and also how they can work in synergy.

It will help enlighten you about the two. Once armed with enough knowledge, according to your needs you can choose one.

Apache Hadoop – An Introduction

Initially, in 2006, Hadoop was a Yahoo project, but later on, it became a top-level Apache open-source project.

Apache Hadoop is a general-purpose form of distributed processing. It has several components like the Hadoop Distributed File System (HDFS). The HDFS stores files in a format native to Hadoop. The other main components of Hadoop are YARN and MapReduce. The first one is a scheduling tool for coordinating the runtime of applications. The latter is an algorithm that actually processes the data.

It is built in Java while you can access it using a variety of other languages like Python.

Other components are Sqoop, Hive, and Mahout.

Apache Hadoop is open-source if you use it through Apache distribution. Also, you can get it through vendors like Cloudera (Largest Hadoop vendor), MapR and HortonWorks.

Apache Hadoop

Apache Spark – An Introduction

Apache Spark is a new project developed in 2012 at the AMPLab. This top-level Apache project focuses on data processing in parallel across a cluster. The biggest difference between Apache Hadoop and Spark is that the later works in-memory. It was developed to handle the shortcoming of Hadoop MapReduce. The shortcoming was the speed of processing and Spark can do it 100 times faster than MapReduce.

Spark Core creates the structure of Spark. It is the engine driving the scheduling, optimizations, and RDD abstraction.

Numerous libraries operate on top of Spark Core which includes Spark SQL. It lets you run SQL-like commands on distributed data sets, GraphX for graph problems, MLLib for machine learning and much more.

There are endless APIs for Spark. Scala was used for writing its original interface. Other languages that you can use for Spark projects are Java, Python and R endpoints.

The creator of Spark Matei Zaharia owns a company named Databricks. It sees the distribution of Spark nowadays.

Statistics Regarding Spark and Hadoop

Statistics of Spark and Hadoop

Hadoop VS Spark -Read and Write Files

Apache Hadoop uses HDFS to read and write files. While Spark uses RAM for the same with the help of a concept known as an RDD( Resilient Distributed Dataset).

Hadoop VS Spark –Architecture

  • Hadoop:

The system passes all the files into HDFS, which are split into blocks then. Then, it reproduces each block a specific number of times. The repetition happens across the cluster, and this is based on a configured block size and replication factor. After that, it passes the data to the NameNode. The NameNode job is to keep track of everything across the cluster. After this, the NameNode assigns each file to a number of data nodes.

Hadoop’s MapReduce algorithm works on top of HDFS and it consists of a JobTracker.  First, the Hadoop developer writes an application in one of the languages accepted by Apache Hadoop. After that, the JobTracker picks it up and assigns works to TaskTrackers that listen to other nodes.

Next, YARN assigns resources and monitors them. Also, it keeps moving the processes around for better efficiency. Lastly, the results from the MapReduce phase and after that they aggregated for writing back to disk in HDFS.

  • Spark

Spark mostly works similar to Hadoop except that, Spark runs and store computations in memory. First, Spark reads data from a file on HDFS, S3, and so on into the SparkContext. Then, Spark creates a structure known as Resilient Distributed Dataset. The RDD represents a collection of elements which you can operate on simultaneously.

Simultaneous to the creation of RDD, Spark creates a DAG or Directed Acyclic Graph. It visualizes operations order and their relationships. Every DAG has steps and stage similar to SQL. On the RDD, if necessary you can perform many functions. Then, the result of every transformation is sent into the DAG.

get free consultation

Hadoop VS Spark- Performance

Spark speed performance is much better than Apache Hadoop. Spark runs 100 times faster in-memory and 10 times quicker on disk. Also, it sorts 100 TB of data quickly than Hadoop MapReduce by 3-times fast on one-tenth of the machines. Sparks works even best and fast on Machine learning applications.

Thus, the performance of Spark is optimal than Hadoop due to several reasons like:

It doesn’t restrict itself over input-output concerns every time a part of MapReduce task is run on it.

Sparks is faster for applications

Hadoop has no connection between MapReduce steps which means no performance turn around can happen.

But Hadoop is more efficient when it comes for a batch-processing use-case. The reason is that if Spark is running on YARN with other services, the RAM overheats and causes memory leaks.

Hadoop VS Spark- Cost

Apache Hadoop and Spark are free as open-source projects. So, there is no installation cost for both.

But you have to consider the total ownership cost which includes the cost of maintenance, hardware and software purchases. Also, you would require a team of Spark and Hadoop developers that know about cluster administration.

The pre-requisite for installing these two means more memory for Hadoop and more RAM for Spark. It means setting up the Spark cluster is more expensive than Hadoop.

Another point that makes Spark expensive is the fact that it is a newer system. That is why finding experts for this rare and costly.

Extract pricing comparisons between big data Hadoop and Spark is difficult. The reason is that both these distributed systems run in tandem.

But to make sure you make the right choice, let’s assume that you use a computer-optimized EMR cluster for Hadoop. The cost for the same will be $0.026 per hour (For a small version). While choosing the same for Spark would cost $0.067 per hour.

That means, that if you take the per hour cost, Spark is more expensive than Hadoop.

Hadoop VS Spark- Fault-Tolerant

Apache Hadoop is highly fault-tolerant as it was designed specifically to reproduce data across many nodes. In Hadoop, each big data file is broken into blocks and copied across numerous machines. It ensures that Hadoop developers can rebuild the file using any block in case a single machine breaks down.

Spark’s fault tolerance is slightly low than Hadoop. But you can achieve it through RDD operations. With the RDD, you also get a lineage. It remembers the construction of the data and that it helps it to rebuild the data from scratch if needed.

Another way, Spark can rebuild data is through data nodes.

bigdata hadoop

Hadoop VS Spark- Security

Through support from Kerberos authentication, both Spark and Hadoop provide great security.

But Apache Hadoop has more security for HDFS.  It uses Apache Sentry that enforces fine-grained metadata access.

Spark’s has scarce security as of now but provides enough security through its shared sheets.

Can Apache Hadoop And Spark Work Together In Synergy?

Yes, they can. Let’s read on if they can work together and how. Apache Hadoop has an ecosystem which includes HDFS, Apache Query and HIVE. Now, keeping this mind, let’s see how they work together.

HDFS + Apache Spark

The function of Apache Spark is to process data. In order to process data, the engine needs to take the data from storage. For this, it uses HDFS, true it’s not the only option available, but it’s popular. The reason is that they both are highly compatible since Apache is the brain behind them.

Apache Hive + Apache Spark

With the combination of Apache Spark and Apache Hive can solve many business problems. Let’s understand this from an example by assuming a business that analyzes customer behavior. For this, the company will accumulate data from multiple sources like clickstream data, comments, and social media, customer mobile apps and so on.

The company will choose HDFS to store data and Apache Hive as an intermediary between HDFS and Spark. Then, Apache Hive will make it possible question the data. The result is that Spark with support from Hive easily accesses the data and process it. In the end, the company is able to understand the preferences and behavior of its customers.

Examples Of Spark And Apache Hadoop Working Together

There are many real-life experiences where Apache Hadoop and Spark came together to build great applications. Here are some apps that use both these for their storing their big data:


The app uses Spark and Hadoop both to provide a seamless experience to their users. With these two distributed systems, two features were introduced by TripAdvisor- Auto-tagging and photo selection.


To process the big data of their consumer, Uber uses a combination of Spark and Hadoop. To provide drivers in a particular time and location, it uses real-time traffic situation. And for this, Uber makes use of HDFS for loading raw data onto Hive and Spark is used for processing of millions of events.


We read the difference between Hadoop VS Spark and also how the two can work together. The choice between using these two prominent distributed systems rests on your choice and project needs. Remember, Hadoop and Spark are both projects of Apache for processing big data, so don’t worry about their quality.

The only thing you should do is weigh their features against your need and then choose the right one.

hadoop solutions

Share post
©2019 Endive Software Private Limited. All Rights Reserved.

Connected with Us: