Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Decouple all the things - Asynchronous messaging keeps it simple

Decouple all the things - Asynchronous messaging keeps it simple

Talk at DevconTLV, March 2016

Kerstin Puschke

March 22, 2016
Tweet

More Decks by Kerstin Puschke

Other Decks in Technology

Transcript

  1. inform about update Updates need to propagate 7 business partners

    business partner out of business orders support contracts
  2. downside of REST: client misses update if temporarily down 8

    business partners orders support contracts
  3. downside of REST: app needs to know its clients 9

    business partners orders support contracts invoices
  4. amqp.org/about/what “The capable, commoditized, multi-vendor communications ecosystem which AMQP enables

    “The capable, commoditized, multi-vendor communications ecosystem which AMQP enables creates opportunities for commerce and innovation “The capable, commoditized, multi-vendor communications ecosystem which AMQP enables creates opportunities for commerce and innovation which can transform the way business is done “The capable, commoditized, multi-vendor communications ecosystem which AMQP enables creates opportunities for commerce and innovation which can transform the way business is done on the Internet “The capable, commoditized, multi-vendor communications ecosystem which AMQP enables creates opportunities for commerce and innovation which can transform the way business is done on the Internet, and in the Cloud.”
  5. Messages contain payload and routing key 15 Routing Key Payload

    •  application data – any form, any encoding… …and more •  Structured app-specific data (properties / attributes) •  Headers •  Annotations •  …
  6. Consumer subscribes, without touching producer 19 P X Q2 Q1

    C1 C2 Producer Exchange Queue Consumer
  7. Why not include updated data? routing key <...>profile.updated payload 23

    { “user_id”: 42, “fields”: [“last_name”] }
  8. No guaranteed order – aim for commutativity Order of messages

    not guarantueed Commutativity Complement with synchronous API (e.g. REST) •  most recent data •  leading system •  message consumers follow up with REST if necessary Small payload •  easier on the broker 24
  9. No exactly-once delivery – aim for idem-potent messages Duplicated messages

    •  possible e.g. if producer re-sends message after connection failure •  use idem-potent message handling 25
  10. Centralized tracking of decentralized events 27 P1 P2 X Q

    C event to be tracked tracking counter ++
  11. Task / Command – consumer state to change 30 Message

    Broker X Q P C event / state change
  12. Run tasks asynchronously 32 Message Broker X Q P C

    image upload user facing image processing
  13. Improve response time, avoid downtimes 33 Message Broker X Q

    P C image upload user facing image processing
  14. Scaling on the fly 34 X Q C C P

    migration trigger data migration
  15. Migration without downtime 35 Message Broker X Q P C

    old system user facing new system
  16. Test without impacting users 36 Message Broker X Q P

    C old app user facing shadow calls to new app
  17. In a nutshell •  Interoperability •  Improve response times • 

    Avoid downtimes •  Scale on the fly •  Reduce complexity •  Simplify code •  Easy to get started 37
  18. Who am I Contact •  http://www.kpuschke.eu •  twitter: @titanoboa42 • 

    https://www.xing.com/profile/ Kerstin_Puschke Senior Software Engineer at XING Hamburg •  xing.com social network for business professionals •  debian, perl, javascript, ruby on rails, mysql, redis, riak, . . . We’re hiring in Hamburg, Barcelona,… http://corporate.xing.com/ english/company/careers- at-xing/ The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.
  19. Flexible Routing via different Exchange Types Direct Exchange •  routes

    to all queues whose binding_key equals routing_key Fanout Exchange •  broadcasts to every queue it has a binding for •  ignores routing key and queue name Topic Exchange •  dot-separated words as routing keys, plus wildcards •  routing on multiple attributes Header Exchange •  based on headers, not routing keys •  routing on multiple attributes 41