Fault tolerance in Apache Spark
Fault tolerance in Apache Spark

Fault tolerance in Apache Spark

We will see fault-tolerant stream processing with Spark Streaming and Spark RDD fault tolerance. We will also learn what is Spark Streaming write ahead log, Spark streaming driver failure, Spark streaming worker failure to understand how to achieve fault tolerance in Apache Spark.

Let us see Apache Spark installation on Ubuntu

Introduction to Fault Tolerance in Apache Spark

Before we start with learning what is fault tolerance in Apache Spark, let us revise concepts of Apache Spark for beginners.

Now let’s understand what is fault and how Spark handles fault tolerance.

Fault refers to failure, thus fault tolerance in Apache Spark is the capability to operate and to recover loss after a failure occurs. If we want our system to be fault tolerant, it should be redundant because we require a redundant component to obtain the lost data. The faulty data is recovered by redundant data.

 Spark RDD Fault Tolerance

Let us firstly see how to create RDDs in Spark? Spark operates on data in fault-tolerant file systems like HDFS or S3. So all the RDDs generated from fault tolerant data is fault tolerant. But this does not set true for streaming/live data (data over the network). So the key need of fault tolerance in Spark is for this kind of data. The basic fault-tolerant semantic of Spark are:

  • Since Apache Spark RDD is an immutable dataset, each Spark RDD remembers the lineage of the deterministic operation that was used on fault-tolerant input dataset to create it.
  • If due to a worker node failure any partition of an RDD is lost, then that partition can be re-computed from the original fault-tolerant dataset using the lineage of operations.
  • Assuming that all of the RDD transformations are deterministic, the data in the final transformed RDD will always be the same irrespective of failures in the Spark cluster.

To achieve fault tolerance for all the generated RDDs, the achieved data is replicated among multiple Spark executors in worker nodes in the cluster. This results in two types of data that needs to be recovered in the event of failure:

  • Data received and replicated – In this, the data gets replicated on one of the other nodes thus the data can be retrieved when a failure.
  • Data received but buffered for replication – The data is not replicated thus the only way to recover fault is by retrieving it again from the source.

Failure also occurs in worker as well as driver nodes.

  • Failure of worker node – The node which runs the application code on the Spark cluster is Spark worker node. These are the slave nodes. Any of the worker nodes running executor can fail, thus resulting in loss of in-memory If any receivers were running on failed nodes, then their buffer data will be lost.
  • Failure of driver node – If there is a failure of the driver node that is running the Spark Streaming application, then SparkContent is lost and all executors with their in-memory data are lost.

Apache Mesos helps in making the Spark master fault tolerant by maintaining the backup masters. It is open source software residing between the application layer and the operating system. It makes easier to deploy and manage applications in large-scale clustered environment. Executors are relaunched if they fail. Post failure, executors are relaunched automatically and spark streaming does parallel recovery by recomputing Spark RDD’s on input data. Receivers are restarted by the workers when they fail.

Fault Tolerance with Receiver-based sources

For input sources based on receivers, the fault tolerance depends on both- the failure scenario and the type of receiver. There are two types of receiver:

  • Reliable receiver – Once it is ensured that the received data has been replicated, the reliable sources are acknowledged. If the receiver fails, the source will not receive acknowledgment for the buffered data. So, the next time the receiver is restarted, the source will resend the data. Hence, no data will be lost due to failure.
  • Unreliable Receiver – Due to the worker or driver failure, the data can be lost since receiver does not send an acknowledgment.

Learn more about top 5 Apache Spark certifications for your Spark Career

Read complete Article>>

See Also-



Mike Frampton

IT Contractor - Currently Looking For Opportunites

7 å¹´

You mentioned mesos as a spark cluster manager but what about dcos ?

赞
回复
Piotr Czarnas

Founder @ DQOps open-source Data Quality platform | Detect any data quality issue and watch for new issues with Data Observability

7 å¹´

That is an interesting concept. We created our own support for a failover #Spark driver in #Querona. #Querona is a Data Virtualization engine and can use Spark or a whole cluster like Hortonworks HDP or Microsoft HDInsight for caching. When we deploy the driver on HDP or HDInsight, we are deploying and starting two drivers on both the head nodes (the active one and the passive). The drivers are sharing state by just using leader election code used by many other Hadoop applications - we are just sharing and monitoring a state in Zookeeper. Querona keeps connections to both drivers but only one driver actually starts a Spark context and executes queries on the cluster. In case of a node failure (for example when Azure was restarting a head node), one driver was just not reporting its state and the second driver was taking the "leader" role. Querona then resubmits the query and it is executed by the newly elected driver instance. So - when we compare it to this idea, we are not storing the state between executions but we just restart the execution. I am wondering how many projects actually have a failover driver architecture because we couldn't find any reference on the web when we were developing our solution.

Ram Chandra( Big Data Consultant )

Big data Solution Architect at Princeton

7 å¹´

Hi Malini, Thank you for your article , Here I could see one thing about replication factor.As per my knowledge Spark won't write the data in disk but it will be in-memory. So RDD it self recreate the data if it loss. Please correct me if I misunderstood. Thanks and Regards, Ram.

赞
回复
Mohit Sharma(OCAJP?,ITIL?,AWSSAA?,ELK?)

Technical Architect, ELK,Bigdata and AWS & Azure Cloud Services at Tata Consultancy Services

7 å¹´

Worth Reading !!????

要查看或添加评论,请登录

Malini Shukla的更多文章

社区洞察