Suche senden
Hochladen
ZeroMQ Is The Answer: PHP Tek 11 Version
•
23 gefällt mir
•
6,239 views
I
Ian Barber
Folgen
The slides I would have shown at PHP Tek 11!
Weniger lesen
Mehr lesen
Technologie
Diashow-Anzeige
Melden
Teilen
Diashow-Anzeige
Melden
Teilen
1 von 50
Jetzt herunterladen
Downloaden Sie, um offline zu lesen
Empfohlen
Créer une base NoSQL en 1 heure
Créer une base NoSQL en 1 heure
Amaury Bouchard
ZeroMQ Is The Answer
ZeroMQ Is The Answer
Ian Barber
ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made Simple
Ian Barber
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 Version
Ian Barber
How to stand on the shoulders of giants
How to stand on the shoulders of giants
Ian Barber
Asynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time Messaging
Steve Rhoades
神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)
guregu
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and Lua
Jon Moore
Empfohlen
Créer une base NoSQL en 1 heure
Créer une base NoSQL en 1 heure
Amaury Bouchard
ZeroMQ Is The Answer
ZeroMQ Is The Answer
Ian Barber
ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made Simple
Ian Barber
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 Version
Ian Barber
How to stand on the shoulders of giants
How to stand on the shoulders of giants
Ian Barber
Asynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time Messaging
Steve Rhoades
神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)
guregu
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and Lua
Jon Moore
C99.php
C99.php
veng33k
Lua tech talk
Lua tech talk
Locaweb
React PHP: the NodeJS challenger
React PHP: the NodeJS challenger
vanphp
The promise of asynchronous PHP
The promise of asynchronous PHP
Wim Godden
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message Queue
Gleicon Moraes
Asynchronous I/O in PHP
Asynchronous I/O in PHP
Thomas Weinert
Malcon2017
Malcon2017
Andriy Brukhovetskyy
Using ngx_lua in UPYUN
Using ngx_lua in UPYUN
Cong Zhang
Redis as a message queue
Redis as a message queue
Brandon Lamb
C99
C99
sifo12
Py conkr 20150829_docker-python
Py conkr 20150829_docker-python
Eric Ahn
Keep it simple web development stack
Keep it simple web development stack
Eric Ahn
Bootstrapping multidc observability stack
Bootstrapping multidc observability stack
Bram Vogelaar
The promise of asynchronous php
The promise of asynchronous php
Wim Godden
How-to Integração Postfi
How-to Integração Postfi
Thiago Cavalcante
HTTP For the Good or the Bad - FSEC Edition
HTTP For the Good or the Bad - FSEC Edition
Xavier Mertens
Http capturing
Http capturing
Eric Ahn
C99[2]
C99[2]
guest8914af
SSH I/O Streaming via Redis-based Persistent Message Queue -Mani Tadayon
SSH I/O Streaming via Redis-based Persistent Message Queue -Mani Tadayon
Redis Labs
Puppet Camp 2012
Puppet Camp 2012
Server Density
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Masahiro Nagano
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your application
rjsmelo
Weitere ähnliche Inhalte
Was ist angesagt?
C99.php
C99.php
veng33k
Lua tech talk
Lua tech talk
Locaweb
React PHP: the NodeJS challenger
React PHP: the NodeJS challenger
vanphp
The promise of asynchronous PHP
The promise of asynchronous PHP
Wim Godden
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message Queue
Gleicon Moraes
Asynchronous I/O in PHP
Asynchronous I/O in PHP
Thomas Weinert
Malcon2017
Malcon2017
Andriy Brukhovetskyy
Using ngx_lua in UPYUN
Using ngx_lua in UPYUN
Cong Zhang
Redis as a message queue
Redis as a message queue
Brandon Lamb
C99
C99
sifo12
Py conkr 20150829_docker-python
Py conkr 20150829_docker-python
Eric Ahn
Keep it simple web development stack
Keep it simple web development stack
Eric Ahn
Bootstrapping multidc observability stack
Bootstrapping multidc observability stack
Bram Vogelaar
The promise of asynchronous php
The promise of asynchronous php
Wim Godden
How-to Integração Postfi
How-to Integração Postfi
Thiago Cavalcante
HTTP For the Good or the Bad - FSEC Edition
HTTP For the Good or the Bad - FSEC Edition
Xavier Mertens
Http capturing
Http capturing
Eric Ahn
C99[2]
C99[2]
guest8914af
SSH I/O Streaming via Redis-based Persistent Message Queue -Mani Tadayon
SSH I/O Streaming via Redis-based Persistent Message Queue -Mani Tadayon
Redis Labs
Puppet Camp 2012
Puppet Camp 2012
Server Density
Was ist angesagt?
(20)
C99.php
C99.php
Lua tech talk
Lua tech talk
React PHP: the NodeJS challenger
React PHP: the NodeJS challenger
The promise of asynchronous PHP
The promise of asynchronous PHP
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message Queue
Asynchronous I/O in PHP
Asynchronous I/O in PHP
Malcon2017
Malcon2017
Using ngx_lua in UPYUN
Using ngx_lua in UPYUN
Redis as a message queue
Redis as a message queue
C99
C99
Py conkr 20150829_docker-python
Py conkr 20150829_docker-python
Keep it simple web development stack
Keep it simple web development stack
Bootstrapping multidc observability stack
Bootstrapping multidc observability stack
The promise of asynchronous php
The promise of asynchronous php
How-to Integração Postfi
How-to Integração Postfi
HTTP For the Good or the Bad - FSEC Edition
HTTP For the Good or the Bad - FSEC Edition
Http capturing
Http capturing
C99[2]
C99[2]
SSH I/O Streaming via Redis-based Persistent Message Queue -Mani Tadayon
SSH I/O Streaming via Redis-based Persistent Message Queue -Mani Tadayon
Puppet Camp 2012
Puppet Camp 2012
Ähnlich wie ZeroMQ Is The Answer: PHP Tek 11 Version
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Masahiro Nagano
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your application
rjsmelo
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Masahiro Nagano
20 modules i haven't yet talked about
20 modules i haven't yet talked about
Tatsuhiko Miyagawa
Redis for the Everyday Developer
Redis for the Everyday Developer
Ross Tuck
The promise of asynchronous php
The promise of asynchronous php
Wim Godden
Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12
Jakub Zalas
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
clkao
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
clkao
ReactPHP
ReactPHP
Philip Norton
Mojo as a_client
Mojo as a_client
Marcus Ramberg
Forget about index.php and build you applications around HTTP!
Forget about index.php and build you applications around HTTP!
Kacper Gunia
Tatsumaki
Tatsumaki
Tatsuhiko Miyagawa
The History of PHPersistence
The History of PHPersistence
Hugo Hamon
Yy
Yy
yygh
Yy
Yy
yygh
Nouveau document texte
Nouveau document texte
Sai Ef
Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJS
Ladislav Prskavec
Perl Web Client
Perl Web Client
Flavio Poletti
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Kacper Gunia
Ähnlich wie ZeroMQ Is The Answer: PHP Tek 11 Version
(20)
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your application
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
20 modules i haven't yet talked about
20 modules i haven't yet talked about
Redis for the Everyday Developer
Redis for the Everyday Developer
The promise of asynchronous php
The promise of asynchronous php
Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
ReactPHP
ReactPHP
Mojo as a_client
Mojo as a_client
Forget about index.php and build you applications around HTTP!
Forget about index.php and build you applications around HTTP!
Tatsumaki
Tatsumaki
The History of PHPersistence
The History of PHPersistence
Yy
Yy
Yy
Yy
Nouveau document texte
Nouveau document texte
Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJS
Perl Web Client
Perl Web Client
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Mehr von Ian Barber
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find Fraudsters
Ian Barber
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
Ian Barber
Deployment Tactics
Deployment Tactics
Ian Barber
In Search Of: Integrating Site Search (PHP Barcelona)
In Search Of: Integrating Site Search (PHP Barcelona)
Ian Barber
Debugging: Rules & Tools
Debugging: Rules & Tools
Ian Barber
In Search Of... (Dutch PHP Conference 2010)
In Search Of... (Dutch PHP Conference 2010)
Ian Barber
In Search Of... integrating site search
In Search Of... integrating site search
Ian Barber
Document Classification In PHP - Slight Return
Document Classification In PHP - Slight Return
Ian Barber
Document Classification In PHP
Document Classification In PHP
Ian Barber
Mehr von Ian Barber
(9)
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find Fraudsters
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
Deployment Tactics
Deployment Tactics
In Search Of: Integrating Site Search (PHP Barcelona)
In Search Of: Integrating Site Search (PHP Barcelona)
Debugging: Rules & Tools
Debugging: Rules & Tools
In Search Of... (Dutch PHP Conference 2010)
In Search Of... (Dutch PHP Conference 2010)
In Search Of... integrating site search
In Search Of... integrating site search
Document Classification In PHP - Slight Return
Document Classification In PHP - Slight Return
Document Classification In PHP
Document Classification In PHP
Kürzlich hochgeladen
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Edi Saputra
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
apidays
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
DianaGray10
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
Zilliz
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Orbitshub
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
UiPathCommunity
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Zilliz
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
Andrey Devyatkin
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Orbitshub
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
apidays
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Juan lago vázquez
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
sammart93
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Angeliki Cooney
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
Christopher Logan Kennedy
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
Dropbox
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
Remote DBA Services
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
The Digital Insurer
Kürzlich hochgeladen
(20)
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
ZeroMQ Is The Answer: PHP Tek 11 Version
1.
r
/ib we .m q n s ro ze r a // be 42 ttp: ar h e 4 h /3 - nb t r .in e d om @ia is rb in .c - a jo ir t B // hp ne n p: /p p. Ia tt :/ ph h ttp @ h nb ia
2.
“0MQ is unbelievably cool –
if you haven’t got a project that needs it, make one up” jon gifford - loggly
3.
4.
5.
6.
queue
esb pipeline async pub/sub gateway
7.
request/response $ctx = new
ZMQContext(); rep.php $server = new ZMQSocket($ctx, ZMQ::SOCKET_REP); $server->bind("tcp://*:5454"); while(true) { $message = $server->recv(); $server->send($message . " World"); }
8.
request/response $ctx = new
ZMQContext(); req.php $req = new ZMQSocket($ctx, ZMQ::SOCKET_REQ); $req->connect("tcp://localhost:5454"); $req->send("Hello"); echo $req->recv();
9.
10.
import zmq
rep.py context = zmq.Context() server = context.socket(zmq.REP) server.connect("tcp://localhost:5455") while True: message = server.recv() print "Sending", message, "Worldn" server.send(message + " World")
11.
Image: http://flickr.com/photos/sebastian_bergmann/3318754086
12.
wget http://repo.zero.mq/rpm/zeromq.repo yum update yum
install zeromq pear channel-discover pear.zero.mq pecl install zero.mq/zmq-beta echo "extension=zmq.so" > /etc/php.d/zmq.ini http://download.zeromq.org/ http://github.com/zeromq/zeromq2-1 http://github.com/zeromq/libzmq
13.
atomic
string multipart messaging
14.
Post Office Image:
http://www.flickr.com/photos/10804218@N00/4315282973 Post Box Image: http://www.flickr.com/photos/kenjonbro/3027166169
15.
16.
queue
17.
queue $ctx
= new ZMQContext(); $front = $ctx->getSocket(ZMQ::SOCKET_XREP); $back = $ctx->getSocket(ZMQ::SOCKET_XREQ); $front->bind('tcp://*:5454'); $back->bind ('tcp://*:5455'); $poll = new ZMQPoll(); $poll->add($front, ZMQ::POLL_IN); $poll->add($back, ZMQ::POLL_IN); $read = $write = array(); $snd = ZMQ::MODE_SNDMORE; $rcv = ZMQ::SOCKOPT_RCVMORE; queu e.php
18.
while(true) { $events
= $poll->poll($read, $write); foreach($read as $socket) { if($socket === $front) { $messages = $frontend->recvMulti(); $backend->sendMulti($messages); } else if($socket === $back) { $messages = $backend->recvMulti(); $frontend->sendMulti($messages); } } }
19.
0MQ1
0MQ2 Socket STDIN POLL events
20.
$ctx = new
ZMQContext(); $sock = $ctx->getSocket(ZMQ::SOCKET_PULL); $sock->bind("tcp://*:5555"); $poll = new ZMQPoll(); $poll->add($sock, ZMQ::POLL_IN); $poll->add(STDIN, ZMQ::POLL_IN); while(true) { $events = $poll->poll($read, $write); if($read[0] === $sock) { echo "ZMQ: ", $read[0]->recv(); } else { echo "STDIN: ", fgets($read[0]); } } poll.php
21.
22.
stable / unstable
Image: http://www.flickr.com/photos/pelican/235461339/
23.
pipeline
24.
logging processes
local log ag gregators log writer
25.
pipeline <?php
logger.php $ctx = new ZMQContext(); $out = $ctx->getSocket(ZMQ::SOCKET_PUSH); $out->connect("ipc:///tmp/logger"); $msg = array("time" => time()); $msg['msg'] = $_SERVER['argv'][1]; $out->send(json_encode($msg));
26.
loglocal.php $bufSz = 3;
$messages = array(); $ctx = new ZMQContext(); $in = $ctx->getSocket(ZMQ::SOCKET_PULL); $out = $ctx->getSocket(ZMQ::SOCKET_PUSH); $in->bind("ipc:///tmp/logger"); $out->connect("tcp://loghost:5555"); while(true) { $messages[] = $in->recv(); if(count($messages) == $bufferSize) { $out->sendMulti($messages); $messages = array(); } }
27.
logserv.php $ctx = new
ZMQContext(); $in = $ctx->getSocket(ZMQ::SOCKET_PULL); $in->bind("tcp://*:5555"); while(true) { $messages = $in->recvMulti(); echo "Messages Received: ", count($messages), PHP_EOL; foreach($messages as $msg) { $a = json_decode($msg); echo date("Y-m-d h:i:s", $a->time), " ", $a->msg, PHP_EOL; } }
28.
29.
pub/sub Image:
http://www.flickr.com/photos/nikonvscanon/4519133003/
30.
pub/sub
31.
pub
send “h “hi” i” i” “h sub sub sub i” “h ted ann ned
32.
pub/sub $ctx = new
ZMQContext(); $pub = $ctx->getSocket(ZMQ::SOCKET_PUB); $pub->bind('tcp://*:5566'); $pull = $ctx->getSocket(ZMQ::SOCKET_PULL); $pull->bind('tcp://*:5567'); while(true) { $message = $pull->recv(); $pub->send($message); } server.php
33.
$name = htmlspecialchars($_POST['name']); $msg
=htmlspecialchars($_POST['message']); $ctx = new ZMQContext(); $send = $ctx->getSocket(ZMQ::SOCKET_PUSH); $send->connect('tcp://localhost:5567'); if($msg == 'm:joined') { $send->send( "<em>" . $name . " has joined</em>"); } else { $send->send($name . ': ' . $msg); } send.php
34.
$ctx = new
ZMQContext(); $sub = $ctx->getSocket(ZMQ::SOCKET_SUB); $sub->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE,''); $sub->connect('tcp://localhost:5566'); $poll = new ZMQPoll(); $poll->add($sub, ZMQ::POLL_IN); $read = $wri = array(); while(true) { $ev = $poll->poll($read, $wri, 5000000); if($ev > 0) { echo "<script type='text/javascript'> parent.updateChat('"; echo $sub->recv() ."');</script>"; } ob_flush(); flush(); } ch at.php
35.
36.
sub
sub user data pub pub pub web web web
37.
$ctx = new
ZMQContext(); $socket = $ctx->getSocket(ZMQ::SOCKET_PUB); $socket->connect("ipc:///tmp/usercache"); $socket->connect("ipc:///tmp/datacache"); $type = array('users', 'data'); while(true) { $socket->send($type[array_rand($type)], ZMQ::MODE_SNDMORE); $socket->send(rand(0, 12)); sleep(rand(0,3)); } cach e.php
38.
$ctx = new
ZMQContext(); $socket = $ctx->getSocket(ZMQ::SOCKET_SUB); $socket->setSockOpt( ZMQ::SOCKOPT_SUBSCRIBE, "users"); $socket->bind("ipc:///tmp/usercache"); while(true) { $cache = $socket->recv(); $request = $socket->recv(); echo "Clearing $cache $requestn"; } userlistener.php
39.
types of transport
inproc ipc tcp pgm
40.
41.
distro
sub web client sub web sub event sub sub web pub distro sub web client sub db
42.
$ctx = new
ZMQContext(); $out = $ctx->getSocket(ZMQ::SOCKET_PUB); $out->setSockOpt(ZMQ::SOCKOPT_RATE, 10000); $out->connect("epgm://;239.192.0.1:7601"); $in = $ctx->getSocket(ZMQ::SOCKET_PULL); $in->bind("tcp://*:6767"); $device = new ZMQDevice( ZMQ::DEVICE_FORWARDER, $in, $out); eventhub.php
43.
$ctx = new
ZMQContext(); $in = $ctx->getSocket(ZMQ::SOCKET_SUB); $in->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, ''); $in->setSockOpt(ZMQ::SOCKOPT_RATE, 10000); $in->connect("epgm://;239.192.0.1:7601"); $out = $ctx->getSocket(ZMQ::SOCKET_PUB); $out->bind("ipc:///tmp/events"); $device = new ZMQDevice( ZMQ::DEVICE_FORWARDER, $in, $out); distro.php
44.
$ctx = new
ZMQContext(); $in = $ctx->getSocket(ZMQ::SOCKET_SUB); for($i = 0; $i<100; $i++) { $in->setSockOpt( ZMQ::SOCKOPT_SUBSCRIBE, rand(100000, 999999)); } $in->connect("ipc:///tmp/events"); $i = 0; while($i++ < 1000) { $who = $in->recv(); $msg = $in->recv(); printf("%s %s %s", $who, $msg, PHP_EOL); } cli ent.php
45.
push
handler mongrel pub client client mongrel 2 http://mongrel2.org/
46.
$ctx = new
ZMQContext(); $in = $ctx->getSocket(ZMQ::SOCKET_PULL); $in->connect('tcp://localhost:9997'); $out = $ctx->getSocket(ZMQ::SOCKET_PUB); $out->connect('tcp://localhost:9996'); $http = "HTTP/1.1 200 OKrnContent-Length: %srnrn%s"; while(true) { $msg = $in->recv(); list($uuid, $id, $path, $rest) = explode(" ", $msg, 4); $res = $uuid." ".strlen($id).':'.$id.", "; $res .= sprintf($http, 6, "Hello!"); $out->send($res); } handler.php
47.
simple_handler = Handler(
send_spec='tcp://*:9997', send_ident='ab206881-6f49-4276-9db1-1676bfae18b0', recv_spec='tcp://*:9996', recv_ident='' ) main = Server( uuid="9e71cabf-6afb-4ee1-b550-7972245f7e0a", access_log="/logs/access.log", error_log="/logs/error.log", chroot="./", default_host="general.local", name="example", pid_file="/run/mongre2.pid", port=6767, hosts = [ Host(name="general.local", routes={'/test':simple_handler}) ] ) settings = {"zeromq.threads": 1} servers = [main]
48.
namespace m2php; $id ="82209006-86FF-4982-B5EA-D1E29E55D481"; $con
= new m2phpConnection($id, "tcp://127.0.0.1:9997", "tcp://127.0.0.1:9996"); $ctx = new ZMQContext(); $in = $ctx->getSocket(ZMQ::SOCKET_SUB); $in->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE,''); $in->connect('tcp://localhost:5566'); $poll = new ZMQPoll(); $poll->add($sub, ZMQ::POLL_IN); $poll->add($con->reqs, ZMQ::POLL_IN); $read = $write = $ids = array(); $snd = ''; $h = "HTTP/1.1 200 OKrnContent-Type: text/ htmlrnTransfer-Encoding: chunkedrnrn"; https://github.com/winks/m2php
49.
while (true) {
$ev = $poll->poll($read, $write); foreach($read as $r) { if($r !== $in) { $req = $con->recv(); $snd = $req->sender; if($req->is_disconnect()) { unset($ids[$req->conn_id]); } else { $ids[$req->conn_id] = $req->conn_id; $con->send($snd, $req->conn_id,$h); } } else { $m = "<script type='text/javascript'> parent.updateChat('".$in->recv()."'); </script>rn"; $con->send($snd, implode(' ', $ids), sprintf("%xrn%s",strlen($m),$m)); } } } }
50.
Helpful Links http://zero.mq http://zguide.zero.mq
Ian Barber http://zero.mq/ib http://phpir.com ian.barber@gmail.com @ianbarber http://joind.in/talk/view/3442 thanks!
Jetzt herunterladen