Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Apache_Gearpump_-_Strata_Beijing_2016.pdf

Avatar for ManuZhang ManuZhang
November 07, 2016
3

 Apache_Gearpump_-_Strata_Beijing_2016.pdf

Avatar for ManuZhang

ManuZhang

November 07, 2016

Transcript

  1. What is Gearpump ? • An Akka[2] based real-time streaming

    engine • An Apache Incubator[1] project since Mar.8th, 2016 • A super simple pump that consists of only two gears but very powerful at streaming water
  2. Gearpump Architecture • Actor concurrency • Message passing communication •

    error handling and isolation with supervision hierarchy • Master HA with Akka Cluster
  3. Stream processing is hard but no system meets all requirements

    • Infinite data • Out-of-order data • Low latency assurance (e.g real-time recommendation) • Correctness requirement (e.g. charge advertisers for ads) • Cheap to update user logics
  4. How Gearpump solves the hard parts • User interface •

    Flow control • Out-of-order processing • Exactly once • Dynamic DAG
  5. Use case - Detect anomaly words 1. Words 3. W

    indow Counts 2. Window Counts 4. Models 5. Anom aly words KafkaSource WindowCounter ModelCalculator AnomalyDetector KafkaSink
  6. How Gearpump solves the hard parts • User Interface •

    Flow control • Out-of-order processing • Exactly Once • Dynamic DAG
  7. User Interface - DAG API Graph( KafkaSource ~ ShufflePartitioner ~>

    WindowCounter, WindowCounter ~ HashPartitioner ~> ModelCalculator, WindowCounter ~ HashPartitioner ~> AnomalyDetector, ModelCalculator ~> HashPartitioner ~> AnomalyDetector, AnomalyDetector ~> ShufflePartitioner ~> KafkaSink)
  8. partitioner User Interface - Partitioner Graph( KafkaSource ~ ShufflePartitioner ~>

    WindowCounter, WindowCounter ~ HashPartitioner ~> ModelCalculator, WindowCounter ~ HashPartitioner ~> AnomalyDetector, ModelCalculator ~ HashPartitioner ~> AnomalyDetector, AnomalyDetector ~ ShufflePartitioner ~> KafkaSink) WindowCounter (parallelism = 3) ModelCalculator (parallelism = 2) Task Task Task Task Task
  9. How Gearpump solves the hard parts • User interface •

    Flow control • Out-of-order processing • Exactly once • Dynamic DAG
  10. Flow Control 1. Words 3. W indow Counts 2. Window

    Counts 4. Models 5. Anom aly words KafkaSource WindowCounter ModelCalculator AnomalyDetector KafkaSink
  11. With Flow Control - Backpressure KafkaSource WindowCounter ModelCalculator Slow down

    Slow down Very Slow backpressure backpressure pull slower
  12. How Gearpump solves the hard parts • User Interface •

    Flow control • Out-of-order processing • Exactly Once • Dynamic DAG
  13. Out-of-order data Event time 3 2 1 Processing time •

    Event time - when data generated • Processing time - when data processed 1 2 3 4 5 6
  14. Window Count 1. Words 3. W indow Counts 2. Window

    Counts 4. Models 5. Anom aly words KafkaSource WindowCounter ModelCalculator AnomalyDetector KafkaSink
  15. When can window counts be emitted ? window messages count

    [0, 2) 1 [2, 4) 2 [4, 6) 2 (“gearpump”, 1) WindowCounter In-memory Table • No window can be emitted since message as early as time 1 has not arrived (“gearpump”, 1) (“gearpump”, 3) (“gearpump”, 5) (“gearpump”, 4) (“gearpump”, 2) WindowCounter
  16. On Watermark[4] Event time 3 2 1 Processing time 1

    2 3 4 5 6 watermark • No timestamp earlier than watermark will be seen
  17. Out-of-order processing with watermark window messages count [0, 2) 1

    [2, 4) 2 [4, 6) 2 (“gearpump”, 1) WindowCounter In-memory Table (“gearpump”, 1) (“gearpump”, 3) (“gearpump”, 5) (“gearpump”, 4) (“gearpump”, 2) WindowCounter watermark = 0, No window can be emitted
  18. Out-of-order processing with watermark window messages count [0, 2) 1

    [2, 4) 2 [4, 6) 2 (“gearpum p”, [0, 2), 1) WindowCounter In-memory Table (“gearpump”, 1) (“gearpump”, 3) (“gearpump”, 5) (“gearpump”, 4) (“gearpump”, 2) WindowCounter watermark = 2, Window [0, 2) can be emitted (“gearpump”, [0, 2), 1)
  19. How to get watermark ? 1. Words 3. W indow

    Counts 2. Window Counts 4. Models 5. Anom aly words KafkaSource WindowCounter ModelCalculator AnomalyDetector KafkaSink
  20. From upstream 1. Words 3. W indow Counts 2. Window

    Counts 4. Models 5. Anom aly words KafkaSource WindowCounter ModelCalculator AnomalyDetector KafkaSink watermark
  21. More on Watermark • Source watermark defined by user •

    Usually heuristic based • Users decide whether to drop data arriving after watermark
  22. How Gearpump solves the hard parts • User Interface •

    Flow control • Out-of-order processing • Exactly once • Dynamic DAG
  23. Exactly Once - no Lost or Duplicated States • Lost

    states can cause anomaly words skipped • Duplicated states can cause false alarm States 4. Models 5. Anom aly words KafkaSource WindowCounter ModelCalculator AnomalyDetector KafkaSink kafka_offset window_counts models
  24. (2, kafka_offset) (2, window_counts) Exactly Once with asynchronous checkpointing KafkaSource

    WindowCounter ModelCalculator Watermark = 2 Watermark = 2 Watermark = 0 (2, window_counts)
  25. (2, kafka_offset) (2, window_counts) (2, models) Exactly Once with asynchronous

    checkpointing KafkaSource WindowCounter ModelCalculator Watermark = 2 Watermark = 2 Watermark = 2 (2, models)
  26. (2, kafka_offset) (2, window_counts) (2, models) Exactly Once with asynchronous

    checkpointing KafkaSource WindowCounter ModelCalculator Watermark = 2 Watermark = 2 Watermark = 2 (2, models)
  27. (2, kafka_offset) (2, window_counts) (2, models) Recover to latest checkpoint

    at 2 KafkaSource WindowCounter ModelCalculator models window_counts kafka_offset Replay from kafka Get state at 2
  28. More on Exactly Once • User extends PersistentState interface and

    system checkpoints state for users automatically • Watermark is persisted on master
  29. How Gearpump solves the hard parts • User Interface •

    Flow control • Out-of-order processing • Exactly Once • Dynamic DAG
  30. Can we update model algorithm in a cheap way ?

    1. Words 3. W indow Counts 2. Window Counts 4. Models 5. Anom aly words KafkaSource WindowCounter ModelCalculator AnomalyDetector KafkaSink The model algorithm doesn’t perform well
  31. Yahoo! Streaming Benchmark • 4 node cluster • Each node

    has 32-core, 64 GB memory • 10GB Ethernet
  32. Apache Beam[6] Gearpump Runner Beam Model: Fn Runners Apache Flink

    Apache Spark Beam Model: Pipeline Construction Other Languages Beam Java Beam Python Execution Execution Cloud Dataflow Execution Apache Gearpump
  33. Experimental features • Web UI Authorization / OAuth2 Authentication •

    CGroup Resource Isolation • Binary Storm compatibility • Akka Streams integration
  34. Summary • Gearpump is good at streaming infinite out-of-order data

    and guarantees correctness • Gearpump helps users to easily program streaming applications, get runtime information and update dynamically
  35. What is Akka • Message driven • Shared nothing •

    Location transparent • Supervision based failure management • High performance Actor Actor Actor Actor Actor spawn