Top Banner
Microservice Plumbing With RabbitMQ ASYNC MESSAGING FOR MICROSERVICES @jsonrow [email protected] https://github.com/JasonRowe
24

MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

Jul 19, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

Microservice PlumbingWithRabbitMQASYNC MESSAGINGFORMICROSERVICES

@[email protected]

https://github.com/JasonRowe

Page 2: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

AboutMe

@JSONROW

jasonrowe.com

PastAsync MessagingExperience• MSMQ• NServiceBus• MassTransit

CurrentTechStack• .NETCore• RabbitMQ• Docker• Vue.JS

Page 3: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

RabbitMQ OverviewWhatisRabbitMQ?

@JSONROW

Page 4: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

WhatisAMQP?AdvancedMessageQueueProtocol

Openinternetprotocolforbusinessmessaging

Binarywire-levelprotocol

AMQPwasdesignedwiththefollowingmaincharacteristicsasgoals:

Security

Reliability

Interoperability

Standard

Open

@JSONROW

Page 5: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

AMQPModel

Exchange->Binding->[Queue]

Exchanges

Receivesandroutesmessages

Binding

Definestherelationshipbetweenexchangeandqueue

Queues

Storesmessagesuntiltheyareprocessed

@JSONROW

Page 6: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

RabbitMQ Hello,world.

@JSONROW

Page 7: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

RabbitMQ – changingamonolith

@JSONROW

P/C P/C P/C

P CX Q

P

C

C

BigChallenge- changingthecommunicationpattern.

Page 8: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

MessageDurabilityPublisherconfirms

Durabilityexchangesandqueues

message acknowledgements

Deliveryandprocessingconfirmation

@JSONROW

Page 9: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

MessagePublishing

@JSONROW

MessagePublishinginRabbitMQ,by GavinMRoy

Page 10: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

ReceivingMessages

@JSONROW

MessagePublishinginRabbitMQ,by GavinMRoy

Page 11: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

HighAvailability

EnablePublisherconfirms

UseDurablequeues,exchanges

Extensionstoconsider- consistentlyhashandsharding

DonotenableHiPE

Prefetch configuration

MultinodeswithHApolicy

@JSONROW

Page 12: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

HighPerformanceEnableHiPE

DisableLazyQueue

Shortqueues

TransientMessages

DisableHA

@JSONROW

Page 13: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

MyRecentRabbitMQ successstory.RefiningaservicesboundariesandswitchingtoRabbitMQ

@JSONROW

Page 14: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

RecentRabbitMQ successstory.

0

10,000

20,000

30,000

40,000

50,000

60,000

70,000

Run1 Run2 Run3

AverageTime(m

s)

Baselinetestruns

Legacy RabbitMQ

@JSONROW

Page 15: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

DirectExchange

Publisher DirectexchangeCreatedModifiedDeleted

RoutingKeys

Queue

Queue

Queue

Consumer

Consumer

Consumer

@JSONROW

Modified

Bindings

Page 16: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

Fanoutexample

P

C

Fanoutexchange

QueueA

QueueB

QueueC

@JSONROW

C

C

Page 17: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

TopicexchangeexampleWildcardroutingbyroutingkey*(star)cansubstituteforexactlyoneword.#(hash)cansubstituteforzeroormorewords.

@JSONROW

P Topicexchange

Q

Q

Q

C

C

C

*.*.mdc

Bindings

Page 18: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

AnalysisRequestExample

@JSONROW

P X

Q

cnc.emea

C

AnalysisRequest

Q

Q

C

C 3DPAmericaAnalysis

CNCUKAnalysis

InjectionMoldingJapanAnalysis

Q C AnalysisArchive

Page 19: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

CompetingConsumers

@JSONROW

Page 20: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

Rabbitmq UseCasesGood

EventStream

Connectingappsnewandoldwrittenindifferentlanguages

WhenyouareuncertainRabbitMQ isacertainchoice

multiprotocolandpatterns

Federationbetweendatacenters

Bad

Largebinaryvideosandimages

Useasadatastorelargequeues

@JSONROW

Page 21: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

LessonsLearnedMajorRabbitMQ upgradesandErlang upgradescomeswithsomedowntimeevenonmulti-nodeclusters.(bluegreen)

Connections- don'topennewconnectionswitheverymessage.Don'tletqueuesgrow10,000messagesistoomuchlimitwithTTLormaxsizeSendpersistentmessagesandusedurablequeuesandexchangeUsepublisherconfirmswhenitmakessenseTakealookatprefetch andadjustifneeded

@JSONROW

Page 22: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

MonitoringQueueLength

MissingConsumers

Howlongmessageshavebeeninqueue

CPU,RAM,Disk

https://www.rabbitmq.com/production-checklist.html

@JSONROW

Page 23: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

Summary• RabbitMQ isagreatsolutionforconnectingasync messagingforMicroservices

• RabbitMQ providesoptionsforhighperformanceandhighreliability

• Messagingdoesn’tneedtobehard,itcanbeboring,andboringisgood.

• It’sageneralpurposemessagingsystemthatmaybetherightchoicetohelpbreakupyourmonolithorconnectourmicroservices

@JSONROW

Page 24: MicroservicePlumbing With RabbitMQ - Ilm€¦ · • Docker • Vue.JS. RabbitMQOverview What is RabbitMQ? @JSONROW. What is AMQP? Advanced Message Queue Protocol Open internet protocol

Questions?

@JSONROW