Spark Streaming with Kafka - Meetup Bangalore

download Spark Streaming with Kafka - Meetup Bangalore

of 21

Embed Size (px)

Transcript of Spark Streaming with Kafka - Meetup Bangalore

  1. 1. Tale of Kafka Consumer for Spark Streaming by Dibyendu Bhattacharya
  2. 2. What we do at Pearson
  3. 3. Anatomy of Kafka Cluster..
  4. 4. Spark in a Slide..
  5. 5. Spark + Kafka
  6. 6. Spark + Kafka 1. Streaming application uses Streaming Context which uses Spark Context to launch Jobs across the cluster. 2. Receivers running on Executors process 3. Receiver divides the streams into Blocks and writes those Blocks to Spark BlockManager. 4. Spark BlockManager replicates Blocks 5. Receiver reports the received blocks to Streaming Context. 6. Streaming Context periodically (every Batch Intervals ) take all the blocks to create RDD and launch jobs using Spark context on those RDDs. 7. Spark will process the RDD by running tasks on the blocks. 8. This process repeats for every batch intervals.
  7. 7. Failure Scenarios.. Receiver failed Driver failed Data Loss in both cases ?
  8. 8. Failure Scenarios..Receiver Un-Reliable Receiver Need a Reliable Receiver
  9. 9. Kafka Receivers.. Reliable Receiver can use .. Kafka High Level API ( Spark Out of the box Receiver ) Kafka Low Level API (part of Spark-Packages) High Level Kafka API has SERIOUS issue with Consumer Re- Balance...Can not be used in Production
  10. 10. Low Level Kafka Receiver Challenges Consumer implemented as Custom Spark Receiver which need to handle .. Consumer need to know Leader of a Partition. Consumer should aware of leader changes. Consumer should handle ZK timeout. Consumer need to manage Kafka Offset. Consumer need to handle various failovers.
  11. 11. Low Level Receiver..
  12. 12. Failure Scenarios..Driver Need to enable WAL based recovery Data which is buffered but not processed are lost ...why ?
  13. 13. Zero Loss using Receiver Based approach..
  14. 14. Direct Kafka Stream Approach ..Experimental
  15. 15. Direct Kafka Stream Approach ..need to mature Where to Store the Offset details ? Checkpoint is default mechanism . Has issue with checkpoint recoverability . Offset in external store . Complex and manage own recovery Offset saved to external store can only be possible , when you get offset details from the Stream.
  16. 16. Some pointers on Low Level Receiver Rate limiting by size of messages , not by number of messages Can save ZK offset to different Zookeeper node than the one manage the Kafka cluster. Can handle ALL failure recovery . Kafka broker down. Zookeeper down. Underlying Spark Block Manager failure. Offset Out Of Range issues. Ability to Restart or Retry based on failure scenarios.
  17. 17. dibbhatt/kafka-spark-consumer Date Rate : 1MB/250ms per Receiver
  18. 18. dibbhatt/kafka-spark-consumer Date Rate : 5MB/250ms per Receiver
  19. 19. dibbhatt/kafka-spark-consumer Date Rate : 10MB/250ms per Receiver
  20. 20. Direct Stream Approach
  21. 21. Thank You !