Velocity Conference '13: Asynchronous messaging for performance optimization, featuring RabbitMQ
Upcoming SlideShare
Loading in...5
×
 

Velocity Conference '13: Asynchronous messaging for performance optimization, featuring RabbitMQ

on

  • 2,750 views

How do Google, Twitter, and Instagram ensure fast application performance at scale? One technique is asynchronous messaging using RabbitMQ to prevent application bottlenecks. In this session, we’ll ...

How do Google, Twitter, and Instagram ensure fast application performance at scale? One technique is asynchronous messaging using RabbitMQ to prevent application bottlenecks. In this session, we’ll cover common asynchronous messaging patterns and how to implement them in RabbitMQ, common pitfalls to avoid, and how to cluster RabbitMQ for increased scalability and reliability.

Statistics

Views

Total Views
2,750
Views on SlideShare
2,743
Embed Views
7

Actions

Likes
3
Downloads
56
Comments
0

2 Embeds 7

https://www.linkedin.com 5
http://www.linkedin.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Now that I’ve provided some background on what AMQP, it is time to explain a few key AMQP concepts. Like most messaging platforms, RabbitMQ supports the concept of point to point messaging, which is just a fancy way of saying, I have a single message that needs to be sent to a single recipient. In AMQP we use a “Direct Exchange” to do point to point messaging.The cornerstone of AMQP is the concept of an “exchange”. Exchanges are stateless message routers that handle all incoming messages. You will bind an exchange to a message queue, in this case, we will create a “binding” called “marriott” that will route hotel booking messages from the exchange to the “marriott” queue. The “P” icon is for message producers. A message producer will send a message using a “routing” key. I this case, the routing key will match the binding name, but that is not a requirement. “C” stands for a message consumer. Message consumers will connect directly to the RabbitMQ server and queue. You can have as many consumers as you want and those consumers usually stay connected to the messaging system and pull messages as fast as they can process them. The message producer will send message one, two and three. Each message will be queued in a “Weak FIFO” order and processed first in/first out style. It is important to note that RabbitMQ does not guarantee message ordering and it is a bad idea to require message ordering for application to application communication, because it is a performance killer.
  • Fan-out exchanges have all of the same characteristics of a Direct Exchange except for one key difference. A Fanout exchange is known as a “publish-subscribe” mechanism, which is a fancy way of saying that I need to send a single message to multiple recipients, very similar to an email distribution list. Any queue bound to a fan-out exchange will receive any message sent to the exchange. And, message consumption of each queue will be dependent on the number of consumers and speed of message consumption.
  • The fan-out exchange provides a simple publish-subscribe model, but AMQP also supports a more powerful content based router mechanism called a topic exchange. In this example, we have three different queues, one for all hotel bookings, whether they are made via orbitz, travelocity or expedia, one for just orbitz bookings and another for orbitz bookings to the marriott hotel chain. We will use a binding pattern to control message flow. For the first queue, any message that has a routing key that starts with “booking.” will go to the all_bookings queue because we are using the pound sign, a multi-word pattern symbol. The second queue is bound by an asterisk which will match all single word values. Our last binding requires an exact match because it doesn’t use an asterisk or pound symbol.The first message goes to all three queues. The second message doesn’t match the routing key pattern for queue #3. The third message only matches our least specific filter, “all_bookings”.
  • Design guidance from http://redis.io/Note that “easy to use” isn’t in this copy. That’s because it’s implied with the tagline “messaging that just works” and the extensive list of tutorial links.
  • http://www.wapolabs.com/2012/02/07/leveraging-rabbitmq-to-decouple-your-application/
  • More:http://uidai.gov.in/UID_PDF/Front_Page_Articles/Documents/Strategy_Overveiw-001.pdfhttp://uidai.gov.in/UID_PDF/Front_Page_Articles/Strategy/Exclusion_to_Inclusion_with_Micropayments.pdfhttp://uidai.gov.in/index.php?option=com_content&view=article&id=153&Itemid=13http://blogs.vmware.com/vfabric/2012/07/spring-and-rabbitmq-behind-indias-12-billion-person-biometric-database-1.htmlhttp://www.biometrics.org/bc2012/presentations/UIDAI/Technology_Tampa_v1040.pdf
  • http://www.bbc.co.uk/blogs/researchanddevelopment/2010/09/what-makes-zeitgeist-tick.shtml
  • James Manyika et al. “Big data: The next frontier for innovation, competition and productivity”, McKinsey Global Institute, Tech rep. May 2011

Velocity Conference '13: Asynchronous messaging for performance optimization, featuring RabbitMQ Velocity Conference '13: Asynchronous messaging for performance optimization, featuring RabbitMQ Presentation Transcript

  • 1Pivotal Confidential–Internal Use Only 1Pivotal Confidential–Internal Use Only Asynchronous Messaging for Performance Optimization Al Sargent Director, Product Marketing Pivotal Velocity Conference 2013 June 20, 2013
  • 2Pivotal Confidential–Internal Use Only About me  Now: Application Fabric team @ Pivotal  Previously: SpringSource/VMware/RabbitMQ since 2010  Earlier: Sauce Labs, Wily, Mercury, Oracle
  • 3Pivotal Confidential–Internal Use Only Diagram adapted from http://www.manning.com/videla/ History of Messaging
  • 4Pivotal Confidential–Internal Use Only Typical use cases for Messaging  Event I need to know when to do something  Data fragment I need to give you a piece of this data without you needing to understand the whole schema  Routing Control who gets which message, without changing sender and receiver  Publish Tell everyone who wants to know about this  Batch Producer and consumer can run at independent times  Telemetry Metadata on servers, devices, etc.  Load share Add more consumers to scale up
  • 5Pivotal Confidential–Internal Use Only AMQP introduction • AMQP (Advanced Message Queuing Protocol) is an open standard application layer protocol for message oriented middleware – It is an open protocol (like TCP, HTTP, SMTP, and so on) • The defining features of AMQP are: – Message orientation – Queuing – Routing (including point-to-point and publish-and-subscribe) – Reliability – Security • AMQP mandates the behaviour of the messaging provider and client – Implementations from different vendors are truly interoperable – Previous attempts to standardise middleware have focussed at the API level • This approach did not create interoperability – Instead of merely defining an API, AMQP defines a wire-level protocol • A wire-level protocol is a description of the format of the data that is sent across the network as a stream of octets • Any tool that can create and interpret messages that conform to the defined wire-level protocol can interoperate with any other compliant tool, irrespective of implementation language
  • 6Pivotal Confidential–Internal Use Only AMQP motivation • AMQP was born of frustration! – Message oriented middleware needs to be everywhere in order to be useful, but… – Traditionally dominant solutions are typically very proprietary • They are frequently too expensive for everyday use • They invariably do not interoperate – The above issues with proprietary solutions have resulted in numerous home-grown developments • Custom middleware solutions • Custom adaptors – The net result for a large enterprise is middleware hell • Hundred’s of applications, thousand’s of links • Every other connection is different • Massive waste of effort – Costly to implement – Costly and difficult to maintain
  • 7Pivotal Confidential–Internal Use Only AMQP Comparison with other protocols AMQP can accommodate all of the above as use-cases… and switch between them (open, ubiquitous, and adaptable) Protocol Comments SMTP Unreliable, slow HTTP Synchronous, semi-reliable, no routing XMPP No delivery fidelity or queue management FTP Point to point, transient, does not work well with NAT/SSL MQ Exactly once TCP At least once, reliable but short lived, no application-level state management UDP Fast but has no delivery guarantees
  • 8Pivotal Confidential–Internal Use Only AMQP scales of deployment Type of deployment Possible scenario Developer/casual use 1 server, 1 user, 10 queues, 1 message per second Production application 2 servers, 10-100 users, 10-50 queues, 25 messages per second Departmental mission critical application 4 servers, 100-500 users, 50-100 queues, 250 messages per second Regional mission critical application 16 servers, 500-2,000 users, 100-500 queues and topics, 2,500 messages per second Global mission critical application 64 servers, 2K-10K users, 500-1000 queues and topics, 25,000 messages per second Market data (trading) 200 servers, 5K users, 10K topics, 250K messages per second As well as volume, the latency of message transfer is often important; AMQP implementations can deliver messages with latencies of less than 200μs AMQP implementations can cover deployment at different levels of scale ranging from trivial to the mind-boggling... no job too big or too small.
  • 9Pivotal Confidential–Internal Use Only AMQP concepts Each message is stateless Consumers create queues; these buffer messages for push to consumers Queues are stateful, ordered, and can be persistent, transient, private, shared. Exchanges are stateless routing tables. Consumers tell queues to bind to named exchanges; each binding has a pattern e.g. “tony” or “*.ibm.*” Producers send messages to exchanges with a routing key e.g. “tony”, or ordered set of keys e.g. “buy.ibm.nyse” Exchanges route messages to queues whose binding pattern matches the message routing key or keys
  • 10Pivotal Confidential–Internal Use Only M3M1 M2 AMQP direct exchanges Queue BindingRouting key • Point to point messaging • A single message that needs to be sent to a single recipient • Can have multiple consumers (load will be balanced across them)
  • 11Pivotal Confidential–Internal Use Only AMQP fan-out exchange • A fan-out exchange is a “publish-subscribe” mechanism • Used to send a single message to multiple recipients (very similar to an email distribution list) • Any queue bound to a fan-out exchange will receive any message sent to the exchange • Message consumption of each queue will be dependent on the number of consumers and speed of message consumption M3M1 M2 M3M1 M2 M3M1 M2 Queue 1 Queue 1 Queue 3 Same message sent to multiple queues/recipients
  • 12Pivotal Confidential–Internal Use Only M1 M2 M1 M2 M3 M1 AMQP topic exchange Queue 1 Queue 2 Queue 3 Binding pattern B Binding pattern C Binding pattern A • Content-based routing mechanism • Messages posted to queues based on binding pattern (PCRE used) • Very powerful mechanism
  • 13Pivotal Confidential–Internal Use Only RabbitMQ: Modern Messaging for the Cloud Multi-geo, cloud-scale Message Bus RabbitMQ Message Broker AMQP, JMS, MQTT, STOMP, HTTP, HTTPS… Point-to-point and pub-sub Virtual hosts, dynamic configuration Cluster within single datacenter Federate across multiple datacenters Cloud Services DevicesApplications
  • 14Pivotal Confidential–Internal Use Only RabbitMQ: Run Everywhere, Connect Anything Hundreds of other clients C Frameworks Languages Operating Systems
  • 15Pivotal Confidential–Internal Use Only • Problem: A tightly coupled Grails Application is serving ads to a web page. Ads are refreshed every four hours, using a synchronous batch update process. Then, a new business guideline is introduced, which requires the refresh rate of the ads to be increased by 50 percent. • Solution: To increase the refresh rate without putting additional strain on the existing servers, employ a solution utilizing RabbitMQ. Instead of having a Quartz Job run every four hours to call one service, reconfigure the Quartz Job to run every hour and post messages to a queue. Once a message becomes available on the queue, other servers are on standby to read it and then refresh the given segment of ads. • Benefits of using RabbitMQ: – separate requests and actions – scalability – ease of increasing processing capabilities – ability to have apps coded in different languages communicate with one another – great for batch processing in an asynchronous manner http://www.wapolabs.com/2012/02/07/leveraging-rabbitmq-to-decouple-your-application/ Leveraging RabbitMQ to decouple a webapp Synchronous batch update process RabbitMQ solution
  • 16Pivotal Confidential–Internal Use Only Government of India: UIADI • One of the largest IT projects ever • Biggest online identity project in the world • Enabling social services and microfinance for 1.2 billion people • Very significant countrywide infra with many moving parts http://www.biometrics.org/bc2012/presentations/UIDAI/Technology_Tampa_v1040.pdf
  • 17Pivotal Confidential–Internal Use Only
  • 18Pivotal Confidential–Internal Use Only BBC Zeitgeist Zeitgeist is a prototype developed by BBC Research & Development to discover and track the most shared BBC webpages on Twitter. http://www.bbc.co.uk/blogs/researchanddevelopment/2010/09/what-makes-zeitgeist-tick.shtml
  • 19Pivotal Confidential–Internal Use Only Number of connected devices is growing Source: McKinsey, May 2011
  • 20Pivotal Confidential–Internal Use Only 1 Sensor with MQTT client 2 Pivotal RabbitMQ 3 Spring AMQP Spring Hadoop & XD Pivotal tc Server 4 Pivotal HD Use Case: Big Data Applications How Pivotal components fit together
  • 21Pivotal Confidential–Internal Use Only • The rabbitmq-management plugin provides an HTTP-based API for management and monitoring the RabbitMQ broker • Two tools are provided that use this API: • A powerful browser-based UI • A powerful command line tool (rabbitmqadmin) • rabbitmqadmin can perform the same actions as the web-based UI, and is convenient for use when scripting • Or you can use the API to develop your own tools... RabbitMQ: management and monitoring
  • 22Pivotal Confidential–Internal Use Only RabbitMQ: management and monitoring
  • 23Pivotal Confidential–Internal Use Only RabbitMQ: management and monitoring
  • 24Pivotal Confidential–Internal Use Only www.github.com/gopivotal