SlideShare a Scribd company logo
1 of 34
Download to read offline
Ømq and CakePHP
Socket programming brought to your web app
What is Ømq?

Intelligent socket library for messaging
Incredibly flexible, you can build your own patterns
Fast as hell
Fault tolerant
Language agnostic
What is not Ømq?

A message queue, it literally has zero message queues
A server you can connect to
Persistent
Out of the box solution (sorry to let you down)
Why use Ømq instead of X?
It’s a paradigm change, you can hardly compare it to “other
solutions”
When your system require more advanced network
interactions (or patterns)
You need cheap and easy parallel processing
You don’t want a single point of failure
You need exceptional speed
Transports
Supported transports

INPROC (in-process communication)
IPC (inter-process communication)
Multicast (using a pgm multicast)
TCP
Let’s talk about
    patterns
Patterns is all what Ømq is about
You can choose to use any of the patterns or combine them
all in a single application
Combining patterns help you build more advanced
distributed systems
ICANHAZ?

Client              Server




Request - Reply
Request - Reply
                  client.php
Request - Reply
                  server.php
Wait a minute...

This looks way too slow, a single php process won’t cope the
load of multiple clients.
We need a solution
The solution

Start more servers on different ports
Bind your clients to multiple servers using the same socket
Ømq will automatically load balance them for you
Drawback: You need to hardcode server addresses on each
client
Load Balanced Requests




               More on balancing later...
Client


               Client
  Server
               Client

               Client


Publisher - Subscriber
Publisher
            publisher.php
Subscriber
             client.php
Pub - Sub

Like a radio broadcast, if you tune in late you’ll miss part of
the show
If client crashes the it will also lose messages
It is possible to attach multiple filters to a connection
You can listen on multiple addresses at once
Pub -Sub

Ømq will buffer the messages in the subscriber if it is a “slow
listener”
It will drop messages if buffer gets too big
That is extremely cool
Client   Worker      Worker           Worker
                  more steps
         Worker
Fan      Worker                Sink

         Worker



  Push - Pull (Pipeline)
Push - Pull
              ventilator.php
Push - Pull
              task.php
Push - Pull
              sink.php
Push - Pull
One way only
PUSH is used for “fanning out” tasks
PULL is used for fan-in or sink processes
Workers can hop-in at any time
Only one worker gets the task at a time and they are load
balanced
Push - Pull

Ømq will buffer the messages if there are no peers to get
them
It will block at some point if buffering too much
That is also extremely cool
Devices
Devices or Brokers

Devices are programs that will route messages between two
nodes
Devices are usually small but they can also be trusted with
larger tasks, such as persisting messages
Used to solve hard problems but also introduce single points
of failure
We needed a solution
Devices as balancers
  Client   Client   Client



           Dealer



  Server   Server   Server
A simple broker
                  broker.php
Devices

Clients will connect to localhost:5559
Servers will connect to localhost:5560
Load balancing is done by Ømq
If dealer fails everything breaks :(
You can install failover dealers! :)
Devices

Allow you to create more complex topologies
Help you route requests to anonymous workers
Good place for handling/persisting/retrying messages extra
logic
Can be written in any language supported by Ømq!
Let’s see some
  examples

More Related Content

What's hot

What's hot (20)

Real World Event Sourcing and CQRS
Real World Event Sourcing and CQRSReal World Event Sourcing and CQRS
Real World Event Sourcing and CQRS
 
CloudStack Overview
CloudStack OverviewCloudStack Overview
CloudStack Overview
 
Microservices: Decomposing Applications for Deployability and Scalability (ja...
Microservices: Decomposing Applications for Deployability and Scalability (ja...Microservices: Decomposing Applications for Deployability and Scalability (ja...
Microservices: Decomposing Applications for Deployability and Scalability (ja...
 
Scalable Web Architecture and Distributed Systems
Scalable Web Architecture and Distributed SystemsScalable Web Architecture and Distributed Systems
Scalable Web Architecture and Distributed Systems
 
Active MQ
Active MQActive MQ
Active MQ
 
3. CPU virtualization and scheduling
3. CPU virtualization and scheduling3. CPU virtualization and scheduling
3. CPU virtualization and scheduling
 
Consul
ConsulConsul
Consul
 
Flink history, roadmap and vision
Flink history, roadmap and visionFlink history, roadmap and vision
Flink history, roadmap and vision
 
How to build Micro Frontends with @angular/elements
How to build Micro Frontends with @angular/elementsHow to build Micro Frontends with @angular/elements
How to build Micro Frontends with @angular/elements
 
Cloud foundry: The Platform for Forging Cloud Native Applications
Cloud foundry: The Platform for Forging Cloud Native ApplicationsCloud foundry: The Platform for Forging Cloud Native Applications
Cloud foundry: The Platform for Forging Cloud Native Applications
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022
Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022
Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022
 
Asynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingAsynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time Messaging
 
Soluciones Dynatrace
Soluciones DynatraceSoluciones Dynatrace
Soluciones Dynatrace
 
Prometheus design and philosophy
Prometheus design and philosophy   Prometheus design and philosophy
Prometheus design and philosophy
 
Rabbitmq basics
Rabbitmq basicsRabbitmq basics
Rabbitmq basics
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
M365 reinventing digital environment for modern workplace
M365 reinventing digital environment for modern workplaceM365 reinventing digital environment for modern workplace
M365 reinventing digital environment for modern workplace
 
Monitoring microservices platform
Monitoring microservices platformMonitoring microservices platform
Monitoring microservices platform
 
Introduction to AMQP Messaging with RabbitMQ
Introduction to AMQP Messaging with RabbitMQIntroduction to AMQP Messaging with RabbitMQ
Introduction to AMQP Messaging with RabbitMQ
 

Viewers also liked (9)

Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011
 
Network Programming With Anyevent
Network Programming With AnyeventNetwork Programming With Anyevent
Network Programming With Anyevent
 
Carton CPAN dependency manager
Carton CPAN dependency managerCarton CPAN dependency manager
Carton CPAN dependency manager
 
No Hugging, No Learning
No Hugging, No LearningNo Hugging, No Learning
No Hugging, No Learning
 
Wight: Phantom’s Perl friend - YAPC::Asia 2012
Wight: Phantom’s Perl friend - YAPC::Asia 2012Wight: Phantom’s Perl friend - YAPC::Asia 2012
Wight: Phantom’s Perl friend - YAPC::Asia 2012
 
CPAN Realtime feed
CPAN Realtime feedCPAN Realtime feed
CPAN Realtime feed
 
Intro to PSGI and Plack
Intro to PSGI and PlackIntro to PSGI and Plack
Intro to PSGI and Plack
 
Tatsumaki
TatsumakiTatsumaki
Tatsumaki
 

Similar to ZeroMQ in PHP

The Art of Message Queues - TEKX
The Art of Message Queues - TEKXThe Art of Message Queues - TEKX
The Art of Message Queues - TEKX
Mike Willbanks
 
NoSQL afternoon in Japan Kumofs & MessagePack
NoSQL afternoon in Japan Kumofs & MessagePackNoSQL afternoon in Japan Kumofs & MessagePack
NoSQL afternoon in Japan Kumofs & MessagePack
Sadayuki Furuhashi
 
NoSQL afternoon in Japan kumofs & MessagePack
NoSQL afternoon in Japan kumofs & MessagePackNoSQL afternoon in Japan kumofs & MessagePack
NoSQL afternoon in Japan kumofs & MessagePack
Sadayuki Furuhashi
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
Elizabeth Smith
 
Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginners
webhostingguy
 

Similar to ZeroMQ in PHP (20)

The Art of Message Queues - TEKX
The Art of Message Queues - TEKXThe Art of Message Queues - TEKX
The Art of Message Queues - TEKX
 
Introduction to Kafka
Introduction to KafkaIntroduction to Kafka
Introduction to Kafka
 
Apache web server
Apache web serverApache web server
Apache web server
 
øMQ Vortrag
øMQ VortragøMQ Vortrag
øMQ Vortrag
 
NoSQL afternoon in Japan Kumofs & MessagePack
NoSQL afternoon in Japan Kumofs & MessagePackNoSQL afternoon in Japan Kumofs & MessagePack
NoSQL afternoon in Japan Kumofs & MessagePack
 
NoSQL afternoon in Japan kumofs & MessagePack
NoSQL afternoon in Japan kumofs & MessagePackNoSQL afternoon in Japan kumofs & MessagePack
NoSQL afternoon in Japan kumofs & MessagePack
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
RestMS Introduction
RestMS IntroductionRestMS Introduction
RestMS Introduction
 
Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginners
 
LAMP TECHNOLOGY
LAMP TECHNOLOGYLAMP TECHNOLOGY
LAMP TECHNOLOGY
 
MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011
MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011
MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011
 
Art Of Message Queues
Art Of Message QueuesArt Of Message Queues
Art Of Message Queues
 
zeromq
zeromqzeromq
zeromq
 
Medusa Project
Medusa ProjectMedusa Project
Medusa Project
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
A Quick Guide to Refresh Kafka Skills
A Quick Guide to Refresh Kafka SkillsA Quick Guide to Refresh Kafka Skills
A Quick Guide to Refresh Kafka Skills
 
Scaling Streaming - Concepts, Research, Goals
Scaling Streaming - Concepts, Research, GoalsScaling Streaming - Concepts, Research, Goals
Scaling Streaming - Concepts, Research, Goals
 
MQTT, Eclipse Paho and Java - Messaging for the Internet of Things
MQTT, Eclipse Paho and Java - Messaging for the Internet of ThingsMQTT, Eclipse Paho and Java - Messaging for the Internet of Things
MQTT, Eclipse Paho and Java - Messaging for the Internet of Things
 
Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !
 

More from José Lorenzo Rodríguez Urdaneta (7)

Agile database access with CakePHP 3
Agile database access with CakePHP 3Agile database access with CakePHP 3
Agile database access with CakePHP 3
 
Faster develoment with CakePHP 3
Faster develoment with CakePHP 3Faster develoment with CakePHP 3
Faster develoment with CakePHP 3
 
Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3
 
CakeFest 2013 keynote
CakeFest 2013 keynoteCakeFest 2013 keynote
CakeFest 2013 keynote
 
CakePHP 3.0: Embracing the future
CakePHP 3.0: Embracing the futureCakePHP 3.0: Embracing the future
CakePHP 3.0: Embracing the future
 
Making the most out of CakePHP 2.2
Making the most out of CakePHP 2.2Making the most out of CakePHP 2.2
Making the most out of CakePHP 2.2
 
Mongo Cake Plugin for CakePHP 2.0
Mongo Cake Plugin for CakePHP 2.0Mongo Cake Plugin for CakePHP 2.0
Mongo Cake Plugin for CakePHP 2.0
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

ZeroMQ in PHP

  • 1. Ømq and CakePHP Socket programming brought to your web app
  • 2. What is Ømq? Intelligent socket library for messaging Incredibly flexible, you can build your own patterns Fast as hell Fault tolerant Language agnostic
  • 3. What is not Ømq? A message queue, it literally has zero message queues A server you can connect to Persistent Out of the box solution (sorry to let you down)
  • 4. Why use Ømq instead of X? It’s a paradigm change, you can hardly compare it to “other solutions” When your system require more advanced network interactions (or patterns) You need cheap and easy parallel processing You don’t want a single point of failure You need exceptional speed
  • 6. Supported transports INPROC (in-process communication) IPC (inter-process communication) Multicast (using a pgm multicast) TCP
  • 8. Patterns is all what Ømq is about You can choose to use any of the patterns or combine them all in a single application Combining patterns help you build more advanced distributed systems
  • 9. ICANHAZ? Client Server Request - Reply
  • 10. Request - Reply client.php
  • 11. Request - Reply server.php
  • 12. Wait a minute... This looks way too slow, a single php process won’t cope the load of multiple clients.
  • 13. We need a solution
  • 14. The solution Start more servers on different ports Bind your clients to multiple servers using the same socket Ømq will automatically load balance them for you Drawback: You need to hardcode server addresses on each client
  • 15. Load Balanced Requests More on balancing later...
  • 16. Client Client Server Client Client Publisher - Subscriber
  • 17. Publisher publisher.php
  • 18. Subscriber client.php
  • 19. Pub - Sub Like a radio broadcast, if you tune in late you’ll miss part of the show If client crashes the it will also lose messages It is possible to attach multiple filters to a connection You can listen on multiple addresses at once
  • 20. Pub -Sub Ømq will buffer the messages in the subscriber if it is a “slow listener” It will drop messages if buffer gets too big That is extremely cool
  • 21. Client Worker Worker Worker more steps Worker Fan Worker Sink Worker Push - Pull (Pipeline)
  • 22. Push - Pull ventilator.php
  • 23. Push - Pull task.php
  • 24. Push - Pull sink.php
  • 25. Push - Pull One way only PUSH is used for “fanning out” tasks PULL is used for fan-in or sink processes Workers can hop-in at any time Only one worker gets the task at a time and they are load balanced
  • 26. Push - Pull Ømq will buffer the messages if there are no peers to get them It will block at some point if buffering too much That is also extremely cool
  • 28. Devices or Brokers Devices are programs that will route messages between two nodes Devices are usually small but they can also be trusted with larger tasks, such as persisting messages Used to solve hard problems but also introduce single points of failure
  • 29. We needed a solution
  • 30. Devices as balancers Client Client Client Dealer Server Server Server
  • 31. A simple broker broker.php
  • 32. Devices Clients will connect to localhost:5559 Servers will connect to localhost:5560 Load balancing is done by Ømq If dealer fails everything breaks :( You can install failover dealers! :)
  • 33. Devices Allow you to create more complex topologies Help you route requests to anonymous workers Good place for handling/persisting/retrying messages extra logic Can be written in any language supported by Ømq!
  • 34. Let’s see some examples