SlideShare a Scribd company logo
Batch and Stream processing
with SQL
2013/11/07 Cloudera World Tokyo 2013
TAGOMORI Satoshi @tagomoris
LINE Corp.
13年11月7日木曜日
SQL、宇宙、すべての答え

SELECT 42 FROM anywhere
13年11月7日木曜日
TAGOMORI Satoshi (@tagomoris)
LINE Corp.
Hadoop, Fluentd, Norikra, ...

13年11月7日木曜日
13年11月7日木曜日
13年11月7日木曜日
13年11月7日木曜日
Data Collecting,
Aggregation, Analytics,
Visualization

13年11月7日木曜日
SQL好きですか?

13年11月7日木曜日
How to write M/R
(or Storm app, or...)

Java (or Scala, Clojure, JRuby, ...)
Hadoop Streaming
Pig
Hive, Impala (SQL!)

13年11月7日木曜日
Our log traffic
Daily
2.1+ TB (non compressed)
6.8+ Billion lines / day
Peak time
150,000+ lines / sec
380+ Mbps
13年11月7日木曜日
Our Hadoop cluster
CDH 4.2.0
Master Nodes: 3 (NameNodeHA+QJM)
NameNode, JournalNode,
JobTracker
Slave Nodes: 20

13年11月7日木曜日
What we want to do
COUNT PV,UU and others (daily/realtime)
COUNT Service metrics (daily/hourly/realtime)
FIND Surprising Errors [4xx,5xx] (immediately)
CHECK Response Times (immediately)
SERCH Logs in troubles (hourly/immediately)
VISUALIZE/NOTIFY App Status (realtime)
13年11月7日木曜日
Batches and Streams
Hadoop is for batches
High performance batch is important
HDFS has good performance
Stream log writing and calculations
are also VERY VERY IMPORTANT
Hybrid System:
Stream processing + Batch
13年11月7日木曜日
System Overview
Web
Servers

Archive
Storage
(scribed)

Fluentd
Cluster

STREAM

Notifications
(IRC)

Fluentd
Watchers

Graph
Tools

Norikra
webhdfs

Hadoop Cluster
(HDFS, MR)

13年11月7日木曜日

hive
server
Huahin
Manager

BATCH

SCHEDULED
BATCH
Shib

ShibUI
Data analytics players
PROGRAMMER
Raw Log Formats
Application Logs
Data Sizes
Data Semantics

SERVICE DIRECTOR
SALES
Whatever Metrics They Want

Storages
Hadoop Cluster
Visualization Tools

ADMINISTRATOR

........

BOARD MEMBER
13年11月7日木曜日
Data analytics players
PROGRAMMER
Raw Log Formats
Application Logs
Data Sizes
Data Semantics

SERVICE DIRECTOR
SALES

WE NEED THE QUERY LANGUAGE
Whatever Metrics They Want
WHAT THEY ALL CAN
RUN AND UNDERSTAND!!!!!!!!!!

Storages
Hadoop Cluster
Visualization Tools

ADMINISTRATOR

........

BOARD MEMBER
13年11月7日木曜日
SQL: Hive

13年11月7日木曜日
SQL: Hive

13年11月7日木曜日
Hive
SQL: w/o compile, w/o deployment
HiveServer: w/o server login
Shib: Select only

13年11月7日木曜日
13年11月7日木曜日
Hive:
Simplify versioning problems
Hive 0.10 of CDH 4.2.0
Upgrade CDH for only Hive version

13年11月7日木曜日
Hive: Pros
Many
Scheduled Queries
Metrics
OnDemand Queries
13年11月7日木曜日
Hive: Cons
Too Many
Scheduled Queries
for short time window

13年11月7日木曜日
Stream processing
Queries for fixed Window
every 1hour, 10minutes, 1minutes, ...
latest 10evens, ...
all events

Once query registered, Runs forever
Results appear automatically

NO MORE STORAGES
13年11月7日木曜日
Stream processing
And

SQL
13年11月7日木曜日
Norikra:
Schema-less Stream
Processing with SQL
13年11月7日木曜日
Norikra(1):
Schema-less event stream:
Add/Remove data fields whenever you want

SQL:
No more restarts to add/remove queries
w/ JOINs, w/ SubQueries
w/UDF

Truly Complex events:
Nested Hash/Array, accessible directly from SQL
13年11月7日木曜日
Norikra(2):
Open source software:
Licensed under GPLv2
Based on Esper
UDF plugins from rubygems.org

Ultra-fast bootstrap & small start:
3mins to install/start
1 server

13年11月7日木曜日
Norikra Queries: (1)

SELECT name, age
FROM events

13年11月7日木曜日
Norikra Queries: (1)
{“name”:”tagomoris”,
“age”:34, “address”:”Tokyo”,
“corp”:”LINE”, “current”:”Meguro”}

SELECT name, age
FROM events

{“name”:”tagomoris”,”age”:34}
13年11月7日木曜日
Norikra Queries: (1)
{“name”:”tagomoris”,
“address”:”Tokyo”,
“corp”:”LINE”, “current”:”Meguro”}

SELECT name, age
FROM events

nothing

13年11月7日木曜日
Norikra Queries: (2)
{“name”:”tagomoris”,
“age”:34, “address”:”Tokyo”,
“corp”:”LINE”, “current”:”Meguro”}

SELECT name, age
FROM events
WHERE current=”Meguro”

{“name”:”tagomoris”,”age”:34}
13年11月7日木曜日
Norikra Queries: (2)
{“name”:”frsyuki”,
“age”:25, “address”:”MountainView”,
“corp”:”TD”, “current”:”BayArea”}

SELECT name, age
FROM events
WHERE current=”Meguro”

nothing

13年11月7日木曜日
Norikra Queries: (3)

SELECT age, COUNT(*) as cnt
FROM events.win:time_batch(5 mins)
GROUP BY age

13年11月7日木曜日
Norikra Queries: (3)
{“name”:”tagomoris”,
“age”:34, “address”:”Tokyo”,
“corp”:”LINE”, “current”:”Meguro”}

SELECT age, COUNT(*) as cnt
FROM events.win:time_batch(5 mins)
GROUP BY age

every 5 mins
{”age”:34,”cnt”:3}, {“age”:33,”cnt”:1}, ...
13年11月7日木曜日
Norikra Queries: (4)
{“name”:”tagomoris”,
“age”:34, “address”:”Tokyo”,
“corp”:”LINE”, “current”:”Meguro”}

SELECT age, COUNT(*) as cnt
FROM
events.win:time_batch(5 mins)
GROUP BY age

SELECT max(age) as max
FROM
events.win:time_batch(5 mins)

every 5 mins
{”age”:34,”cnt”:3}, {“age”:33,”cnt”:1}, ...
{“max”:51}
13年11月7日木曜日
Norikra Queries: (5)
{“name”:”tagomoris”,
“user:{“age”:34, “corp”:”LINE”,
“address”:”Tokyo”},
“current”:”Meguro”,
“speaker”:true,
“attend”:[true,true,false, ...]
}

SELECT age, COUNT(*) as cnt
FROM events.win:time_batch(5 mins)
GROUP BY age

13年11月7日木曜日
Norikra Queries: (5)
{“name”:”tagomoris”,
“user:{“age”:34, “corp”:”LINE”,
“address”:”Tokyo”},
“current”:”Meguro”,
“speaker”:true,
“attend”:[true,true,false, ...]
}

SELECT user.age, COUNT(*) as cnt
FROM events.win:time_batch(5 mins)
GROUP BY user.age

13年11月7日木曜日
Norikra Queries: (5)
{“name”:”tagomoris”,
“user:{“age”:34, “corp”:”LINE”,
“address”:”Tokyo”},
“current”:”Meguro”,
“speaker”:true,
“attend”:[true,true,false, ...]
}

SELECT user.age, COUNT(*) as cnt
FROM events.win:time_batch(5 mins)
WHERE current=”Meguro” AND attend.$0 AND attend.$1
GROUP BY user.age

13年11月7日木曜日
Before: Hive

EVERY HOUR!

SELECT
yyyymmdd, hh, campaign_id, region, lang,
count(*) AS click,
count(distinct member_id) AS uu
FROM (
SELECT
yyyymmdd,
hh,
get_json_object(log, '$.campaign.id') AS campaign_id,
get_json_object(log, '$.member.region') AS region,
get_json_object(log, '$.member.lang') AS lang,
get_json_object(log, '$.member.id') AS member_id
FROM applog
WHERE service='myservice'
AND yyyymmdd='20131101' AND hh='00'
AND get_json_object(log, '$.type') = 'click'
) x
GROUP BY yyyymmdd, hh, campaign_id, region, lang
13年11月7日木曜日
After: Norikra
SELECT
campaign.id AS campaign_id, member.region AS region,
count(*) AS click,
count(distinct member.id) AS uu
FROM myservice.win:time_batch(1 hours)
WHERE type="click"
GROUP BY campaign.id, member.region

13年11月7日木曜日
Norikra: Current Status
v0.1.0: Released at 2013/11/01
by tagomoris
http://norikra.github.io/
Documents: under development
Just started to use in production

13年11月7日木曜日
SQL Queries
for batches
for streams

13年11月7日木曜日
企画・開発 幅広く募集中
• データマーケティング
• データベースエンジニア
• BI企画・開発
• etc…

13年11月7日木曜日
TRAVEL
SHOPPING

MOM&KIDS

COOKING

MOVIE

GIRLS

GAME

SPORTS

BOOK

MUSIC
13年11月7日木曜日

Variety
Volume
Velocity

NEWS
企画・開発 幅広く募集中
データ分析・解析 規模拡大/強化中

コーポレートサイトからどうぞ応募を!

13年11月7日木曜日
See Also:
Log analysis system with Hadoop in livedoor 2013
http://www.slideshare.net/tagomoris/log-analysis-with-hadoop-in-livedoor-2013

Norikra
http://norikra.github.io/
https://github.com/norikra

Shib
https://github.com/tagomoris/shib

Fluentd
http://fluentd.org/
https://github.com/fluent/fluentd

13年11月7日木曜日

More Related Content

PDF
The longest 5 minutes in our life
PDF
fluent-plugin-norikra #fluentdcasual
PDF
Complex Event Processing on Ruby, Fluentd and Norikra #rubykaigi
PDF
Stream processing and Norikra
PDF
Oedo Ruby Conference 04: Ruby会議でSQLの話をするのは間違っているだろうか
PDF
Introduction to Chainer and CuPy
PDF
PostgreSQLとpython
PDF
Osc shimane-2016-do-postgres-dream-of-graph-database
The longest 5 minutes in our life
fluent-plugin-norikra #fluentdcasual
Complex Event Processing on Ruby, Fluentd and Norikra #rubykaigi
Stream processing and Norikra
Oedo Ruby Conference 04: Ruby会議でSQLの話をするのは間違っているだろうか
Introduction to Chainer and CuPy
PostgreSQLとpython
Osc shimane-2016-do-postgres-dream-of-graph-database

Similar to Batch and Stream processing with SQL (20)

PDF
Batch processing and Stream processing by SQL
PDF
最近のストリーム処理事情振り返り
PDF
PipelineDBとは?
PPTX
StreamGraph
PDF
20100930 sig startups
PPTX
Norikra + Fluentd + Elasticsearch + Kibana リアルタイムストリーミング処理 ログ集計による異常検知
PDF
InfluxDB の概要 - sonots #tokyoinfluxdb
PDF
IoT時代におけるストリームデータ処理と急成長の Apache Flink
PDF
DynamoDB Streamを使ったリアルタイム分析
PDF
Hadoop上の多種多様な処理でPigの活きる道 (Hadoop Conferecne Japan 2013 Winter)
PDF
PostgreSQL 12の話
PDF
Hive on Spark を活用した高速データ分析 - Hadoop / Spark Conference Japan 2016
PPTX
大量のデータ処理や分析に使えるOSS Apache Sparkのご紹介(Open Source Conference 2020 Online/Kyoto ...
PDF
Facebookのリアルタイム Big Data 処理
PDF
【基本を知ろう】クラウド・データレイクを実現する各サービス最新情報(Oracle Cloudウェビナーシリーズ: 2020年10月15日)
PDF
20120405 setsunaセミナー
PDF
Log analysis with Hadoop in livedoor 2013
PPTX
Azure Data Platform
PDF
[db tech showcase Tokyo 2014] B22: Hadoop Rush!! HDFSからデータを自在に取得、加工するにはどうする? ...
PDF
20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法
Batch processing and Stream processing by SQL
最近のストリーム処理事情振り返り
PipelineDBとは?
StreamGraph
20100930 sig startups
Norikra + Fluentd + Elasticsearch + Kibana リアルタイムストリーミング処理 ログ集計による異常検知
InfluxDB の概要 - sonots #tokyoinfluxdb
IoT時代におけるストリームデータ処理と急成長の Apache Flink
DynamoDB Streamを使ったリアルタイム分析
Hadoop上の多種多様な処理でPigの活きる道 (Hadoop Conferecne Japan 2013 Winter)
PostgreSQL 12の話
Hive on Spark を活用した高速データ分析 - Hadoop / Spark Conference Japan 2016
大量のデータ処理や分析に使えるOSS Apache Sparkのご紹介(Open Source Conference 2020 Online/Kyoto ...
Facebookのリアルタイム Big Data 処理
【基本を知ろう】クラウド・データレイクを実現する各サービス最新情報(Oracle Cloudウェビナーシリーズ: 2020年10月15日)
20120405 setsunaセミナー
Log analysis with Hadoop in livedoor 2013
Azure Data Platform
[db tech showcase Tokyo 2014] B22: Hadoop Rush!! HDFSからデータを自在に取得、加工するにはどうする? ...
20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法
Ad

More from SATOSHI TAGOMORI (20)

PDF
Ractor's speed is not light-speed
PDF
Good Things and Hard Things of SaaS Development/Operations
PDF
Maccro Strikes Back
PDF
Invitation to the dark side of Ruby
PDF
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
PDF
Make Your Ruby Script Confusing
PDF
Hijacking Ruby Syntax in Ruby
PDF
Lock, Concurrency and Throughput of Exclusive Operations
PDF
Data Processing and Ruby in the World
PDF
Planet-scale Data Ingestion Pipeline: Bigdam
PDF
Technologies, Data Analytics Service and Enterprise Business
PDF
Ruby and Distributed Storage Systems
PDF
Perfect Norikra 2nd Season
PDF
Fluentd 101
PDF
To Have Own Data Analytics Platform, Or NOT To
PDF
The Patterns of Distributed Logging and Containers
PDF
How To Write Middleware In Ruby
PDF
Modern Black Mages Fighting in the Real World
PDF
Open Source Software, Distributed Systems, Database as a Cloud Service
PDF
Fluentd Overview, Now and Then
Ractor's speed is not light-speed
Good Things and Hard Things of SaaS Development/Operations
Maccro Strikes Back
Invitation to the dark side of Ruby
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Make Your Ruby Script Confusing
Hijacking Ruby Syntax in Ruby
Lock, Concurrency and Throughput of Exclusive Operations
Data Processing and Ruby in the World
Planet-scale Data Ingestion Pipeline: Bigdam
Technologies, Data Analytics Service and Enterprise Business
Ruby and Distributed Storage Systems
Perfect Norikra 2nd Season
Fluentd 101
To Have Own Data Analytics Platform, Or NOT To
The Patterns of Distributed Logging and Containers
How To Write Middleware In Ruby
Modern Black Mages Fighting in the Real World
Open Source Software, Distributed Systems, Database as a Cloud Service
Fluentd Overview, Now and Then
Ad

Batch and Stream processing with SQL