Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Ø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
Fa...
What is not Ømq?

A message queue, it literally has zero message queues
A server you can connect to
Persistent
Out of the ...
Why use Ømq instead of X?
It’s a paradigm change, you can hardly compare it to “other
solutions”
When your system require ...
Transports
Supported transports

INPROC (in-process communication)
IPC (inter-process communication)
Multicast (using a pgm multicast...
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
Co...
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 a...
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 los...
Pub -Sub

Ømq will buffer the messages in the subscriber if it is a “slow
listener”
It will drop messages if buffer gets t...
Client   Worker      Worker           Worker
                  more steps
         Worker
Fan      Worker                S...
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...
Push - Pull

Ømq will buffer the messages if there are no peers to get
them
It will block at some point if buffering too m...
Devices
Devices or Brokers

Devices are programs that will route messages between two
nodes
Devices are usually small but they can...
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 de...
Devices

Allow you to create more complex topologies
Help you route requests to anonymous workers
Good place for handling/...
Let’s see some
  examples
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Next
Upcoming SlideShare
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Next
Download to read offline and view in fullscreen.

18

Share

ZeroMQ in PHP

Download to read offline

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

ZeroMQ in PHP

  1. 1. Ømq and CakePHP Socket programming brought to your web app
  2. 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. 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. 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
  5. 5. Transports
  6. 6. Supported transports INPROC (in-process communication) IPC (inter-process communication) Multicast (using a pgm multicast) TCP
  7. 7. Let’s talk about patterns
  8. 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. 9. ICANHAZ? Client Server Request - Reply
  10. 10. Request - Reply client.php
  11. 11. Request - Reply server.php
  12. 12. Wait a minute... This looks way too slow, a single php process won’t cope the load of multiple clients.
  13. 13. We need a solution
  14. 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. 15. Load Balanced Requests More on balancing later...
  16. 16. Client Client Server Client Client Publisher - Subscriber
  17. 17. Publisher publisher.php
  18. 18. Subscriber client.php
  19. 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. 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. 21. Client Worker Worker Worker more steps Worker Fan Worker Sink Worker Push - Pull (Pipeline)
  22. 22. Push - Pull ventilator.php
  23. 23. Push - Pull task.php
  24. 24. Push - Pull sink.php
  25. 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. 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
  27. 27. Devices
  28. 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. 29. We needed a solution
  30. 30. Devices as balancers Client Client Client Dealer Server Server Server
  31. 31. A simple broker broker.php
  32. 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. 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. 34. Let’s see some examples
  • FlorentShomora

    Jan. 30, 2020
  • ssuserb6df57

    Mar. 29, 2016
  • alstrik

    Feb. 13, 2016
  • g3n1k

    Jun. 15, 2015
  • vietnambaby

    Dec. 1, 2014
  • JiangYu7408

    Nov. 16, 2014
  • nekofar

    Nov. 5, 2014
  • zoghal

    Nov. 5, 2014
  • lastcowboy

    Oct. 28, 2014
  • maycoolboy

    Oct. 28, 2014
  • baohan1

    Aug. 28, 2014
  • voronenko

    Aug. 13, 2014
  • tommifinnila14

    Aug. 6, 2014
  • sinesiojunor

    Mar. 1, 2014
  • thinkpanda

    Jun. 26, 2013
  • angelocreatore

    Feb. 19, 2013
  • mantiniss

    Nov. 3, 2012
  • vitorpc

    Sep. 1, 2012

Views

Total views

13,434

On Slideshare

0

From embeds

0

Number of embeds

13

Actions

Downloads

111

Shares

0

Comments

0

Likes

18

×