+ All Categories
Home > Engineering > Consuming RabbitMQ at TTL

Consuming RabbitMQ at TTL

Date post: 08-Aug-2015
Category:
Upload: jeanml
View: 1,470 times
Download: 2 times
Share this document with a friend
Popular Tags:
36
Consuming Rabbit MQ JM Laplante Developer @ Trainline.com
Transcript
Page 1: Consuming RabbitMQ at TTL

Consuming Rabbit MQ

JM LaplanteDeveloper @ Trainline.com

Page 2: Consuming RabbitMQ at TTL

What can you use it for?

Page 3: Consuming RabbitMQ at TTL

Pub-Sub

Publisher 1

Subscriber 1

Publisher X

Publisher 2

...

Subscriber 2

Subscriber Y

...

Event A

Event B

Event C

Event A

Event B

Event B

Page 4: Consuming RabbitMQ at TTL

Remote ProcedureCall

Provider

Requester

ResponseCorId: 123

RequestCorId: 123

RequestCorId: 123

ResponseCorId: 123

Page 5: Consuming RabbitMQ at TTL

AsyncJobProcessing

Worker 1

Requester

Worker N...

Job Request 1

...

Job Request N

Job Request 1 Job Request N

Page 6: Consuming RabbitMQ at TTL

Warnings

•RabbitMQ is happier when queues are empty

•RabbitMQ ≠ Data Store

•Connections are precious

•Shared infrastructure*• Poor design decisions have an impact on other components

Page 7: Consuming RabbitMQ at TTL

What are routing topologies?

Page 8: Consuming RabbitMQ at TTL

Publisher

Consumer

PublishingExchange

ConsumingQueue

Page 9: Consuming RabbitMQ at TTL

Routing Topology (Simplest)

Publisher

Consumer

ConsumingQueue

PublishingExchange

Fanout

Page 10: Consuming RabbitMQ at TTL

Routing Topology (Complex)

Publisher

Consumer

ConsumingQueue

PublishingExchange

Fanout

Exchange A Exchange B Exchange C

Subscription Exchange ?

Remote Location

Local Broker B

Remote Consumer

OtherConsumer

Federated FederatedRouting Key

Page 11: Consuming RabbitMQ at TTL

Routing Topology

Proposed approachfor Pub-Sub

Publisher

Consumer

ConsumingQueue

PublishingExchange

Fanout

Routing Exchange

Subscription Exchange

Routing Key Topic

Routing Key

Fanout

Page 12: Consuming RabbitMQ at TTL

What if things fail?

Page 13: Consuming RabbitMQ at TTL

Designing applications for failure•Connections can drop at all times•Nodes can die at all times

•Protect yourself:• Client library should manage connections• Talk to load balancer, not specific nodes• Publish with a circuit breaker library

Page 14: Consuming RabbitMQ at TTL

Designing applications for failure•RabbitMQ delivers messages at least once

RabbitMQ delivers messages at least

once

Page 15: Consuming RabbitMQ at TTL

RabbitMQ

Page 16: Consuming RabbitMQ at TTL

delivers messag

es

Page 17: Consuming RabbitMQ at TTL

at least ONCE

Page 18: Consuming RabbitMQ at TTL

Designing applications for failure•Message processing should be idempotent

•What will happen if a message is processed twice?•No single answer• Immutability goes a long way• Be mindful of side effects

Page 19: Consuming RabbitMQ at TTL

Designing applications for failure•What happens if message processing fails?• Error queues•Dead-letter exchanges

•How will you know?

•How will you replay messages?• Custom-built application• Shovel plugin

Page 20: Consuming RabbitMQ at TTL

How fast is it?

Page 21: Consuming RabbitMQ at TTL

Performance

•RabbitMQ can be very fast• Tens of thousands of messages per second

•Key considerations•Manage connections well•Do you really need publish confirmations?•Do you need message persistence?•Do you need high availability?•How much security should be put in place?

Page 22: Consuming RabbitMQ at TTL

AMQP Transactions vs ‘Publisher Confirms’

Publisher

SynchronousAck

Publisher

AsynchronousAckSLOW FASTER

(100x)

Page 23: Consuming RabbitMQ at TTL

Message Persistence

•Messages that ‘should’ survive broker restart

• Inconsistent publishing times•Disk writes not always consistent (e.g. cheap disk/AWS)

•Do you really need it?

Page 24: Consuming RabbitMQ at TTL

Message Persistence

Website(Matrix)

Add Item To Shopping Basket

Page 25: Consuming RabbitMQ at TTL

Message Persistence

Mobile API

Take Money from Credit Card

Page 26: Consuming RabbitMQ at TTL

Message Persistence

Payment System

Payment Accepted

Page 27: Consuming RabbitMQ at TTL

What about security?

Page 28: Consuming RabbitMQ at TTL

Authentication

• Username/Password for

client applications

• Virtual Host segregation

Client A

ValidCredential

Client A

InvalidCredential

Default vHost

Super Secure vHost

Page 29: Consuming RabbitMQ at TTL

Authorisation

Publisher

Publishing Exchange A

Publishing Exchange B

Consumer

Queue A Queue B

Page 30: Consuming RabbitMQ at TTL

Encryption

•AMQP• Communication channel is not encrypted

•AMQPS• Communication channel is encrypted using SSL• Optional: Exchange signed certificates• Optional: Verify certificates to establish chain of trust

•How much is enough for your data?

Page 31: Consuming RabbitMQ at TTL

How can I monitor my app?

Page 32: Consuming RabbitMQ at TTL

New Relic

•Plugin developed internally•Queue monitoring (Ready/Total messages)• Consumers (Active/Total)•Memory consumption

Page 33: Consuming RabbitMQ at TTL

Circuit Breaker Dashboard

•SCOM alerts

Page 34: Consuming RabbitMQ at TTL

Any .NET client libraries?

Page 35: Consuming RabbitMQ at TTL

Libraries

•RabbitMQ Client API•EasyNetQ (http://easynetq.com/)

• Wrapper around RabbitMQ Client API• Open Source, Well supported, MIT license• Using IAdvancedBus, not IBus*

Page 36: Consuming RabbitMQ at TTL

Questions?


Recommended