end to end exactly once aggregation over ad streams
play

End-to-end Exactly-once Aggregation over Ad Streams Amiraj Dhawan - PowerPoint PPT Presentation

End-to-end Exactly-once Aggregation over Ad Streams Amiraj Dhawan Amit Ramesh Yelps Mission Connecting people with great local businesses. Outline Background & context Business requirements Design


  1. End-to-end Exactly-once Aggregation over Ad Streams Amiraj Dhawan Amit Ramesh

  2. Yelp’s Mission Connecting people with great local businesses.

  3. Outline ● Background & context ● Business requirements ● Design iterations ● Exactly-once aggregation ● What’s next?

  4. Local Ads ● Work done within the Local Ads group ● Manage a few 100K ad campaigns daily ● Mom and pop stores to national chains ● Pipelines receive a few thousand msgs/sec ● Pipelines in production for more than a year

  5. Local Ads – Consumer facing

  6. Local Ads – Advertiser facing

  7. Local Ads – Ad Campaign Management

  8. Distilled Business Requirements ● Aggregate events over a day period ● Slice aggregates along defined dimensions ● Provide partial aggregates as day progresses ● Make aggregates as accurate as possible Day Dimension Dimension Dimension Aggregate Aggregate Aggregate 1 2 N 1 2 M

  9. An Illustrative Example ● Count ad clicks over a day period ● Provide click counts by ad campaign ● Provide partial click counts as day progresses Day Campaign ID Number of clicks Day Campaign ID Number of clicks 4/17/2019 23265 35 4/17/2019 23265 42

  10. Stream Processing 101 Input Stream(s) Output Stream(s) Stream Processing Engine Database

  11. Stream Processing 101 Input Stream(s) Output Stream(s) Stream Processing Engine Database

  12. Windowed operations Tumbling window Sliding window

  13. Why not... ∑ Processing pipeline Day Campaign ID Number of clicks 4/17/2019 23265 35

  14. Why not... ∑ Processing pipeline Day Campaign ID Number of clicks 4/17/2019 23265 35 ● Need partial click counts as day progresses! ● Stateful operation

  15. How about... ∆’s Processing pipeline Day Campaign ID Number of clicks 4/17/2019 23265 35

  16. How about... ∆’s Processing pipeline Day Campaign ID Number of clicks 4/17/2019 23265 35 ● Cassandra has a Counter column type ● Integer type with increment and decrement

  17. However... ● Counter is not meant to be idempotent ● Good for approximate metrics (likes/follows) ● Reported discrepancies of up to 5% ● Discrepancies due to being distributed ● No plans to make it idempotent

  18. Alright... ∑ t ∑ t + ∆ Processing pipeline Day Campaign ID Number of clicks 4/17/2019 23265 35 ● Use Cassandra for the current count ● Increment in Spark and update Cassandra

  19. Kafka 101 Partitions ● Data is in partitions 10 9 8 7 6 5 4 3 2 1 0 ● Partition is ordered Offsets 10 9 8 7 6 5 4 3 2 1 0 ● Consumers track their own progress 10 9 8 7 6 5 4 3 2 1 0

  20. Spark Streaming 101 ● Micro-batching ● No pipelining ● App manages offset commits

  21. Putting them together Kafka Offset Commit Stage 1 Stage 3 Stage 2 ∆ ∑ t + ∆ ∑ t ∑ t ∑ t + ∆

  22. In the words of Ken Arnold Failure is the defining difference between distributed and local programming, so you have to design distributed systems with the expectation of failure. Imagine asking people, "If the probability of something happening is one in ten to the thirteenth, how often would it happen?" Your natural human sense would be to answer, "Never." That is an infinitely large number in human terms. But if you ask a physicist, she would say, "All the time. In a cubic foot of air, those things happen all the time." When you design distributed systems, you have to say, "Failure happens all the time." So when you design, you design for failure. It is your number one concern.

  23. Failure Modes Kafka Offset Commit Stage 1 Stage 3 Stage 2 ∆ ∑ t + ∆ ∑ t ∑ t ∑ t + ∆

  24. Failure Modes Kafka Offset Commit Stage 1 Stage 3 Stage 2 ∆ ∑ t + ∆ ∑ t ∑ t ∑ t + ∆

  25. Failure Modes Kafka Offset Commit Stage 1 Stage 3 Stage 2 ∆ ∑ t + ∆ ∑ t ∑ t ∑ t + ∆

  26. Failure Modes Kafka Offset Commit Stage 1 Stage 3 Stage 2 ∆ ∑ t + ∆ ∑ t ∑ t ∑ t + ∆

  27. At Least + At Most = Exactly-once ● Should be able to distinguish processed data ● Versioning rows is one way to do it ● Versions need to be monotonically increasing ● Data in Kafka partitions are already ordered ● Versioning can leverage data order

  28. Basic Idea Day Campaign Number of Version ID clicks 4/17/2019 5 3 2 Offset 5 4 3 2 1 0 ID: 5 ID: 5 ID: 5 ID: 5 ID: 5 ID: 5 CLK CLK CLK CLK Commit

  29. Basic Idea Day Campaign Number of Version ID clicks 4/17/2019 5 1 2 4/17/2019 9 2 1 Offset 5 4 3 2 1 0 ID: 5 ID: 9 ID: 5 ID: 5 ID: 9 ID: 9 CLK CLK CLK CLK Commit

  30. Basic Idea 5 4 3 2 1 0 ID: 5 ID: 9 ID: 9 ID: 5 ID: 5 ID: 9 CLK CLK CLK CLK Day Campaign Number of Version ID clicks Partition 0 4/17/2019 5 2 P0: 2 P1: 3 5 4 3 2 1 0 4/17/2019 9 3 P0: 0 P1: 1 ID: 5 ID: 9 ID: 5 ID: 5 ID: 9 ID: 9 CLK CLK CLK CLK Partition 1

  31. Exactly-once Aggregation Kafka Offset Commit Stage 2 Stage 3 Stage 1 Ver ∆ ∑ t + ∆ , ∑ t , Ver t Ver t+1 ∑ t ∑ t , Ver t ∑ t + ∆ , Ver t+1

  32. Exactly-once Aggregation Kafka Offset Commit Stage 2 Stage 3 Stage 1 Ver ∆ ∑ t + ∆ , ∑ t , Ver Ver t+1 ∑ t ∑ t , Ver t ∑ t + ∆ , Ver t+1

  33. Exactly-once Aggregation Kafka Offset Commit Stage 2 Stage 3 Stage 1 Ver ∆ ∑ t + ∆ , ∑ t , Ver Ver t+1 ∑ t ∑ t , Ver t ∑ t + ∆ , Ver t+1

  34. Exactly-once Aggregation Kafka Offset Commit Stage 2 Stage 3 Stage 1 Ver ∆ ∑ t + ∆ , ∑ t , Ver Ver t+1 ∑ t ∑ t , Ver t ∑ t + ∆ , Ver t+1

  35. Exactly-once Aggregation Kafka Offset Commit Stage 2 Stage 3 Stage 1 Ver ∆ ∑ t + ∆ , ∑ t , Ver Ver t+1 ∑ t ∑ t , Ver t ∑ t + ∆ , Ver t+1

  36. Generalization ● Aggregation logic is in the pipeline ● Logic can be arbitrarily complex ● Does not have to be a mathematical function ● Strings, sets, lists, maps, etc.

  37. What’s next? ● Windowed joins ○ As a specialization of aggregation ○ Allows for arbitrary business rules in joins ● Deduplication within aggregation ○ Input streams can typically have duplicates

  38. We're Hiring! www.yelp.com/careers/

  39. fb.com/YelpEngineers @YelpEngineering engineeringblog.yelp.com github.com/yelp

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend