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
Data streams processing with PHP and STORM
Search
Mariusz Gil
April 20, 2013
Programming
750
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Data streams processing with PHP and STORM
Mariusz Gil
April 20, 2013
More Decks by Mariusz Gil
See All by Mariusz Gil
Aspect Oriented Programming
mariuszgil
1
340
Designing and implementing GraphQL API
mariuszgil
1
110
Discovering unknown with EventStorming ConFoo
mariuszgil
0
320
Game of Developer Life... Deconstructed
mariuszgil
1
200
Back to forgotten roots
mariuszgil
1
430
Go micro with microservices
mariuszgil
5
710
Machine Learning for the rescue
mariuszgil
0
450
Discovering graph structures
mariuszgil
3
560
Introduction to Aerospike with PHP
mariuszgil
8
870
Other Decks in Programming
See All in Programming
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
340
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
2
750
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.6k
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
970
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
430
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
180
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
280
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
460
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
460
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
330
スマートグラスで並列バイブコーディング
hyshu
0
270
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
260
Featured
See All Featured
Designing for Timeless Needs
cassininazir
1
270
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
300
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Optimizing for Happiness
mojombo
378
71k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
A better future with KSS
kneath
240
18k
Transcript
PROCESSING t he php way of... STORM DAta STREAMS Mariusz
Gil
about me
#php #scalability #nosql #performance #hadoop #hive #pig #bigdata #mahout #datamining
#storm https://music.twitter.com/_login/background.jpg
batch #1 batch #2 batch #3 t he P r
obl em
t he S t or y
STORM DISTRIBUTED REALTIME COMPUTATION SYSTEM
scalable no data lost fault tolerant extremely robust language agnostic
efficient messaging local or distributed
terms and architecture
Spouts Bolts Stream Topologies (val1, val2) (val3, val4) (val5, val6)
unbounded sequence of tuples tuple tuple tuple tuple tuple tuple tuple
Spouts Bolts Stream Topologies (val1, val2) (val3, val4) (val5, val6)
source of streams tuple tuple tuple tuple tuple tuple tuple tuple tuple tuple tuple tuple tuple tuple
Spouts Bolts Stream Topologies (val1, val2) (val3, val4) (val5, val6)
process input streams and produce new streams tuple tuple tuple tuple tuple tuple tuple tuple tuple tuple tuple tuple tuple tuple
Spouts Bolts Stream Topologies (val1, val2) (val3, val4) (val5, val6)
network of spouts and bolts TextSpout SplitSentenceBolt WordCountBolt [sentence] [word] [word, count]
None
storm-kestrel storm-kafka storm-amqp-spout storm-jms storm-pubsub storm-beanstalkd mapr-spout
shuffle grouping fields grouping all grouping global grouping direct grouping
local or shuffle grouping
ZooKeepers Supervisors Nimbus
fast CLUSTER STATE IS STORED LOCALLY OR IN ZOOKEEPERS fail
code examples
https://github.com/nathanmarz/storm
https://github.com/maltoe/storm-install
https://github.com/nathanmarz/storm-starter/
https://github.com/lazyshot/storm-php
public class DoubleAndTripleBolt extends BaseRichBolt { private OutputCollectorBase _collector; @Override
public void prepare(Map conf, TopologyContext context, OutputCollectorBase collector) { _collector = collector; } @Override public void execute(Tuple input) { int val = input.getInteger(0); _collector.emit(input, new Values(val*2, val*3)); _collector.ack(input); } @Override public void declareOutputFields(OutputFieldsDeclarer declarer) { declarer.declare(new Fields("double", "triple")); } } Java example / bolt
public static class ExclamationBolt implements IRichBolt { OutputCollector _collector; public
void prepare(Map conf, TopologyContext context, OutputCollector collector) { _collector = collector; } public void execute(Tuple tuple) { _collector.emit(tuple, new Values(tuple.getString(0) + "!!!")); _collector.ack(tuple); } public void cleanup() { } public void declareOutputFields(OutputFieldsDeclarer declarer) { declarer.declare(new Fields("word")); } public Map getComponentConfiguration() { return null; } } Java example / bolt
TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("words", new TestWordSpout(), 10); builder.setBolt("exclaim1",
new ExclamationBolt(), 3) .shuffleGrouping("words"); builder.setBolt("exclaim2", new ExclamationBolt(), 2) .shuffleGrouping("exclaim1"); Java example / topology ... words exclaim1 exclaim2
zkServer.sh start bin/storm nimbus bin/storm supervisor bin/storm ui #optional storm
jar all-my-code.jar backtype.storm.MyTopology arg1 arg2 Java example / run
PHP example / spout PHP example / spout require_once('storm.php'); class
RandomSentenceSpout extends ShellSpout { ! protected $sentences = array( ! ! "the cow jumped over the moon", ! ! "an apple a day keeps the doctor away", ! ! "four score and seven years ago", ! ! "snow white and the seven dwarfs", ! ); ! protected function nextTuple() ! { ! ! sleep(.1); ! ! $sentence = $this->sentences[ rand(0, count($this->sentences) -1)];! ! ! $this->emit(array($sentence)); ! } ! protected function ack($tuple_id) ! { ! ! return; ! } ! protected function fail($tuple_id) ! { ! ! return; ! }! } $SentenceSpout = new RandomSentenceSpout(); $SentenceSpout->run();
PHP example / bolt require_once('storm.php'); class SplitSentenceBolt extends BasicBolt {
! public function process(Tuple $tuple) ! { ! ! $words = explode(" ", $tuple->values[0]); ! ! foreach($words as $word) ! ! { ! ! ! $this->emit(array($word)); ! ! } ! } } $splitsentence = new SplitSentenceBolt(); $splitsentence->run();
/** * This topology demonstrates Storm's stream groupings and multilang
capabilities. */ public class WordCountPHPTopology { public static class SplitSentence extends ShellBolt implements IRichBolt { public SplitSentence() { super("php", "splitsentence.php"); } @Override public void declareOutputFields(OutputFieldsDeclarer declarer) { declarer.declare(new Fields("word")); } @Override public Map<String, Object> getComponentConfiguration() { return null; } } // ... } MultiLang example / Topology, Bolt
{"command": "next"} {"command": "ack", "id": "1231231"} {"command": "fail", "id": "1231231"}
NonJVMSpout NonJVMBolt {"command": "sync"} { ! "command": "emit", ! "id": "1231231", ! "stream": "1", ! "task": 9, ! "tuple": ["field1", 2, 3] } { ! "id": "-6955786537413359385", ! "comp": "1", ! "stream": "1", ! "task": 9, ! "tuple": ["snow white and dwarfs", "field2", 3] } { ! "command": "emit", ! "anchors": ["1231231", "-234234234"], ! "stream": "1", ! "task": 9, ! "tuple": ["field1", 2, 3] } https://github.com/nathanmarz/storm/wiki/Multilang-protocol
demo
use cases
stream processing
continous query computation
RPC distributed arguments results [request-id, arguments] [request-id, results]
realtime analytics personalization search revenue optimization monitoring
content search realtime analytics generating feeds integrated with elastic search,
Hbase,hadoop and hdfs
realtime scoring moments generation integration with kafka queues and hdfs
storage
thanks! feel free to contact with me email:
[email protected]
twitter:
@mariuszgil