Beginning Microservices with .NET & RabbitMQ
-
Upload
paul-mooney -
Category
Software
-
view
897 -
download
4
Transcript of Beginning Microservices with .NET & RabbitMQ
![Page 1: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/1.jpg)
Microservice Architecture
Beginning Microservices with .NET & RabbitMQ
Paul Mooney@daishisystems | www.insidethecpu.com
![Page 2: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/2.jpg)
Overview
Microservice design based on real-world examples
Focus on, but not restricted to .NET and RabbitMQ
Design Patterns
Decoupled Middleware
Circuit Breaker
Flyball Governor
Implementation Problems
Consistent Message Delivery
Load balancing a RabbitMQ Cluster
Selling to the Business
![Page 3: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/3.jpg)
Decoupled MiddlewareD
isp
atch
erR
ece
iver
ASP.NET
Receiver
Disp
atch
er
SimpleMathMicroservice
Input Queue
Output Queue
Message Bus
![Page 4: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/4.jpg)
Decoupled Middleware
Microservice Daemon
Message Dispatcher
Event Listener
Microservice Daemon
Event Listener
Message Dispatcher
Service Bus
Queue #1
Queue #2
Message Message
Message Message
![Page 5: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/5.jpg)
Circuit Breaker
Filter
Cir
cuit
Bre
aker
Service
Fea
ture
1Featu
re 2Fe
atu
re 3
Client
Request
![Page 6: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/6.jpg)
Circuit Breaker
Filter
Cir
cuit
Bre
aker
Service
Fea
ture
1Featu
re 2Fe
atu
re 3
Client
requestCount < threshHold
![Page 7: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/7.jpg)
Circuit Breaker
Filter
Cir
cuit
Bre
aker
Service
Fea
ture
1Featu
re 2Fe
atu
re 3
Client
RequestrequestCount >= threshHold
![Page 8: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/8.jpg)
Flyball Governor
![Page 9: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/9.jpg)
Flyball Governor
Load never drops to 0% capacity
Load never rises to 100% capacity
Balance is achieved through polling
Requires detailed tuning to establish optimal setting
End result is Autoscaling through natural equilibrium
![Page 10: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/10.jpg)
Flyball Governor
QueueWatch
Inbound Queue
Outbound Queue
Diagnostics Queue
Inbound Queue
Outbound Queue
Diagnostics Queue
Inbound Queue
Outbound Queue
Diagnostics Queue
1
2 2 2
Direct Exchange
3 3 3
![Page 11: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/11.jpg)
Flyball GovernorD
isp
atch
erR
ece
iver
ASP.NET
Receiver
Disp
atch
er
SimpleMathMicroservice
Input Queue
Output Queue
Message Bus
![Page 12: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/12.jpg)
Flyball GovernorD
isp
atc
he
rR
ecei
ver
ASP.NET
Input Queue
Output Queue
Message Bus
Receivers
Disp
atch
ers
SimpleMathMicroservices 1...n
![Page 13: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/13.jpg)
Microservices as N-Tier Applications
AMQP
AMQP
AMQP
AMQPBrowser API Queue Microservice Instances
HttpRequestMapper
CommandMessageBuilder
MessageDispatcher
ResponseMessageParser
ResponseMessageConsumer CommandMessageParser
CommandMessageMapper
MessageDispatcher
ResponseMessageBuilder
ServiceCommand
2. Map HTTP Request to CommandMessage
3. Build CommandMessage
4. Dispatch CommandMessage to INPUT Queue
5. Parse and extract CommandMessage
6. Map CommandMessage to ServiceCommand
7. Execute ServiceCommand
8. Build ResponseMessage
9. Dispatch ResponseMessage to OUTPUT Queue
10. Consume ResponseMessage
11. Parse Response
SignalR
SignalR
1. Send REST HTTP Request
12. Return Response
WEB #1
APP #1
APP #2
HTTP
To downstream apps
![Page 14: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/14.jpg)
Consistent Message Delivery
SimpleMath Microservice
Inbound Message Queue
Outbound Message Queue
Inbound Messages
Outbound Messages
1 2
3
4
5
ASP.NET App
![Page 15: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/15.jpg)
Consistent Message Delivery
SimpleMath Microservice
Inbound Message Queue
Inbound Messages
ASP.NET App
1 2
3
4
4
4
5
![Page 16: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/16.jpg)
Consistent Message Delivery
SimpleMath Microservice
Inbound Message Queue
Inbound Messages
ASP.NET App
1
3
Queue Pool
2
45
6
Queue Pool Queue
![Page 17: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/17.jpg)
Load Balancing a RabbitMQ Cluster
Node #1 Node #2 Node #3
Load Balancer
![Page 18: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/18.jpg)
Load Balancing a RabbitMQ Cluster
Node #1 Node #2 Node #3
Load Balancer
Client Application
1
2
3
![Page 19: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/19.jpg)
Load Balancing a RabbitMQ Cluster
Node #1 Node #2 Node #3
Load Balancer
Client Application
NewQueue1 NewQueue2 NewQueue3
![Page 20: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/20.jpg)
Load Balancing a RabbitMQ Cluster
Node #1 Node #2 Node #3
Client ApplicationRandomiser
![Page 21: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/21.jpg)
Load Balancing a RabbitMQ Cluster
Node #1 Node #2 Node #3
Client Application
Monitor Service
Queue Metadata StoreRandomiser
![Page 22: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/22.jpg)
Selling to the BusinessReal-world example of how to sell Microservices to techies and non-
techies alike.
![Page 23: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/23.jpg)
Monolithic Flow #1
I want to book a flight
![Page 24: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/24.jpg)
Monolithic Flow #2
Here are the available flights
![Page 25: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/25.jpg)
Monolithic Flow #3
I want to book one of those flights
![Page 26: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/26.jpg)
Monolithic Flow #4
Would you like to hire a car?
![Page 27: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/27.jpg)
Business Drawbacks
One-way communication
Customer is in control
Website is idle when user is idle
Limited window of opportunity to interact
Reduced scope for ancillary revenue
![Page 28: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/28.jpg)
Technical Drawbacks
Results in dependencies
Failure affects everything
Change is slow
Scale is expensive (minor features require unilateral scale)
Steep learning curve
Technology stack is limited to specific skillsets
Introduces legal pitfalls (PCI DSS, Compliance)
Duplicated components due to lack of explicit boundaries
Rigid – likely to break under pressure
![Page 29: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/29.jpg)
Microservice Flow #1
Car Hire
Hotel
Flight
Taxi
User Profile
Fare Finder
Flights
Other
![Page 30: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/30.jpg)
Microservice Flow #2
Car Hire
Hotel
Flight
Taxi
User Profile
Fare Finder
Flights
Taxis
Other
![Page 31: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/31.jpg)
Microservice Flow #3
Car Hire
Hotel
Flight
Taxi
User Profile
Fare Finder
Flights
Taxis
Cars
Other
![Page 32: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/32.jpg)
Microservice Flow #4
Car Hire
Hotel
Flight
Taxi
User Profile
Fare Finder
Flights
Taxis
Cars
Hotels
Other
![Page 33: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/33.jpg)
Enhanced Flow Step #5
Car Hire
Hotel
Flight
Taxi
User Profile
Fare Finder
Flights
Taxis
Cars
Fares
Hotels
Other
![Page 34: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/34.jpg)
Business Benefits
Two-way communication
We’re in control (think Google)
APIs are always working
Unlimited opportunities to interact
Broader scope for ancillary revenue
![Page 35: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/35.jpg)
Technical Benefits
Eliminates dependencies
Failure is isolated
React to change quicker
Scale is less expensive (APIs scale individually)
More intuitive learning curve
Technology stack is not limited to specific skillsets
Shielded from legal pitfalls
Reusable components
Flexible – will bend rather than break under pressure
![Page 36: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/36.jpg)
General Advice
Log everything
Log everything
Log some more
If a framework exists, use it
Try to avoid the technical swamp
![Page 37: Beginning Microservices with .NET & RabbitMQ](https://reader034.fdocuments.us/reader034/viewer/2022042510/5885f23e1a28ab864f8b6087/html5/thumbnails/37.jpg)
Let’s Talk Further…
insidethecpu.com (search for “Microservices”)
https://github.com/daishisystems/Daishi.AMQP
@daishisystems
https://ie.linkedin.com/in/daishisystems
Q&A