Slide 1

Slide 1 text

REAL-TIME ANALYTICS WITH OPEN SOURCE TECHNOLOGIES KAFKA · HADOOP · STORM · DRUID FANGJIN YANG · GIAN MERLINO SOFTWARE ENGINEERS @ METAMARKETS

Slide 2

Slide 2 text

PROBLEM DEALING WITH EVENT DATA MOTIVATION EVOLUTION OF A “REAL-TIME” STACK ARCHITECTURE THE “RAD”-STACK NEXT STEPS TRY IT OUT FOR YOURSELF OVERVIEW

Slide 3

Slide 3 text

THE PROBLEM

Slide 4

Slide 4 text

2013 Fangjin Yang 2013

Slide 5

Slide 5 text

2013 Fangjin Yang 2013

Slide 6

Slide 6 text

2013 Fangjin Yang 2013

Slide 7

Slide 7 text

2013 Fangjin Yang 2013 Event Stream

Slide 8

Slide 8 text

2013 Fangjin Yang 2013 Event Stream

Slide 9

Slide 9 text

2013 Fangjin Yang 2013 ...AND WE ANALYZE DATA WE ARE METAMARKETS...

Slide 10

Slide 10 text

2013 THE PROBLEM ‣ Arbitrary and interactive exploration ‣ Multi-tenancy: thousands of concurrent users ‣ Recency matters! Alert on major changes ‣ Scalability & Availability

Slide 11

Slide 11 text

2013 A SOLUTION ‣ Load all your data into Hadoop. Query it. Done! ‣ Good job guys, let’s go home

Slide 12

Slide 12 text

2013 FINDING A SOLUTION Hadoop Event Streams Insight

Slide 13

Slide 13 text

2013 PROBLEMS OF THE NAIVE SOLUTION ‣ MapReduce can handle almost every distributed computing problem ‣ MapReduce over your raw data is flexible but slow ‣ Hadoop is not optimized for query latency ‣ To optimize queries, we need a query layer

Slide 14

Slide 14 text

2013 FINDING A SOLUTION Hadoop Query Engine Hadoop Event Streams Insight

Slide 15

Slide 15 text

A FASTER QUERY LAYER

Slide 16

Slide 16 text

2013 MAKE QUERIES FASTER ‣ What types of queries to optimize for? • Revenue over time broken down by demographic • Top publishers by clicks over the last month • Number of unique visitors broken down by any dimension • Not dumping the entire dataset • Not examining individual events

Slide 17

Slide 17 text

2013 FINDING A SOLUTION Hadoop RDBMS Hadoop Event Streams Insight

Slide 18

Slide 18 text

2013 FINDING A SOLUTION Hadoop NoSQL K/V Stores Hadoop Event Streams Insight

Slide 19

Slide 19 text

2013 FINDING A SOLUTION Hadoop Commercial Databases Hadoop Event Streams Insight

Slide 20

Slide 20 text

DRUID AS A QUERY ENGINE

Slide 21

Slide 21 text

2013 DRUID ‣ Druid project started in 2011 ‣ Open sourced in Oct. 2012 ‣ Growing Community • ~40 contributors from many different organizations ‣ Designed for low latency ingestion and aggregation • Optimized for the types of queries we were trying to make

Slide 22

Slide 22 text

2013 RAW DATA timestamp publisher advertiser gender country click price! 2011-01-01T01:01:35Z bieberfever.com google.com Male USA 0 0.65! 2011-01-01T01:03:63Z bieberfever.com google.com Male USA 0 0.62! 2011-01-01T01:04:51Z bieberfever.com google.com Male USA 1 0.45! ...! 2011-01-01T01:00:00Z ultratrimfast.com google.com Female UK 0 0.87! 2011-01-01T02:00:00Z ultratrimfast.com google.com Female UK 0 0.99! 2011-01-01T02:00:00Z ultratrimfast.com google.com Female UK 1 1.53

Slide 23

Slide 23 text

2013 ROLLUP DATA timestamp publisher advertiser gender country impressions clicks revenue! 2011-01-01T01:00:00Z ultratrimfast.com google.com Male USA 1800 25 15.70! 2011-01-01T01:00:00Z bieberfever.com google.com Male USA 2912 42 29.18! 2011-01-01T02:00:00Z ultratrimfast.com google.com Male UK 1953 17 17.31! 2011-01-01T02:00:00Z bieberfever.com google.com Male UK 3194 170 34.01 ‣ Truncate timestamps ‣ GroupBy over string columns (dimensions) ‣ Aggregate numeric columns (metrics)

Slide 24

Slide 24 text

2013 PARTITION DATA timestamp publisher advertiser gender country impressions clicks revenue! ! ! ! 2011-01-01T01:00:00Z ultratrimfast.com google.com Male USA 1800 25 15.70! 2011-01-01T01:00:00Z bieberfever.com google.com Male USA 2912 42 29.18! ! ! ! ! 2011-01-01T02:00:00Z ultratrimfast.com google.com Male UK 1953 17 17.31! 2011-01-01T02:00:00Z bieberfever.com google.com Male UK 3194 170 34.01! ! ‣ Shard data by time ‣ Immutable chunks of data called “segments” ! ! Segment 2011-01-01T02/2011-01-01T03 ! ! Segment 2011-01-01T01/2011-01-01T02

Slide 25

Slide 25 text

2013 IMMUTABLE SEGMENTS ‣ Fundamental storage unit in Druid ‣ Read consistency ‣ One thread scans one segment ‣ Multiple threads can access same underlying data ‣ Segment sizes -> computation completes in ms ‣ Simplifies distribution & replication

Slide 26

Slide 26 text

2013 COLUMN ORIENTATION timestamp publisher advertiser gender country impressions clicks revenue! ! ! ! 2011-01-01T01:00:00Z ultratrimfast.com google.com Male USA 1800 25 15.70! 2011-01-01T01:00:00Z bieberfever.com google.com Male USA 2912 42 29.18! ! ‣ Scan/load only what you need ‣ Compression! ‣ Indexes!

Slide 27

Slide 27 text

2013 ARCHITECTURE (EARLY DAYS) Broker Node Historical Node Historical Node Historical Node Broker Node Queries Hadoop Data

Slide 28

Slide 28 text

2013 MORE PROBLEMS ‣ We’ve solved the query problem • Druid gave us arbitrary data exploration & fast queries ‣ What about data freshness? • Batch loading is slow! • We need “real-time” • Alerts, operational monitoring, etc.

Slide 29

Slide 29 text

A FASTER DATA PIPELINE

Slide 30

Slide 30 text

2013 THE STORY SO FAR Hadoop Druid Hadoop Event Streams Insight

Slide 31

Slide 31 text

2013 THE STORY SO FAR ‣ Clients uploaded data to S3 ‣ We used Hadoop + Pig to clean it up, transform, and join it ‣ We loaded the result into Druid ‣ Typical turnaround time: 2–8 hours

Slide 32

Slide 32 text

2013 INGESTION DELAYS ‣ Let’s build a streaming version of this data pipeline ‣ Three obstacles ‣ Acquiring raw data ‣ Processing the data ‣ Loading processed data into Druid

Slide 33

Slide 33 text

2013 FAST DELIVERY WITH KAFKA ‣ High throughput event delivery service ‣ Straightforward, reliable design ‣ Buffers incoming data to give consumers time to process it ‣ We can place an HTTP API in front of this

Slide 34

Slide 34 text

2013 FAST DELIVERY WITH KAFKA Kafka Brokers Producer Producer Producer Consumer Consumer Consumer

Slide 35

Slide 35 text

2013 FAST PROCESSING WITH STORM ‣ Storm is a stream processor— one event at a time ‣ We can already process our data using Hadoop MapReduce ‣ Let’s translate that to streams ‣ “Load” operations stream data from Kafka ‣ “Map” operations are already stream-friendly ‣ “Reduce” operations can be windowed with partitioned state

Slide 36

Slide 36 text

2013 FAST LOADING WITH DRUID ‣ We have an indexing system ‣ We have a serving system that runs queries on data ‣ We can serve queries while building indexes! ‣ Real-time indexing workers do this

Slide 37

Slide 37 text

2013 FAST LOADING WITH DRUID Druid Realtime Workers Immediate Druid Historical Cluster Periodic Druid Query Broker Kafka Brokers Storm Workers

Slide 38

Slide 38 text

2013 THE STORY SO FAR Hadoop Druid Hadoop Event Streams Insight Kafka Storm Druid

Slide 39

Slide 39 text

2013 WHAT WE GAINED ‣ Druid queries reflect new events within seconds ‣ Systems are fully decoupled ‣ Brief processing delays during maintenance ‣ Because we need to restart Storm topologies ‣ But query performance and availability are not affected

Slide 40

Slide 40 text

2013 WHAT WE GAVE UP ‣ Stream processing isn’t perfect ‣ Difficult to handle corrections of existing data ‣ Windows may be too small for fully accurate operations ‣ Hadoop was actually good at these things

Slide 41

Slide 41 text

2013 THE RETURN OF HADOOP ‣ An open-source “lambda architecture” ‣ Batch re-processing runs for all data older than a few hours ‣ Batch segments replace real-time segments in Druid ‣ Query broker merges results from both systems “Fixed up,” immutable, historical data –by Hadoop Realtime data –by Storm & Realtime Druid

Slide 42

Slide 42 text

2013 THE STACK Event Streams Insight Kafka Hadoop Druid Storm ‣ Real-time ‣ Only on-time data ‣ Some hours later ‣ All data

Slide 43

Slide 43 text

DO TRY THIS AT HOME

Slide 44

Slide 44 text

2013 CORNERSTONES ‣ Druid - druid.io - @druidio ‣ Storm - storm.incubator.apache.org - @stormprocessor ‣ Hadoop - hadoop.apache.org ‣ Kafka - kafka.apache.org - @apachekafka

Slide 45

Slide 45 text

2013 GLUE Event Streams Insight Kafka Hadoop Druid Storm storm-kafka Camus Druid Tranquility

Slide 46

Slide 46 text

2013 GET RADICAL ‣ Queries answered quickly, on fresh data ‣ Kafka provides fast, reliable event transport ‣ Storm and Hadoop clean and prepare data for Druid ‣ Druid handles queries and manages the serving layer ‣ “Real-time Analytics Data Stack” ‣ …a.k.a. RAD Stack ‣ https://metamarkets.com/2014/building-a-data-pipeline/

Slide 47

Slide 47 text

THANK YOU @DRUIDIO @METAMARKETS