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
ふつうのFeature Flag実践入門
irof
7
3.7k
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
230
AIで効率化できた業務・日常
ochtum
0
120
AIエージェントの隔離技術の徹底比較
kawayu
0
470
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
560
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
690
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
120
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
280
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
1.9k
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
150
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
780
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
490
Featured
See All Featured
Writing Fast Ruby
sferik
630
63k
The Limits of Empathy - UXLibs8
cassininazir
1
350
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
290
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Skip the Path - Find Your Career Trail
mkilby
1
140
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
A Tale of Four Properties
chriscoyier
163
24k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
330
Paper Plane (Part 1)
katiecoart
PRO
0
8.8k
Fireside Chat
paigeccino
42
3.9k
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