Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Amazon Kinesisでストリーム解析 - Node学園12時限目
Search
nashibao
April 24, 2014
Technology
4
3.9k
Amazon Kinesisでストリーム解析 - Node学園12時限目
Node学園12時限目で話します.
Amazon Kinesisをストリーム解析に使えるか検証した時の話です.
http://plaid.co.jp
nashibao
April 24, 2014
Tweet
Share
More Decks by nashibao
See All by nashibao
ちゃんと使えるBotについて考える
nashibao
0
2.2k
PySparkを使った レコメンドアルゴリズムの改良
nashibao
1
5.8k
カジュアルにリアクティブウェブを実現している話
nashibao
1
5.4k
fishシェルからのエトセトラ - nanapi勉強会 vol2
nashibao
1
480
Other Decks in Technology
See All in Technology
【NGK2025S】動物園(PINTO_model_zoo)に遊びに行こう
kazuhitotakahashi
0
260
Amazon Route 53, 待ちに待った TLSAレコードのサポート開始
kenichinakamura
0
180
トラブルシュートを楽しもう (wakamonog meeting 15)
recuraki
0
160
色々なAWSサービス名の由来を調べてみた
iriikeita
0
110
「人物ごとのアルバム」の精度改善の軌跡/Improving accuracy of albums by person
mixi_engineers
PRO
1
120
AIアプリケーション開発でAzure AI Searchを使いこなすためには
isidaitc
1
130
My small contributions - Fujiwara Tech Conference 2025
ijin
0
1.5k
Visual StudioとかIDE関連小ネタ話
kosmosebi
1
380
Azureの開発で辛いところ
re3turn
0
240
20250116_JAWS_Osaka
takuyay0ne
2
200
Docker Desktop で Docker を始めよう
zembutsu
PRO
0
190
0→1事業こそPMは営業すべし / pmconf #落選お披露目 / PM should do sales in zero to one
roki_n_
PRO
1
1.6k
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
96
5.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
52k
A Modern Web Designer's Workflow
chriscoyier
693
190k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.6k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
39
1.9k
A better future with KSS
kneath
238
17k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
The Language of Interfaces
destraynor
155
24k
Thoughts on Productivity
jonyablonski
68
4.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
870
Transcript
Amazon KinesisͰ ετϦʔϜղੳ (ג)ϓϨΠυ @nashibao
0. Who are you?
@nashibaoͱ͍͍·͢ ࣲࢁथ తࢄܕػցֶशతΤϯδχΞ(31) ! ~201208: େֶͱ͔Ͱʑͱ͢ΔɽMapReduceͱߦྻղ͕ɽ 201209: Node.jsʹ֮ΊΔ 201304: ݩָఱ(31)ͱىۀ
σʔλղੳ&CRMαʔϏε 201309: ത࢜υϩοϓΞτ
(ג)ϓϨΠυͱ͍͍·͢ http://plaid.co.jp EC͚ͷղੳ&CRMαʔϏεΛεςϧε։ൃதɽ ! ݱࡏ։ൃͨͬͨ2ਓ(t-nakamura)ͳͷͰɺ ԠืΛຊʹ͓͓ͪͯ͠Γ·͢ʂ ෲյ͢·Ͱ͕৯͑ΔձࣾʂͦΕ͕ϓϨΠυʂ ܴձγϡϥείͰ͢ʂ
Amazon KinesisΛετϦʔϜ ղੳʹ͑Δ͔ݕূ͓ͨ͠
1. Kinesisͱʁ 2. Node.js͔ΒKinesisΛ͏ 3. ύϑΥʔϚϯεݕূ 4. ײ
1. Kinesisͱʁ
Amazon Kinesis
“a fully managed service for real-time processing of streaming data
at massive scale.” ͲͰ͔͍σʔλ͔Β ϦΞϧλΠϜॲཧ͕ग़དྷΔ ϑϧϚωʔδυͳαʔϏε
5JCTF 5JCTF 5JCTF -# -# -# 2TQFWEGT -KPGUKU#RRNKECVKQPU 5VTGCO 2TQFWEGT
2TQFWEGT 2TQFWEGT 2TQFWEGT 哋┮䠉㏰ا揉ⓧ
5JCTF 5JCTF 5JCTF -# -# -# WEGT -KPGUKU#RRNKECVKQPU 5VTGCO WEGT
WEGT WEGT EGT ϑϧϚωʔδυͳ෦ ! • 24࣌ؒอ࣋ • ࠶औಘՄʢex: Τϥʔ࣌ʣ • 1000tps/shard put • 5tps/shard get
5JCTF 5JCTF 5JCTF -# -# -# WEGT -KPGUKU#RRNKECVKQPU 5VTGCO WEGT
WEGT WEGT EGT ϑϧϚωʔδυͳ෦ ! • 24࣌ؒอ࣋ • ࠶औಘՄʢex: Τϥʔ࣌ʣ • 1000tps/shard put • 5tps/shard get • hashKey(ࣗ༝)ͰৼΓ͚
5JCTF 5JCTF 5JCTF -# -# -# WEGT -KPGUKU#RRNKECVKQPU 5VTGCO WEGT
WEGT WEGT EGT େྔʹॻ͖ࠐΜͰ ·ͱΊͯ औಘ͢ΔͨΊͷΩϡʔ? ॻ͖ࠐΈΛΩϟογϡ͢Δ ड͚ࡼͷΑ͏ͳΠϝʔδ
ෛՙूதͷड͚ࡼʹ Ͱ͖Δʁ
5KVG# 5KVG$ &$ &$ ! 5VTGCO #PCN[VKEU 5GOKDCVEJ/CR4GFWEG ! .QIIGT
Ý ݱঢ় YGDUQEMGV
5KVG# 5KVG$ &$ &$ ! 5VTGCO #PCN[VKEU 5GOKDCVEJ/CR4GFWEG ! .QIIGT
Ý ݱঢ় ෛՙ͕ूத͢Δͱ͘͞ͷେมʂ YGDUQEMGV
5KVG# 5KVG$ &$ &$ ! 5VTGCO #PCN[VKEU 5GOKDCVEJ/CR4GFWEG ! .QIIGT
Ý Kinesis? YGDUQEMGV
5KVG# 5KVG$ &$ ! 5VTGCO #PCN[VKEU 5GOKDCVEJ/CR4GFWEG Kinesis? -KPGUKU !
Ý YGDUQEMGV
2.Node.js͔Βѻ͏
plaidev/kinesis-wrapper.js # install npm install kinesis-wrapper.js # stream ϕʔε mhart/kinesis
! # ΫϥγΧϧͳͷ͕ཉ͍͠ͷɽɽ͔ͩΒॻ͍ͨͷɽɽ plaidev/kinesis-wrapper.js
plaidev/kinesis-wrapper.js # install npm install kinesis-wrapper.js # stream ϕʔε mhart/kinesis
! # bacon.js ϕʔε andyhorng/kinesis ! # ΫϥγΧϧͷ͕ཉ͍͠ͷɽɽ͔ͩΒॻ͍ͨͷɽɽ plaidev/kinesis-wrapper.js
1. putRecordͰ͛ࠐΉ var kinesis = require('..'); ! # ετϦʔϜͱͭͳ͛Δ var
stream = kinesis.stream('hoge'); ! # ‘key’MD5ͰϋογϡԽ͞ΕͯγϟʔυʹৼΓ͚ΒΕΔ stream.putRecord('key', {date: new Date()}, function(err, res){ console.log(err, res); });
2. getRecordsͰϙʔϦϯά var kinesis = require('..'); ! # ετϦʔϜͱͭͳ͛Δ var
stream = kinesis.stream('hoge'); ! # ϙʔϦϯάͯ͠औಘɽγϟʔυ͝ͱग़དྷ·͢ stream.getRecords(function(err, records){ console.log(new Date(), records[0].val.date); });
͍ͭͰʹ ಉظతʹฒྻԽ͢Δ • async.jsʁ • ͜Ε͔Βyieldʂ • node-thunkify • nashibao/co-gateѱ͘ͳ͍Αʂ
co-gateϞδϡʔϧ ैདྷͷίʔϧόοΫܗࣜͷؔΛͦͷ··ฒ ྻԽɾಉظతʹॻ͚Δ ICVG ECNNDCEM ECNNDCEM ECNNDCEM ECNNDCEM KP QWV
TGUWNVU
var co = require('co'); var Gate = require('co-gate'); ! co(function
*(){ ! var gate = new Gate(); ! async_function(gate.in()); ! var results = yield gate.out(); ! })(); co-gateϞδϡʔϧ
3. େྔʹ͛ࠐΉʢ࠶ʣ co(function *(){ var gate = new Gate(); !
for (var i = 0; i < 100; i++){ stream.putRecord('key', {date: new Date()}, gate.in()); } ! var res = yield gate.out(); }
4. ϙʔϦϯάʢ࠶ʣ co(function *(){ var gate = new Gate(); !
stream.getRecords(gate.in()); ! var records = yield gate.out(); })();
3. KinesisͷύϑΥʔϚϯε
ݕূڥɾ݅ • EC2(c3-4xlarge)1͔Β͛ͯݕূɽ • ΫϥΠΞϯτଆͷλΠϜελϯϓͰtpsΛܭଌ • 1~3shard • ৄ͘͠ɺ͏গ͠ݕূඞཁ
putRecord / shard UQTͱ͔ೖͬͨΓ͢Δɽɽ
put & getRecords UQTఔͰݻ·ͬͯऔಘͰ͖Δ
ࢥͬͨΑΓॻ͖ࠐΊΔɽͰ ͪΐͬͱ͍? • max3000~ tps/shard put • ॻ͖ࠐΈ͗͢Δͱ݁ہऔΓग़͢·Ͱʹ͔͔࣌ؒΔɽ • ݁ہ400~700tpsఔ·Ͱ͍͚Δ͜ͱ֬ೝ
• avg1sec get • ϙʔϦϯάࠐΈͰ͜ͷఔ • 200msҎʹฦͬͯ͘ΔΘ͚͡Όͳ͍ • ॻ͖ࠐΜͰऔΓग़͢·Ͱʹͳ͔ͥϥά͕͋ͬͨΓͳ͔ͬͨΓ
ײ • ϑϧϚωʔδυʁ • KAࣗͰཧɽγϟʔυʹϫʔΧʔͤΒΕͳ͍ͷ͔ɽɽ ! • ϦΞϧλΠϜʁ • ϙʔϦϯά
• औΓग़͢ͷʹϥά͕͚ͬ͜͏͋Δ ! • ύϑΥʔϚϯε • writeߴ͍ɽγϟʔυ૿͔ͤͳΓ͍͚ͦ͏
͋Γ͕ͱ͏͍͟͝·ͨ͠ɽ
http://plaid.co.jp