RabbitMQ & Hutch

35
RabbitMQ & Hutch Pete Hamilton - GoCardless

description

Talk I gave at LRUG about RabbitMQ, how we're using it at GoCardless and the some tools we built - Hutch and AMQPC Hutch is an opinionated library for RabbitMQ which makes using it for comms in SOA super simple

Transcript of RabbitMQ & Hutch

Page 1: RabbitMQ & Hutch

RabbitMQ & HutchPete Hamilton - GoCardless

Page 2: RabbitMQ & Hutch

About Me

• Developer at GoCardless

• CompSci Student at ICL

• Github: https://github.com/petehamilton

• Blog: pete-hamilton.co.uk

• Twitter: @peterejhamilton

Page 3: RabbitMQ & Hutch

SOA CommunicationA (very) brief overview

Awesome Service

Page 4: RabbitMQ & Hutch

SOA CommunicationA (very) brief overview

Awesomer Services

Page 5: RabbitMQ & Hutch

SOA CommunicationA (very) brief overview

Awesomer Services

Page 6: RabbitMQ & Hutch

SOA CommunicationA (very) brief overview

?Client - Server?

Message Queues?

Page 7: RabbitMQ & Hutch

RabbitMQ

Page 8: RabbitMQ & Hutch

RabbitMQWhy?

• Nice Learning Curve

• Reliable

• Active Community

• Polyglot

• Scalable

• Proven itself in battle production

Page 9: RabbitMQ & Hutch

RabbitMQWhy?

• Payments are pretty serious stuff

• Async = Potential problems

• Network Failure?

• Consumer Crashes?

• Duplication/redelivery?

• RabbitMQ helps with confirms, acknowledgements, mandatory flags

Page 10: RabbitMQ & Hutch

RabbitMQ Routing

P X

C1

C2

Q1

Q2

Page 11: RabbitMQ & Hutch

Fanout Exchange

RabbitMQ Routing

P X

C1

C2

Q1

Q2

Page 12: RabbitMQ & Hutch

Direct Exchange

RabbitMQ Routing

P X

C1

C2

type=direct

fireflystar_trek

big_bang_theory

Q1

Q2

Page 13: RabbitMQ & Hutch

Topic Exchange

RabbitMQ Routing

P X

C1

C2

type=topic

tv.scifi.*

tv.comedy.*

C3

tv.#

Q1

Q2

Q3Sample Message Routing Keys:- tv.comedy.big_bang_theory- tv.scifi.firefly- tv.scifi.star_trek

Page 14: RabbitMQ & Hutch

RabbitMQ

• Very Flexible, but...

• Which data structure do you use?

• How do you serialise your data?

• Which fields do you require in your messages?

• How should messages be routed? fan out? direct? topically?

• How do new nodes set themselves up?

• What form should “Boiler Plate” code take?

Page 15: RabbitMQ & Hutch

A system for processing RabbitMQ messages in Ruby

Page 16: RabbitMQ & Hutch

• Our Conventions (Warning: Opinions!)

• Topic Exchange Routing

• Serialisation w/ JSON

• Message IDs and Timestamps

• Simple to use

• Configurable

• Specific ruby files or full Rails apps

Page 17: RabbitMQ & Hutch

Publisher

Page 18: RabbitMQ & Hutch

Consumer

Page 19: RabbitMQ & Hutch
Page 20: RabbitMQ & Hutch
Page 21: RabbitMQ & Hutch
Page 23: RabbitMQ & Hutch

RabbitMQScaling

• Good guide to clustering online

• Potential for issues with multiple nodes

Page 24: RabbitMQ & Hutch

RabbitMQScaling

• Good guide to clustering online

• Potential for issues with multiple nodes

S S

M

C1

Page 25: RabbitMQ & Hutch

RabbitMQScaling

• Good guide to clustering online

• Potential for issues with multiple nodes

S S

M

x C1

Page 26: RabbitMQ & Hutch

RabbitMQScaling

• Good guide to clustering online

• Potential for issues with multiple nodes

S S

M

x C1

Page 27: RabbitMQ & Hutch

RabbitMQScaling

• Good guide to clustering online

• Potential for issues with multiple nodes

S S

M

C1

Page 28: RabbitMQ & Hutch

RabbitMQScaling

• Good guide to clustering online

• Potential for issues with multiple nodes

S S

M

C1

x

Page 29: RabbitMQ & Hutch

RabbitMQScaling

• Good guide to clustering online

• Potential for issues with multiple nodes

M S

M

C1

x

Page 30: RabbitMQ & Hutch

RabbitMQScaling

• Good guide to clustering online

• Potential for issues with multiple nodes

• Clients exist for load testing, but...

• We wanted ++ parallelism

• Built “AMQPC”

Page 31: RabbitMQ & Hutch

AMQPC

• Written in Go

• Producer & Consumer modes

• Traffic Modes

• One off burst

• Intermittent burst

• Consistent load

Page 32: RabbitMQ & Hutch

AMQPC

Page 34: RabbitMQ & Hutch

Useful Links

• Hutch - www.github.com/gocardless/hutch

• AMQPC - www.github.com/gocardless/amqpc

• RabbitMQ - http://www.rabbitmq.com/getstarted.html

Page 35: RabbitMQ & Hutch

Questions?