57
RabbitMQ Overview Tony Garnock-Jones <[email protected]> Wednesday, 19 August 2009

RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

RabbitMQ OverviewTony Garnock-Jones <[email protected]>

Wednesday, 19 August 2009

Page 2: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Agenda

• AMQP in 3 minutes

• RabbitMQ architecture

• Availability, Clustering, Federation

• Durability, Persistence, Memory usage

• Security

• Operational Tools

• Ongoing work

Wednesday, 19 August 2009

Page 3: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

AMQP

Wednesday, 19 August 2009

Page 4: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

AMQP Basics

• Exchanges perform relaying, copying, and filtering

• Queues perform buffering and round-robin delivery

X

PC

X

P

C

C

(0-9-1)

Wednesday, 19 August 2009

Page 5: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

AMQP Basics

ExchangesX

QueuesQ

bind to

(0-9-1)

App

App

Producers

Consumers

publish to

deliver to

Wednesday, 19 August 2009

Page 6: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

PubSub

• AMQP exchange used as the destination copies to multiple queues

• Per-consumer private queues receive topical messages

XP

C

C

Wednesday, 19 August 2009

Page 7: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Queueing

• Using the default exchange (“”) routes directly to queues

• Both shared and private queues can be addressed like this

PC

C

Wednesday, 19 August 2009

Page 8: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Simple load-balancing

• Shared queue mediates access to service instances

• Load-balancing, live upgrades, fault-tolerance

Request Queue

(Private)ReplyQueue

Wednesday, 19 August 2009

Page 9: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

RabbitMQ

Wednesday, 19 August 2009

Page 10: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Code Overview

(out of date numbers! it’s ~7500 LoC now, mid 2009)

Wednesday, 19 August 2009

Page 11: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Concurrency

Wednesday, 19 August 2009

Page 12: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Order Preservation

Wednesday, 19 August 2009

Page 13: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Clustering

Wednesday, 19 August 2009

Page 14: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Clustering

Erlang Node

Message Store

Physical Machine

Listening Socket

Virtual Host

Erlang’s inter-nodemessage routing

Wednesday, 19 August 2009

Page 15: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Connectivity

Wednesday, 19 August 2009

Page 16: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Availability,Clustering,Federation

Wednesday, 19 August 2009

Page 17: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Failover

• Split “availability” into

• Service availability: a broker’s ready when you need one

• Data availability: your persisted messages survive failures

• Short outage during failover; non-ack’d messages will need to be retransmitted

• Need better? Use redundant data paths

Wednesday, 19 August 2009

Page 18: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Failover

• Off-the-shelf components:

• Networked fsync()able filesystem

• Failure monitor: Linux-HA, ping + virtual ethernet, ...

Wednesday, 19 August 2009

Page 19: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

FailoverC

X X

P

SAN

PrimaryWarm standby

mnesia + message journal

Wednesday, 19 August 2009

Page 20: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Redundancy for HA

X

P

C

X X

P

C

XOne broker,

two nodes each

Two brokers,

one node each

Wednesday, 19 August 2009

Page 21: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Exactly-Once Delivery

• “guaranteed delivery”, even with intermittent links

• “auto-deduplication”

Broker

Client

Client

Wednesday, 19 August 2009

Page 22: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Paul Baran’s NetworksPaul Baran, Introduction to Distributed Communications Networks, 1964

Wednesday, 19 August 2009

Page 23: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Clustering

Wednesday, 19 August 2009

Page 24: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

WAN ClusterThe WAN cluster has local queues but global exchanges

Apps decide which broker-cluster to publish to

Wednesday, 19 August 2009

Page 25: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

SynchronisationWhen clustering might not be right:

• huge networks

• intermittent connectivity

• ruling bandwidth with an iron fist

• different administrative domains

Wednesday, 19 August 2009

Page 26: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Synchronisation

Wednesday, 19 August 2009

Page 27: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Ring

Pass it on to your neighbour if your neighbour’s name isn’t in the list yet

Wednesday, 19 August 2009

Page 28: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

CompleteGraph

Pass it on to your neighbour if it hasn’t been labelled at all yet

Wednesday, 19 August 2009

Page 29: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Multicast

Pass it on to your neighbour if it hasn’t been labelled at all yet

Wednesday, 19 August 2009

Page 30: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Durability, Persistence & Memory Usage

Wednesday, 19 August 2009

Page 31: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Terminology

• Durable: resource (exchange, queue, binding) that survives broker restart

• Persistent: message that survives broker restart

• Durability and persistence required for robust storage at the broker

Wednesday, 19 August 2009

Page 32: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Persister: Old

• Old persister slows down dramatically once a backlog builds up

• Old persister uses disk as a backup only: still limited by RAM + swap

• Once swap runs out, it’s all over

Wednesday, 19 August 2009

Page 33: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Persister: New

• New persister doesn’t slow down with backlog

• New persister doesn’t overflow RAM(but does make good use of the RAM you have installed!)

• Automatic or manual decision when to switch to disk and then disk-only mode

• Carefully tuned to give good default behaviour

Wednesday, 19 August 2009

Page 34: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

32B, Backlog 5,000

Wednesday, 19 August 2009

Page 35: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

32B, Backlog 10,000

Wednesday, 19 August 2009

Page 36: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

32B, Backlog 20,000

Wednesday, 19 August 2009

Page 37: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

32B, Backlog 40,000

Wednesday, 19 August 2009

Page 38: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

32B, Backlog 80,000

Wednesday, 19 August 2009

Page 39: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

1MB, Backlog 125

Wednesday, 19 August 2009

Page 40: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

1MB, Backlog 250

Wednesday, 19 August 2009

Page 41: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

1MB, Backlog 500

Wednesday, 19 August 2009

Page 42: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

1MB, Backlog 1,000

Wednesday, 19 August 2009

Page 43: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

1MB, Backlog 2,000

Wednesday, 19 August 2009

Page 44: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

1MB, Backlog 4,000

Wednesday, 19 August 2009

Page 45: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Persister: Summary

• Fast (slower than old persister, but still fast)

• Scales to fill your disks without filling RAM

• In QA at the moment; will land for 1.7

Wednesday, 19 August 2009

Page 46: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Security

Wednesday, 19 August 2009

Page 47: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Resource ACLs

• Users are granted access to each vhost

• Each user has three regular expressions:

• for Administrative actions (create, delete)

• for Reading (bind from exch, consume from queue)

• for Writing (publish to exch, bind to queue)

Wednesday, 19 August 2009

Page 48: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Encryption, PKI

• Securing the Transport

• stunnel4

• native SSL support in final QA

• Securing the Messages

• key directory + per-message encryption and signing

Wednesday, 19 August 2009

Page 49: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Operational Tools

Wednesday, 19 August 2009

Page 50: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

rabbitmqctl

Wednesday, 19 August 2009

Page 51: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

BDL

Wednesday, 19 August 2009

Page 52: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Munin plugins

Wednesday, 19 August 2009

Page 53: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

RESTful APIs: TrixxGET http://localhost:8080/exchanges/:vhostPOST http://localhost:8080/exchangesGET http://localhost:8080/queues/:vhostPOST http://localhost:8080/queuesGET http://localhost:8080/bindings/:vhostGET http://localhost:8080/vhostsPOST http://localhost:8080/vhostsGET http://localhost:8080/connectionsGET http://localhost:8080/users/:user/permissions

GET http://localhost:8080/usersPUT http://localhost:8080/users

POST http://localhost:8080/users

DELETE http://localhost:8080/users/:user

GET http://localhost:8080/rabbit/statusPUT http://localhost:8080/rabbit/startPUT http://localhost:8080/rabbit/stopPUT http://localhost:8080/rabbit/reset

POST http://localhost:8080/sessions/authenticate

Wednesday, 19 August 2009

Page 54: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

RESTful APIs: Alice /conn - Current connection information /exchanges - Current exchanges information /queues - Current queues /users - Current users /bindings - Current bindings /control - Access to the RabbitMQ control /permissions - Current permissions /vhosts - Current vhosts

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

auser $ curl -i -XPOST \ -d'{"username":"ari", "password":"weak password"}' \ http://localhost:9999/users HTTP/1.1 200 OKServer: MochiWeb/1.0 (Any of you quaids got a smint?)Date: Thu, 16 Jul 2009 00:10:35 GMTContent-Type: text/jsonContent-Length: 25

{"users":["ari","guest"]}

Wednesday, 19 August 2009

Page 55: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Web UIs: Trixx

Wednesday, 19 August 2009

Page 56: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Web UIs: Wonderland

Wednesday, 19 August 2009

Page 57: RabbitMQ Overviewtech.labs.oliverwyman.com/downloads/dev.lshift.net/... · AMQP Basics • Exchanges perform relaying, copying, and filtering • Queues perform buffering and round-robin

Other ongoing projects• Management

• SNMP

• JMX, HermesJMS

• Presence, meta-events

• AMQP Protocol extensions for management

• Gateways, federation

• RabbitHub (HTTP)

• Multicast

• XMPP, JMS bridges

• AMQP Protocol extensions for generalised gatewaying

Wednesday, 19 August 2009