Event-Driven Architectures


                                                              Ilya Grigorik
                 ...
Apr 7th launch:
                                                      Bestest Blog discovery!




Event-Driven Architectur...
• Request, Response Cycle
          • Event Driven Architectures
          • Cloud Computing

          • Real-time Web!
 ...
Elastic, Event-Driven, Real-time, Staged,
                      Services Oriented Architecture
                           ...
GET /home



                                                GET /home




                                               ...
Google: +200ms = -10% searches
         Amazon: +100ms = -5% purchases



                                                ...
Bottleneck




                                                       Complexity and Time



Event-Driven Architectures   ...
“Rails, Django, Seaside, Grails…” cant scale.




                                                      Myth: Slow Framewo...
Application server: 1-1000+ req/s




                                                  “Fast Enough” Frameworks



Event-...
1.   5 ms: Process request
         2.   30 ms: Authenticate user
         3.   90 ms: Contact database & other services
 ...
The Proxy Solution



Event-Driven Architectures   http://bit.ly/eda-mesh    @igrigorik #meshu #eda
The “More” Proxy Solution



Event-Driven Architectures   http://bit.ly/eda-mesh            @igrigorik #meshu #eda
This is madness.
                                                              (after a certain point)




Event-Driven Ar...
1.   Receive
         2.   Verify
         3.   Dispatch
         4.   Aggregate
         5.   Handle errors
         6.  ...
Buzzword: Event-Driven Architectures
                                                      (aka, reinventing the wheel)


...
Auto Manufacturing circa 1910




                                                2-3 men, 1-2 days / car

Event-Driven Ar...
More
                                                  workers!




                                      Scaling the manu...
Then Henry Ford came along…




Event-Driven Architectures   http://bit.ly/eda-mesh   @igrigorik #meshu #eda
And gave us the assembly line!
                                      Scaling the manufacturing process



Event-Driven Arc...
Queuing theory

    Lean manufacturing

    Just in time




          Lower response time,
           higher throughput!
...
Event Driven Architecture (EDA) = Assembly line
                                                      except, we’re not bu...
1.   5 ms - Receive
                                                                   2.   30 ms - Verify
               ...
Can someone else do it?
          Total: 115 ms, ~ 3 req / s

                                                         1. ...
1.   5 ms - Receive
   2.   30 ms - Verify
   3.   30 ms - Save
                                                     1. Ge...
1.   5 ms - Receive
   2.   30 ms - Verify
   3.   30 ms - Save
                                                     1. Ge...
Don’t keep the client waiting!
                                                                          “Can I defer it?”...
PDF service layer                   Email service layer


                     GET /purchase

                            ...
Scalability of service layer




                     GET /purchase

                             OK




                 ...
Elastic Computing
                                                                       EC2 & Virtualization




Event-Dr...
3 servers (always): $216 / month
                        $0.10 / hour
                                                    ...
100 computers * 1 hour = 1 computer * 100 hours




                              Elastic Computing (Pay by the sip)



Ev...
Era of Parallelism



Event-Driven Architectures   http://bit.ly/eda-mesh   @igrigorik #meshu #eda
Elastic car
    manufacturing?



    High capital
    investment



    People & Unions



Event-Driven Architectures   h...
Elastic Computing = Assembly Line 2.0
                                                                    EC2 & Virtualiza...
Elastic, Event-Driven, Staged, Services
                                  Oriented Architecture
                          ...
Phew.




Event-Driven Architectures   http://bit.ly/eda-mesh   @igrigorik #meshu #eda
Buzzword: Real-time web
                                             Scientific translation: really, really, really, fast
...
Ouch!




                                                        Really fast
                             Millions of
   ...
HTTP? DB? …          HTTP? Queue? …




                                                      Real-time communication



E...
Emerging Standards: XMPP & AMQP




Event-Driven Architectures   http://bit.ly/eda-mesh   @igrigorik #meshu #eda
From: A, To: B                                                   From: A, To: B
           Hello!                         ...
Event-stream
                       protocol




           Persistent
          connections


                           ...
User               Domain              Resource


                                      ilya@aiderss.com/office

         ...
<message from=quot;ilya@aiderss.com/officequot; type=quot;chatquot; to=quot;ilya@igvita.comquot; id=quot;aae1aquot;>
     ...
XMPP in the wild: Google Talk



Event-Driven Architectures   http://bit.ly/eda-mesh            @igrigorik #meshu #eda
XMPP in the wild: Google Talk + Video



Event-Driven Architectures   http://bit.ly/eda-mesh   @igrigorik #meshu #eda
Psi: cross-platform Jabber/XMPP client



Event-Driven Architectures   http://bit.ly/eda-mesh   @igrigorik #meshu #eda
require quot;rubygemsquot;
   require quot;xmpp4rquot;

   jid = Jabber::JID::new(quot;ilya@aiderss.comquot;)
   client = ...
require quot;rubygemsquot;
   require quot;xmpp4rquot;

   jid = Jabber::JID::new(quot;ilya@aiderss.comquot;)
   client = ...
client.send(Jabber::Presence.new.set_type(:away))

    # <presence from='daniel@aiderss.com/iMac8D2CB97D'
    to='ilya@aid...
client.send(Jabber::Presence.new.set_type(:available))

    # <presence from='daniel@aiderss.com/iMac8D2CB97D'
    to='ily...
One-to-many distribution



Event-Driven Architectures   http://bit.ly/eda-mesh        @igrigorik #meshu #eda
XEP-0060: Publish-Subscribe (Pubsub)



Event-Driven Architectures   http://bit.ly/eda-mesh   @igrigorik #meshu #eda
Many wasteful checks




                   Data?       No      Data?          No   Data?                 Yes




        ...
Persistent connection




               Subscribe                                                 New message!




      ...
<iq type='set‘ from='hamlet@denmark.lit/blogbot' to='pubsub.shakespeare.lit' id='pub1'>
     <pubsub xmlns='http://jabber....
<iq type='set‘ from='hamlet@denmark.lit/blogbot' to='pubsub.shakespeare.lit' id='pub1'>
     <pubsub xmlns='http://jabber....
Distribute




         Publish                 XEP-0060: Publish-Subscribe (Pubsub)



Event-Driven Architectures   http:...
<message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'>
     <event xmlns='http://jabber.org/protocol/...
Seems neat, but so what?




Event-Driven Architectures   http://bit.ly/eda-mesh   @igrigorik #meshu #eda
XMPP                   XMPP




                                                      Real-time communication



Event-Dri...
XMPP                            XMPP                   XMPP




                                                       Rea...
Event-Driven Architectures   http://bit.ly/eda-mesh   @igrigorik #meshu #eda
require 'fire_hydrant'
   require 'yaml'

   hydrant = FireHydrant.new(YAML.load(File.read(quot;config.ymlquot;)))

   hyd...
Presence: available




                     GET /purchase

                             OK




                          ...
Ejabberd                                       Erlang
                                                              Defact...
Advanced Message Queuing Protocol
                                           (AMQP)



Event-Driven Architectures   http:/...
“AMQP is an open Internet Protocol for Business Messaging”



                             AMQP Working Group (16 companie...
Consumer
                             AMQP Broker




                              Publisher
                            ...
Broker Clustering




                                                         AMQP Clustering



Event-Driven Architectur...
Routing key: usd.stock.amz
                               Message: I like AMZ!



                       Direct           ...
Routing key: usd.stock.amz
                               Message: I like AMZ!



                       Direct           ...
Routing key: usd.stock.amz
                               Message: I like AMZ!



                       Direct           ...
Routing key: usd.stock.msft
                              Message: I like Microsoft!



                       Direct     ...
Routing key: usd.stock.msft
                              Message: I like Microsoft!



                       Direct     ...
Routing key: usd.stock.msft
                              Message: I like Microsoft!



                       Direct     ...
Routing key: usd.stock.msft
                              Message: I like Microsoft!



                       Direct     ...
AMQP Kung-fu: Load-balancing




Event-Driven Architectures    http://bit.ly/eda-mesh   @igrigorik #meshu #eda
Routing key: usd.stock.amz
                               Message: I like AMZ!



                       Direct           ...
Bind: purchase.pdf




                     GET /purchase

                             OK




                           ...
AMQP Kung-fu: Persistence & Durability




Event-Driven Architectures   http://bit.ly/eda-mesh   @igrigorik #meshu #eda
Routing key: usd.stock.amz
                               Message: I like AMZ!



                       Direct           ...
Almost there :)



Event-Driven Architectures   http://bit.ly/eda-mesh   @igrigorik #meshu #eda
require 'mq'

    AMQP.start(:host => 'amqp-server.com') do
                                                              ...
require 'mq'

    AMQP.start(:host => 'amqp-server.com') do

      mq = MQ.new
      mq.topic('stocks').publish(quot;5.95q...
Elastic, Event-Driven, <Real-time>,
               Staged, Services Oriented Architecture
                                ...
XMPP / AMQP




                             Publisher



                                                            Elas...
XMPP / AMQP




            Subscribe
                                         Exposing Publish-Subscribe API



Event-Dri...
Thanks.

                                                              Questions &
                             The slides...
Upcoming SlideShare
Loading in...5
×

Event Driven Architecture - MeshU - Ilya Grigorik

12,158

Published on

A look at the technologies and the architecture behind the emerging real-time web. We will discuss XMPP/Jabber and AMQP protocols and explore the advantages of each over the commonly used HTTP request-response cycle. As part of the workshop we will look at the available tools and libraries and work through simple examples of creating an event driven, real-time service.

Published in: Business, Technology
3 Comments
96 Likes
Statistics
Notes
  • If you want your presentation reviewed- allow it to be downloaded. Due to lousy web performance - online viewing is impossible. Was your intent to share information or restrict access to it? Wish I had the connection your other reviewer's did.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Thanks for sharing Ilya!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Great slides & analogy, thank you for sharing! I'd be interested in the sources regarding Amazon & Google on slide 6, it's yummie data :) Thank you!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
12,158
On Slideshare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
0
Comments
3
Likes
96
Embeds 0
No embeds

No notes for slide

Event Driven Architecture - MeshU - Ilya Grigorik

  1. 1. Event-Driven Architectures Ilya Grigorik CTO / AideRSS Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  2. 2. Apr 7th launch: Bestest Blog discovery! Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  3. 3. • Request, Response Cycle • Event Driven Architectures • Cloud Computing • Real-time Web! Fully buzzword • XMPP & AMQP compliant! • Example Questions & The slides… My blog Comments Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  4. 4. Elastic, Event-Driven, Real-time, Staged, Services Oriented Architecture (Ready, ready? Go.) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  5. 5. GET /home GET /home GET /home Response Request, Response Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  6. 6. Google: +200ms = -10% searches Amazon: +100ms = -5% purchases GET /home Response Response Time is Everything Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  7. 7. Bottleneck Complexity and Time Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  8. 8. “Rails, Django, Seaside, Grails…” cant scale. Myth: Slow Frameworks Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  9. 9. Application server: 1-1000+ req/s “Fast Enough” Frameworks Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  10. 10. 1. 5 ms: Process request 2. 30 ms: Authenticate user 3. 90 ms: Contact database & other services 4. 30 ms: Render response Total: 155 ms, 0.5 MB / conn OR 6.5 req / s Request, Response assembly Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  11. 11. The Proxy Solution Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  12. 12. The “More” Proxy Solution Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  13. 13. This is madness. (after a certain point) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  14. 14. 1. Receive 2. Verify 3. Dispatch 4. Aggregate 5. Handle errors 6. Render Throughput != Response Time Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  15. 15. Buzzword: Event-Driven Architectures (aka, reinventing the wheel) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  16. 16. Auto Manufacturing circa 1910 2-3 men, 1-2 days / car Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  17. 17. More workers! Scaling the manufacturing process Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  18. 18. Then Henry Ford came along… Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  19. 19. And gave us the assembly line! Scaling the manufacturing process Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  20. 20. Queuing theory Lean manufacturing Just in time Lower response time, higher throughput! 93 seconds / car 1M + cars / year Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  21. 21. Event Driven Architecture (EDA) = Assembly line except, we’re not building cars here… Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  22. 22. 1. 5 ms - Receive 2. 30 ms - Verify Total: 365 ms, ~ 3 req / s 3. 30 ms - Save 4. 200 ms – Generate PDF 5. 50 ms - Email 6. 50 ms - Render GET /purchase OK Monolith Order Processing (example) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  23. 23. Can someone else do it? Total: 115 ms, ~ 3 req / s 1. 5 ms – Receive No ~ 70% improvement in 2. 30 ms - Verify No response time! 3. 30 ms – Save No 4. 200 ms – Generate PDF Yes 5. 50 ms – Email Yes 6. 50 ms – Render Yes GET /purchase OK Assembly Line Order Processing (example) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  24. 24. 1. 5 ms - Receive 2. 30 ms - Verify 3. 30 ms - Save 1. Generate PDF 4. 10 ms – Dispatch 1. Email PDF 2. Dispatch 5. 50 ms – Render Total: 125 ms GET /purchase OK Assembly Line Order Processing (example) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  25. 25. 1. 5 ms - Receive 2. 30 ms - Verify 3. 30 ms - Save 1. Generate PDF 4. 10 ms – Dispatch 1. Email PDF 2. Dispatch 5. 50 ms – Render Total: 125 ms GET /purchase OK Event-Driven Staged Architecture (SEDA) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  26. 26. Don’t keep the client waiting! “Can I defer it?” Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  27. 27. PDF service layer Email service layer GET /purchase OK Services Oriented Architecture (SOA) helps you maintain your sanity Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  28. 28. Scalability of service layer GET /purchase OK SOA = Simple(r) Scalability Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  29. 29. Elastic Computing EC2 & Virtualization Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  30. 30. 3 servers (always): $216 / month $0.10 / hour 3 servers (elastic): $120 / month 0AM – 8AM 8AM – 24PM Elastic Computing (Pay by the sip) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  31. 31. 100 computers * 1 hour = 1 computer * 100 hours Elastic Computing (Pay by the sip) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  32. 32. Era of Parallelism Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  33. 33. Elastic car manufacturing? High capital investment People & Unions Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  34. 34. Elastic Computing = Assembly Line 2.0 EC2 & Virtualization Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  35. 35. Elastic, Event-Driven, Staged, Services Oriented Architecture (that’s a mouthful) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  36. 36. Phew. Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  37. 37. Buzzword: Real-time web Scientific translation: really, really, really, fast Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  38. 38. Ouch! Really fast Millions of response users time Real-time pain Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  39. 39. HTTP? DB? … HTTP? Queue? … Real-time communication Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  40. 40. Emerging Standards: XMPP & AMQP Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  41. 41. From: A, To: B From: A, To: B Hello! Hello! Extensible Messaging and Presence Protocol (XMPP) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  42. 42. Event-stream protocol Persistent connections Presence Identity and XMPP Features authentication Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  43. 43. User Domain Resource ilya@aiderss.com/office Jabber Software Foundation JID: Federation, Identity & Authentication Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  44. 44. <message from=quot;ilya@aiderss.com/officequot; type=quot;chatquot; to=quot;ilya@igvita.comquot; id=quot;aae1aquot;> <body>hello</body> <active xmlns=quot;http://jabber.org/protocol/chatstatesquot;/> </message> Very verbose protocol (XML) Example: Message Routing with XMPP Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  45. 45. XMPP in the wild: Google Talk Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  46. 46. XMPP in the wild: Google Talk + Video Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  47. 47. Psi: cross-platform Jabber/XMPP client Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  48. 48. require quot;rubygemsquot; require quot;xmpp4rquot; jid = Jabber::JID::new(quot;ilya@aiderss.comquot;) client = Jabber::Client.new(jid) client.connect(quot;talk.google.comquot;) client.auth(quot;passwordquot;) to = quot;ilya@aiderss.comquot; subject = quot;Jabber clientquot; message = quot;Hello XMPP World!quot; piclient.send Jabber::Message::new(to, message).set_subject(subject) # <message to='ilya@igvita.com'> # <body>Hello XMPP World!</body> # <subject>Jabber client</subject> XMPP4R (Ruby) Demo # </message> Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  49. 49. require quot;rubygemsquot; require quot;xmpp4rquot; jid = Jabber::JID::new(quot;ilya@aiderss.comquot;) client = Jabber::Client.new(jid) client.connect(quot;talk.google.comquot;) client.auth(quot;passwordquot;) to = quot;ilya@aiderss.comquot; subject = quot;Jabber clientquot; message = quot;Hello XMPP World!quot; piclient.send Jabber::Message::new(to, message).set_subject(subject) # <message to='ilya@igvita.com'> # <body>Hello XMPP World!</body> # <subject>Jabber client</subject> XMPP4R (Ruby) Demo # </message> Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  50. 50. client.send(Jabber::Presence.new.set_type(:away)) # <presence from='daniel@aiderss.com/iMac8D2CB97D' to='ilya@aiderss.com/0EDD826C' xmlns='jabber:client'> # <show>away</show> # <priority>0</priority> # <x xmlns='http://www.apple.com/xmpp/idle'> # <idle-since>2009-04-01T21:48:15Z</idle-since> Client Idle… # </x> # </presence> client.add_message_callback do |m| puts quot;#{m.from} -- #{m.body}quot; end # > daniel@aiderss.com -- Hey! XMPP4R (Ruby) Demo Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  51. 51. client.send(Jabber::Presence.new.set_type(:available)) # <presence from='daniel@aiderss.com/iMac8D2CB97D' to='ilya@aiderss.com/0EDD826C' xmlns='jabber:client'> # <show>away</show> # <priority>0</priority> # <x xmlns='http://www.apple.com/xmpp/idle'> # <idle-since>2009-04-01T21:48:15Z</idle-since> Client Idle… # </x> # </presence> client.add_message_callback do |m| puts quot;#{m.from} -- #{m.body}quot; end # > daniel@aiderss.com -- Hey! XMPP4R (Ruby) Demo Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  52. 52. One-to-many distribution Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  53. 53. XEP-0060: Publish-Subscribe (Pubsub) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  54. 54. Many wasteful checks Data? No Data? No Data? Yes HTTP / SMTP Polling: painful, wasteful Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  55. 55. Persistent connection Subscribe New message! Publish-Subscribe Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  56. 56. <iq type='set‘ from='hamlet@denmark.lit/blogbot' to='pubsub.shakespeare.lit' id='pub1'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <publish node='princely_musings'> IQ Stanza <item> <entry xmlns='http://www.w3.org/2005/Atom'> <title>Soliloquy<title> <summary> To be, or not to be: that is the question! <summary> <link rel='alternate' type='text/html' href='http://denmark.lit/2003/12/13/atom03'/> <id>tag:denmark.lit,2003:entry-32397</id> <published>2003-12-13T18:30:02Z</published> <updated>2003-12-13T18:30:02Z</updated> </entry> </item> </publish> PubSub Protocol: Client XML </pubsub> </iq> Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  57. 57. <iq type='set‘ from='hamlet@denmark.lit/blogbot' to='pubsub.shakespeare.lit' id='pub1'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <publish node='princely_musings'> <item> <entry xmlns='http://www.w3.org/2005/Atom'> <title>Soliloquy<title> <summary> To be, or not to be: that is the question! <summary> <link rel='alternate' type='text/html' AtomPub href='http://denmark.lit/2003/12/13/atom03'/> <id>tag:denmark.lit,2003:entry-32397</id> <published>2003-12-13T18:30:02Z</published> <updated>2003-12-13T18:30:02Z</updated> </entry> </item> </publish> PubSub Protocol: Client XML </pubsub> </iq> Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  58. 58. Distribute Publish XEP-0060: Publish-Subscribe (Pubsub) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  59. 59. <message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'> <event xmlns='http://jabber.org/protocol/pubsub#event'> <items node='princely_musings'> <item id='ae890ac52d0df67ed7cfdf51b644e901'> [ ... ENTRY ... ] Subscriber A </item> </items> </event> </message> <message from='pubsub.shakespeare.lit' to='bernardo@denmark.lit' id='bar'> <event xmlns='http://jabber.org/protocol/pubsub#event'> <items node='princely_musings'> <item id='ae890ac52d0df67ed7cfdf51b644e901'> Subscriber B [ ... ENTRY ... ] </item> </items> </event> </message> XEP-0060: Publish-Subscribe (Pubsub) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  60. 60. Seems neat, but so what? Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  61. 61. XMPP XMPP Real-time communication Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  62. 62. XMPP XMPP XMPP Real-time communication Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  63. 63. Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  64. 64. require 'fire_hydrant' require 'yaml' hydrant = FireHydrant.new(YAML.load(File.read(quot;config.ymlquot;))) hydrant.on_location_update do |user| puts quot;#{user.token} has moved to #{user.locations.first}.quot; Push notifications end hydrant.run! Ruby + FireEagle via XMPP Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  65. 65. Presence: available GET /purchase OK Elastic Computing + Presence Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  66. 66. Ejabberd Erlang Defacto XMPP server Djabberd Perl OpenFire Java RPM, GUI, shiny Tigase Java XMPP / Jabber Servers Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  67. 67. Advanced Message Queuing Protocol (AMQP) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  68. 68. “AMQP is an open Internet Protocol for Business Messaging” AMQP Working Group (16 companies) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  69. 69. Consumer AMQP Broker Publisher AMQP Architecture Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  70. 70. Broker Clustering AMQP Clustering Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  71. 71. Routing key: usd.stock.amz Message: I like AMZ! Direct Topic Fanout Exchange Exchange Exchange AMQP Broker Internals Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  72. 72. Routing key: usd.stock.amz Message: I like AMZ! Direct Topic Fanout Exchange Exchange Exchange Name: amazon Queue Bind: usd.stock.amz AMQP Direct Exchange Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  73. 73. Routing key: usd.stock.amz Message: I like AMZ! Direct Topic Fanout Exchange Exchange Exchange Queue Queue Message: I like AMZ! AMQP Direct Exchange Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  74. 74. Routing key: usd.stock.msft Message: I like Microsoft! Direct Topic Fanout Exchange Exchange Exchange Name: stocks Queue Bind: usd.stock.* AMQP Topic Exchange Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  75. 75. Routing key: usd.stock.msft Message: I like Microsoft! Direct Topic Fanout Exchange Exchange Exchange Queue Message: I like Microsoft! AMQP Topic Exchange Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  76. 76. Routing key: usd.stock.msft Message: I like Microsoft! Direct Topic Fanout Exchange Exchange Exchange Queue Queue Name: stocks 1 2 Bind: “” AMQP Fanout Exchange Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  77. 77. Routing key: usd.stock.msft Message: I like Microsoft! Direct Topic Fanout Exchange Exchange Exchange Queue Queue Message: I like Microsoft 1 2 AMQP Fanout Exchange Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  78. 78. AMQP Kung-fu: Load-balancing Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  79. 79. Routing key: usd.stock.amz Message: I like AMZ! Direct Topic Fanout Exchange Exchange Exchange Queue Only one client gets the message! AMQP Load Balancing Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  80. 80. Bind: purchase.pdf GET /purchase OK Elastic AMQP Load-balancing Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  81. 81. AMQP Kung-fu: Persistence & Durability Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  82. 82. Routing key: usd.stock.amz Message: I like AMZ! Direct Topic Fanout Exchange Exchange Exchange Durable: True Queue Persistent: True AMQP Persistence & Durability Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  83. 83. Almost there :) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  84. 84. require 'mq' AMQP.start(:host => 'amqp-server.com') do Publisher mq = MQ.new mq.topic('stocks').publish(quot;5.95quot;, :key => quot;usd.amzquot;) end AMQP.start(:host => 'amqp-server.com') do mq = MQ.new mq.queue('amazon stock').bind(mq.topic('stocks'), :key => 'usd.amz').subscribe{ |price| print 'apple stock', price } end AMQP + Ruby Example Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  85. 85. require 'mq' AMQP.start(:host => 'amqp-server.com') do mq = MQ.new mq.topic('stocks').publish(quot;5.95quot;, :key => quot;usd.amzquot;) end Consumer AMQP.start(:host => 'amqp-server.com') do mq = MQ.new mq.queue('amazon stock').bind(mq.topic('stocks'), :key => 'usd.amz').subscribe{ |price| print ‘amazon stock', price } end AMQP + Ruby Example Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  86. 86. Elastic, Event-Driven, <Real-time>, Staged, Services Oriented Architecture (oi…) Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  87. 87. XMPP / AMQP Publisher Elastic Architecture Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  88. 88. XMPP / AMQP Subscribe Exposing Publish-Subscribe API Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda
  89. 89. Thanks. Questions & The slides… My blog Comments Event-Driven Architectures http://bit.ly/eda-mesh @igrigorik #meshu #eda

×