45
Achieving Scale with Messaging & the Cloud Tony Garnock-Jones <[email protected]> 1 Thursday, 9 July 2009

Achieving Scale With Messaging And The Cloud 20090709

Embed Size (px)

Citation preview

Page 1: Achieving Scale With Messaging And The Cloud 20090709

Achieving Scale with Messaging & the Cloud

Tony Garnock-Jones <[email protected]>

1Thursday, 9 July 2009

Page 2: Achieving Scale With Messaging And The Cloud 20090709

Outline

• Messaging – what, why

• Cloud Messaging – some examples

• Achieving Scale – what, why, how

2Thursday, 9 July 2009

Page 3: Achieving Scale With Messaging And The Cloud 20090709

Messaging

3Thursday, 9 July 2009

Page 4: Achieving Scale With Messaging And The Cloud 20090709

Messaging Elements...relaying, filtering, multicasting, forwarding, buffering,

distribution/scheduling, subscription, topics, streaming, ...

ElementElement

Element

Element

Element

Element

...

...

4Thursday, 9 July 2009

Page 5: Achieving Scale With Messaging And The Cloud 20090709

What is it good for?

• debuggability

• manageability

• monitorability

• rolling upgrades

• load-balancing

• cross-language integration

• fault-tolerance

• store-and-forward

• ...

Decoupling communication from behaviour, enabling:

5Thursday, 9 July 2009

Page 6: Achieving Scale With Messaging And The Cloud 20090709

Messaging Elements...relaying, filtering, multicasting, forwarding, buffering,

distribution/scheduling, subscription, topics, streaming, ...

Elementmessage

messages

subscribe unsubscribe

6Thursday, 9 July 2009

Page 7: Achieving Scale With Messaging And The Cloud 20090709

Messaging Elements

• Delivery:

• deliver(target, message);

• Subscription:

• bind(source, topic, target);

• unbind(source, topic, target);

7Thursday, 9 July 2009

Page 8: Achieving Scale With Messaging And The Cloud 20090709

AMQP for Messaging

• Exchanges perform relaying, copying, and filtering

• Queues perform buffering and round-robin delivery

X

PC

X

P

C

C

8Thursday, 9 July 2009

Page 9: Achieving Scale With Messaging And The Cloud 20090709

It’s Easy

QueueingConsumer consumer = new QueueingConsumer(ch);ch.basicConsume(queueName, consumer);while (true) { QueueingConsumer.Delivery delivery = consumer.nextDelivery(); // ... use delivery.getBody(), etc ... ch.basicAck(delivery.getEnvelope().getDeliveryTag(), false);}

ch.queueBind(queueName, exchange, routingKeyPattern);

byte[] body = ...;ch.basicPublish(exchange, routingKey, null, body);

9Thursday, 9 July 2009

Page 10: Achieving Scale With Messaging And The Cloud 20090709

RabbitMQ Universe

...plus new developments like

RabbitHub, BBC FeedsHub, Trixx, ...

10Thursday, 9 July 2009

Page 11: Achieving Scale With Messaging And The Cloud 20090709

Cloud Messaging

11Thursday, 9 July 2009

Page 12: Achieving Scale With Messaging And The Cloud 20090709

Examples

• Soocial are using RabbitMQ + EC2 to coordinate their contacts-database synchronisation application

• The Ocean Observatories Initiative is using RabbitMQ + relays + gateways for a global sensing & data distribution network

12Thursday, 9 July 2009

Page 13: Achieving Scale With Messaging And The Cloud 20090709

Soocial.com

13Thursday, 9 July 2009

Page 14: Achieving Scale With Messaging And The Cloud 20090709

OOI – Ocean Observatories Initiative

14Thursday, 9 July 2009

Page 15: Achieving Scale With Messaging And The Cloud 20090709

OOI – Ocean Observatories Initiative

Service.DomainName

Region Virtual IP

Cloud IPs

15Thursday, 9 July 2009

Page 16: Achieving Scale With Messaging And The Cloud 20090709

Nanite

• Developed by Ezra Zygmuntowicz at Engineyard

• Presence

• Self-assembling compute fabric

• Load-balancing & recovers from failure

• An easy way of deploying to the cloud

(by pinging; we’re still working out the best way of putting presence into RabbitMQ itself)

16Thursday, 9 July 2009

Page 17: Achieving Scale With Messaging And The Cloud 20090709

VPN3 (VPN-cubed)

• A secure Virtual Private Network in the cloud

• Uses RabbitMQ as a backend for IP multicast (!) which otherwise doesn’t work in EC2

• Uses BGP to arrange routing between nodes

• Can meld your datacentre(s) with EC2

17Thursday, 9 July 2009

Page 18: Achieving Scale With Messaging And The Cloud 20090709

Achieving Scale

18Thursday, 9 July 2009

Page 19: Achieving Scale With Messaging And The Cloud 20090709

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

19Thursday, 9 July 2009

Page 20: Achieving Scale With Messaging And The Cloud 20090709

• Capacity – throughput, latency, responsiveness

• Synchronisation & Sharing

• Availability – uptime, data integrity

• Network Management – lots of devices, lots of addresses, authentication & authorisation

Achieving Scale

20Thursday, 9 July 2009

Page 21: Achieving Scale With Messaging And The Cloud 20090709

Capacity

• Service capacity: bandwidth, throughput

• Service responsiveness: latency

• Data capacity: storage

21Thursday, 9 July 2009

Page 22: Achieving Scale With Messaging And The Cloud 20090709

Simple load-balancing

• Shared queue mediates access to service instances

• Load-balancing, live upgrades, fault-tolerance

Request Queue

(Private)ReplyQueue

22Thursday, 9 July 2009

Page 23: Achieving Scale With Messaging And The Cloud 20090709

Clustering

23Thursday, 9 July 2009

Page 24: Achieving Scale With Messaging And The Cloud 20090709

Clustering

24Thursday, 9 July 2009

Page 25: Achieving Scale With Messaging And The Cloud 20090709

Clustering

Erlang Node

Message Store

Physical Machine

Listening Socket

Virtual Host

Erlang’s inter-nodemessage routing

25Thursday, 9 July 2009

Page 26: Achieving Scale With Messaging And The Cloud 20090709

Divide and Conquer

• By record – parallelisable data lets separate broker clusters handle separate shards of your data

• By component – each independent part of your application can use separate brokers; “federation of distributed systems”

26Thursday, 9 July 2009

Page 27: Achieving Scale With Messaging And The Cloud 20090709

WAN ClusterThe WAN cluster has local queues but global exchanges

Apps decide which broker-cluster to publish to

27Thursday, 9 July 2009

Page 28: Achieving Scale With Messaging And The Cloud 20090709

Overfeeding the server

• Message backlogs can cause catastrophe

• Goal: O(0) RAM cost per message

• Spool out to disk when memory pressure gets high

• Testing and tuning: should land for RabbitMQ 1.7

28Thursday, 9 July 2009

Page 29: Achieving Scale With Messaging And The Cloud 20090709

SynchronisationWhen clustering might not be right:

• huge networks

• intermittent connectivity

• ruling bandwidth with an iron fist

• different administrative domains

29Thursday, 9 July 2009

Page 30: Achieving Scale With Messaging And The Cloud 20090709

Synchronisation

30Thursday, 9 July 2009

Page 31: Achieving Scale With Messaging And The Cloud 20090709

Ring

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

31Thursday, 9 July 2009

Page 32: Achieving Scale With Messaging And The Cloud 20090709

CompleteGraph

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

32Thursday, 9 July 2009

Page 33: Achieving Scale With Messaging And The Cloud 20090709

Multicast

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

33Thursday, 9 July 2009

Page 34: Achieving Scale With Messaging And The Cloud 20090709

Availability

• Broker Availability

• Application/Service Availability

• Data Availability

34Thursday, 9 July 2009

Page 35: Achieving Scale With Messaging And The Cloud 20090709

Responsibility transferConsumer Broker

basic.ack

basic.deliver

basic.deliver

basic.deliver

...

35Thursday, 9 July 2009

Page 36: Achieving Scale With Messaging And The Cloud 20090709

Responsibility transferProducer Broker

tx.commit

tx.commit-ok

basic.publish

basic.publish

basic.publish

...

36Thursday, 9 July 2009

Page 37: Achieving Scale With Messaging And The Cloud 20090709

Responsibility transferProducer Broker

... ...

Consumer

37Thursday, 9 July 2009

Page 38: Achieving Scale With Messaging And The Cloud 20090709

Responsibility transferProducer Broker Consumer

38Thursday, 9 July 2009

Page 39: Achieving Scale With Messaging And The Cloud 20090709

Redundancy for HA

Pfailure = (Ploss)n

(assuming independence)39Thursday, 9 July 2009

Page 40: Achieving Scale With Messaging And The Cloud 20090709

Redundancy for HA

Pfailure = (Ploss)n

(assuming independence)

Uptime Ploss n Pfailure Overall Uptime99% 0.01 2 0.0001 99.99%99% 0.01 3 0.000001 99.9999%

99.9% 0.001 2 0.000001 99.9999%99.9% 0.001 3 0.000000001 99.9999999%

39Thursday, 9 July 2009

Page 41: Achieving Scale With Messaging And The Cloud 20090709

Redundancy for HA

X

P

C

X X

P

C

XOne broker,

two nodes each

Two brokers,

one node each

40Thursday, 9 July 2009

Page 42: Achieving Scale With Messaging And The Cloud 20090709

Deduplication(“Idempotency Barrier”)

many messages enter

one message leaves

id=123

id=123

id=123

id=123

41Thursday, 9 July 2009

Page 43: Achieving Scale With Messaging And The Cloud 20090709

Network Management

• Small systems can be managed by hand

• Large systems need automation:

• Naming & address management

• Service directories

• Authentication & authorization

• Logging, monitoring & alerting

42Thursday, 9 July 2009

Page 44: Achieving Scale With Messaging And The Cloud 20090709

The Future

43Thursday, 9 July 2009

Page 45: Achieving Scale With Messaging And The Cloud 20090709

Questions?http://www.rabbitmq.com/how

44Thursday, 9 July 2009