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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
7.1k
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
120
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
810
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
120
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
560
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
170
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
870
どこまでゆるくて許されるのか
tk3fftk
0
260
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
140
ふつうのFeature Flag実践入門
irof
8
4.2k
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
610
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.6k
The browser strikes back
jonoalderson
0
1.3k
WCS-LA-2024
lcolladotor
0
660
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
210
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
170
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
KATA
mclloyd
PRO
35
15k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
580
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
590
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